Enable lower case colours
[jalview.git] / src / jalview / gui / SequenceFetcher.java
index 7b25531..2beb3d9 100755 (executable)
@@ -1,6 +1,6 @@
 /*\r
  * Jalview - A Sequence Alignment Editor and Viewer\r
- * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
  *\r
  * This program is free software; you can redistribute it and/or\r
  * modify it under the terms of the GNU General Public License\r
@@ -119,8 +119,8 @@ public class SequenceFetcher
                                               new Insets(0, 4, 0, 0), 1, 0));\r
     this.add(textfield, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0\r
                                                , GridBagConstraints.CENTER,\r
-                                               GridBagConstraints.HORIZONTAL,\r
-                                               new Insets(0, 0, 0, 6), 200, 1));\r
+                                               GridBagConstraints.NONE,\r
+                                               new Insets(0, 0, 0, 6), 211, 1));\r
   }\r
 \r
   JComboBox database = new JComboBox();\r
@@ -183,16 +183,26 @@ public class SequenceFetcher
     else if (database.getSelectedItem().equals("EMBL")\r
              || database.getSelectedItem().equals("EMBLCDS"))\r
     {\r
-      EBIFetchClient dbFetch = new EBIFetchClient();\r
-      String[] reply = dbFetch.fetchData(\r
-          database.getSelectedItem().toString().toLowerCase(\r
-          ) + ":" + textfield.getText(),\r
-          "fasta", "raw");\r
+      StringTokenizer st = new StringTokenizer(textfield.getText(), ";");\r
+      while(st.hasMoreTokens())\r
+      {\r
+        EBIFetchClient dbFetch = new EBIFetchClient();\r
+\r
+        String[] reply = dbFetch.fetchData(\r
+            database.getSelectedItem().toString().toLowerCase(\r
+            ) + ":" + st.nextToken(),\r
+            "fasta", "raw");\r
+//\r
+        if (reply != null)\r
+        {\r
+          for (int i = 0; i < reply.length; i++)\r
+            result.append(reply[i] + "\n");\r
+        }\r
+      }\r
 \r
-      if(reply!=null)\r
+      if(result!=null)\r
       {\r
-        for (int i = 0; i < reply.length; i++)\r
-          result.append(reply[i] + "\n");\r
+        System.out.println(result.toString());\r
 \r
         parseResult(result.toString(), null);\r
       }\r
@@ -239,9 +249,9 @@ public class SequenceFetcher
   {\r
     EBIFetchClient ebi = new EBIFetchClient();\r
     File file = ebi.fetchDataAsFile("uniprot:" + id, "xml", null);\r
-   // File file = new File("H:/jalview/classes/fer1.xml");\r
-    SequenceFeatureFetcher sff = new SequenceFeatureFetcher();\r
-    Vector entries = sff.getUniprotEntries(file);\r
+\r
+    DBRefFetcher dbref = new DBRefFetcher();\r
+    Vector entries = dbref.getUniprotEntries(file);\r
 \r
     if (entries != null)\r
     {\r
@@ -291,6 +301,17 @@ public class SequenceFetcher
           onlyPdbEntries.addElement(pdb);\r
         }\r
 \r
+        Enumeration en2 = entry.getAccession().elements();\r
+        while (en2.hasMoreElements())\r
+        {\r
+          sequence[i].getDatasetSequence().addDBRef(new DBRefEntry(DBRefSource.UNIPROT,\r
+                    "0",\r
+                    en2.nextElement().toString()));\r
+        }\r
+\r
+\r
+\r
+\r
         sequence[i].getDatasetSequence().setPDBId(onlyPdbEntries);\r
         if (entry.getFeature() != null)\r
         {\r
@@ -317,17 +338,18 @@ public class SequenceFetcher
     }\r
 \r
     EBIFetchClient ebi = new EBIFetchClient();\r
-    String[] reply = ebi.fetchData("pdb:" + id, "pdb", "raw");\r
-    if (reply == null)\r
+    String file = ebi.fetchDataAsFile("pdb:" + id, "pdb", "raw").getAbsolutePath();\r
+    if (file == null)\r
       return null;\r
     try\r
     {\r
-      PDBfile pdbfile = new PDBfile(reply);\r
+      PDBfile pdbfile = new PDBfile(file, jalview.io.AppletFormatAdapter.FILE);\r
       for (int i = 0; i < pdbfile.chains.size(); i++)\r
       {\r
         if (chain == null ||\r
             ( (PDBChain) pdbfile.chains.elementAt(i)).id.\r
             toUpperCase().equals(chain))\r
+\r
           result.append("\n>PDB|" + id + "|" +\r
                         ( (PDBChain) pdbfile.chains.elementAt(i)).sequence.\r
                         getName() +\r
@@ -353,7 +375,7 @@ public class SequenceFetcher
     String format = new IdentifyFile().Identify(result, "Paste");\r
     SequenceI[] sequences = null;\r
 \r
-    if (FormatAdapter.formats.contains(format))\r
+    if (FormatAdapter.isValidFormat(format))\r
     {\r
       sequences = null;\r
       try{ sequences = new FormatAdapter().readFile(result.toString(), "Paste",\r
@@ -364,15 +386,19 @@ public class SequenceFetcher
       {\r
         if (alignFrame == null)\r
         {\r
-          AlignFrame af = new AlignFrame(new Alignment(sequences));\r
+          AlignFrame af = new AlignFrame(new Alignment(sequences),\r
+                                           AlignFrame.DEFAULT_WIDTH,\r
+                                           AlignFrame.DEFAULT_HEIGHT\r
+);\r
           af.currentFileFormat = format;\r
           if(title==null)\r
             title = "Retrieved from " + database.getSelectedItem();\r
           Desktop.addInternalFrame(af,\r
                                    title,\r
-                                   AlignFrame.NEW_WINDOW_WIDTH,\r
-                                   AlignFrame.NEW_WINDOW_HEIGHT);\r
+                                   AlignFrame.DEFAULT_WIDTH,\r
+                                   AlignFrame.DEFAULT_HEIGHT);\r
           af.statusBar.setText("Successfully pasted alignment file");\r
+\r
           try\r
           {\r
             af.setMaximum(jalview.bin.Cache.getDefault("SHOW_FULLSCREEN", false));\r
@@ -431,7 +457,7 @@ public class SequenceFetcher
 \r
               // We make a DBRefEtntry because we have obtained the PDB file from a verifiable source\r
               // JBPNote - PDB DBRefEntry should also carry the chain and mapping information\r
-              DBRefEntry dbentry = new DBRefEntry("PDB","0",pdbid);\r
+              DBRefEntry dbentry = new DBRefEntry(jalview.datamodel.DBRefSource.PDB,"0",pdbid);\r
               sequences[i].getDatasetSequence().addDBRef(dbentry);\r
             }\r
             else\r