Formatting
[jalview.git] / src / jalview / io / DBRefFetcher.java
index bd3c733..445c90a 100644 (file)
@@ -1,37 +1,31 @@
 /*\r
-* Jalview - A Sequence Alignment Editor and Viewer\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
-* as published by the Free Software Foundation; either version 2\r
-* of the License, or (at your option) any later version.\r
-*\r
-* This program is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-* GNU General Public License for more details.\r
-*\r
-* You should have received a copy of the GNU General Public License\r
-* along with this program; if not, write to the Free Software\r
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
-*/\r
+ * Jalview - A Sequence Alignment Editor and Viewer\r
+ * Copyright (C) 2007 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
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
+ */\r
 package jalview.io;\r
 \r
-import jalview.datamodel.*;\r
-\r
-import jalview.gui.*;\r
-\r
 import java.io.*;\r
-\r
 import java.util.*;\r
 \r
-import org.exolab.castor.mapping.Mapping;\r
-\r
+import org.exolab.castor.mapping.*;\r
 import org.exolab.castor.xml.*;\r
-import jalview.analysis.AlignSeq;\r
-\r
-\r
+import jalview.analysis.*;\r
+import jalview.datamodel.*;\r
+import jalview.gui.*;\r
 \r
 /**\r
  * DOCUMENT ME!\r
@@ -39,7 +33,8 @@ import jalview.analysis.AlignSeq;
  * @author $author$\r
  * @version $Revision$\r
  */\r
-public class DBRefFetcher implements Runnable\r
+public class DBRefFetcher\r
+    implements Runnable\r
 {\r
   AlignmentI dataset;\r
   AlignFrame af;\r
@@ -73,10 +68,9 @@ public class DBRefFetcher implements Runnable
     }\r
     catch (Exception e)\r
     {\r
-      System.out.println("Error getUniprotEntries() "+e);\r
+      System.out.println("Error getUniprotEntries() " + e);\r
     }\r
 \r
-\r
     return uni.getUniprotEntries();\r
   }\r
 \r
@@ -98,13 +92,16 @@ public class DBRefFetcher implements Runnable
     thread.start();\r
     running = true;\r
 \r
-    if(waitTillFinished)\r
+    if (waitTillFinished)\r
     {\r
-      while(running)\r
+      while (running)\r
       {\r
-        try{\r
+        try\r
+        {\r
           Thread.sleep(500);\r
-        }catch(Exception ex){}\r
+        }\r
+        catch (Exception ex)\r
+        {}\r
       }\r
     }\r
 \r
@@ -122,15 +119,15 @@ public class DBRefFetcher implements Runnable
     key = key.toUpperCase();\r
 \r
     Vector seqs;\r
-    if(seqRefs.containsKey(key))\r
+    if (seqRefs.containsKey(key))\r
     {\r
-      seqs = (Vector)seqRefs.get(key);\r
+      seqs = (Vector) seqRefs.get(key);\r
 \r
-      if(seqs!=null && !seqs.contains(seq))\r
+      if (seqs != null && !seqs.contains(seq))\r
       {\r
         seqs.addElement(seq);\r
       }\r
-      else if(seqs==null)\r
+      else if (seqs == null)\r
       {\r
         seqs = new Vector();\r
         seqs.addElement(seq);\r
@@ -146,7 +143,6 @@ public class DBRefFetcher implements Runnable
     seqRefs.put(key, seqs);\r
   }\r
 \r
-\r
   /**\r
    * DOCUMENT ME!\r
    */\r
@@ -171,35 +167,39 @@ public class DBRefFetcher implements Runnable
              seqIndex++, i++)\r
         {\r
           Sequence sequence = (Sequence) sequences.get(seqIndex);\r
-          DBRefEntry [] uprefs = jalview.util.DBRefUtils.selectRefs(sequence.getDBRef(), new String[] {\r
+          DBRefEntry[] uprefs = jalview.util.DBRefUtils.selectRefs(sequence.\r
+              getDBRef(), new String[]\r
+              {\r
               jalview.datamodel.DBRefSource.UNIPROT});\r
-          if (uprefs!=null)\r
+          if (uprefs != null)\r
           {\r
-            if(uprefs.length+i>50)\r
+            if (uprefs.length + i > 50)\r
+            {\r
               break;\r
+            }\r
 \r
-            for(int j=0; j<uprefs.length; j++)\r
+            for (int j = 0; j < uprefs.length; j++)\r
             {\r
               addSeqId(sequence, uprefs[j].getAccessionId());\r
-              queryString.append(uprefs[j].getAccessionId()+";");\r
+              queryString.append(uprefs[j].getAccessionId() + ";");\r
             }\r
           }\r
           else\r
           {\r
             StringTokenizer st = new StringTokenizer(sequence.getName(), "|");\r
-            if(st.countTokens()+i>50)\r
+            if (st.countTokens() + i > 50)\r
             {\r
               //Dont send more than 50 id strings to dbFetch!!\r
-              seqIndex --;\r
+              seqIndex--;\r
             }\r
             else\r
             {\r
-                while(st.hasMoreTokens())\r
-                {\r
-                  String token = st.nextToken();\r
-                  addSeqId(sequence, token);\r
-                  queryString.append(token+";");\r
-                }\r
+              while (st.hasMoreTokens())\r
+              {\r
+                String token = st.nextToken();\r
+                addSeqId(sequence, token);\r
+                queryString.append(token + ";");\r
+              }\r
             }\r
           }\r
         }\r
@@ -233,13 +233,12 @@ public class DBRefFetcher implements Runnable
     }\r
 \r
     af.setProgressBar("DBRef search completed", startTime);\r
-   // promptBeforeBlast();\r
+    // promptBeforeBlast();\r
 \r
-   running = false;\r
+    running = false;\r
 \r
   }\r
 \r
-\r
   /**\r
    * DOCUMENT ME!\r
    *\r
@@ -250,7 +249,9 @@ public class DBRefFetcher implements Runnable
   void ReadUniprotFile(File file)\r
   {\r
     if (!file.exists())\r
+    {\r
       return;\r
+    }\r
 \r
     SequenceI sequence = null;\r
 \r
@@ -275,7 +276,9 @@ public class DBRefFetcher implements Runnable
           {\r
             sequence = (SequenceI) seqs.elementAt(jj);\r
             if (!sequenceMatches.contains(sequence))\r
+            {\r
               sequenceMatches.addElement(sequence);\r
+            }\r
           }\r
         }\r
       }\r
@@ -289,7 +292,9 @@ public class DBRefFetcher implements Runnable
           {\r
             sequence = (SequenceI) seqs.elementAt(jj);\r
             if (!sequenceMatches.contains(sequence))\r
+            {\r
               sequenceMatches.addElement(sequence);\r
+            }\r
           }\r
         }\r
       }\r
@@ -353,7 +358,9 @@ public class DBRefFetcher implements Runnable
         {\r
           PDBEntry pdb = (PDBEntry) e.nextElement();\r
           if (!pdb.getType().equals(DBRefSource.PDB))\r
+          {\r
             continue;\r
+          }\r
 \r
           sequence.addDBRef(new DBRefEntry(DBRefSource.PDB,\r
                                            "0",\r
@@ -371,5 +378,3 @@ public class DBRefFetcher implements Runnable
     }\r
   }\r
 }\r
-\r
-\r