From 9f74164360b38c5e08c89f8e687dac01ddfc98bb Mon Sep 17 00:00:00 2001 From: jprocter Date: Tue, 4 Nov 2008 13:31:18 +0000 Subject: [PATCH] bugfix db ref retrieve routine so it removes dead query strings properly --- src/jalview/ws/DBRefFetcher.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/jalview/ws/DBRefFetcher.java b/src/jalview/ws/DBRefFetcher.java index 76e73e4..96ac7e8 100644 --- a/src/jalview/ws/DBRefFetcher.java +++ b/src/jalview/ws/DBRefFetcher.java @@ -213,27 +213,30 @@ public class DBRefFetcher implements Runnable { // Still queries to make for current seqIndex StringBuffer queryString = new StringBuffer(""); - int nqSize = (maxqlen > queries.size()) ? queries.size() + int numq=0,nqSize = (maxqlen > queries.size()) ? queries.size() : maxqlen; - for (int nq = 0, numq = 0; nq < nqSize; nq++) + + while (queries.size()>0 && numq < nqSize) { - String query = (String) queries.elementAt(nq); + String query = (String) queries.elementAt(0); if (dbsource.isValidReference(query)) { - queryString.append((nq == 0) ? "" : dbsource + queryString.append((numq == 0) ? "" : dbsource .getAccessionSeparator()); queryString.append(query); numq++; } - } - for (int nq = 0; nq < nqSize; nq++) - { + // remove the extracted query string queries.removeElementAt(0); } // make the queries and process the response AlignmentI retrieved = null; try { + if (jalview.bin.Cache.log.isDebugEnabled()) + { + jalview.bin.Cache.log.debug("Querying "+dbsource.getDbName()+" with : '"+queryString.toString()+"'"); + } retrieved = dbsource.getSequenceRecords(queryString.toString()); } catch (Exception ex) { @@ -259,7 +262,7 @@ public class DBRefFetcher implements Runnable { dbSources[db] }); // jalview.datamodel.DBRefSource.UNIPROT // }); // check for existing dbrefs to use - if (uprefs != null) + if (uprefs != null && uprefs.length>0) { for (int j = 0; j < uprefs.length; j++) { -- 1.7.10.2