bugfix db ref retrieve routine so it removes dead query strings properly
authorjprocter <Jim Procter>
Tue, 4 Nov 2008 13:31:18 +0000 (13:31 +0000)
committerjprocter <Jim Procter>
Tue, 4 Nov 2008 13:31:18 +0000 (13:31 +0000)
src/jalview/ws/DBRefFetcher.java

index 76e73e4..96ac7e8 100644 (file)
@@ -213,27 +213,30 @@ public class DBRefFetcher implements Runnable
         {\r
           // Still queries to make for current seqIndex\r
           StringBuffer queryString = new StringBuffer("");\r
-          int nqSize = (maxqlen > queries.size()) ? queries.size()\r
+          int numq=0,nqSize = (maxqlen > queries.size()) ? queries.size()\r
                   : maxqlen;\r
-          for (int nq = 0, numq = 0; nq < nqSize; nq++)\r
+          \r
+          while (queries.size()>0 && numq < nqSize)\r
           {\r
-            String query = (String) queries.elementAt(nq);\r
+            String query = (String) queries.elementAt(0);\r
             if (dbsource.isValidReference(query))\r
             {\r
-              queryString.append((nq == 0) ? "" : dbsource\r
+              queryString.append((numq == 0) ? "" : dbsource\r
                       .getAccessionSeparator());\r
               queryString.append(query);\r
               numq++;\r
             }\r
-          }\r
-          for (int nq = 0; nq < nqSize; nq++)\r
-          {\r
+            // remove the extracted query string\r
             queries.removeElementAt(0);\r
           }\r
           // make the queries and process the response\r
           AlignmentI retrieved = null;\r
           try\r
           {\r
+            if (jalview.bin.Cache.log.isDebugEnabled())\r
+            {\r
+              jalview.bin.Cache.log.debug("Querying "+dbsource.getDbName()+" with : '"+queryString.toString()+"'");\r
+            }\r
             retrieved = dbsource.getSequenceRecords(queryString.toString());\r
           } catch (Exception ex)\r
           {\r
@@ -259,7 +262,7 @@ public class DBRefFetcher implements Runnable
                     { dbSources[db] }); // jalview.datamodel.DBRefSource.UNIPROT\r
             // });\r
             // check for existing dbrefs to use\r
-            if (uprefs != null)\r
+            if (uprefs != null && uprefs.length>0)\r
             {\r
               for (int j = 0; j < uprefs.length; j++)\r
               {\r