X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2FDBRefFetcher.java;h=5ce7d285c4c93f81473e4cc6df4770b00871c12e;hb=28932bb93da81aff277d509d9a624a1119a4a979;hp=662bf31b88e830a3a8eb317aecd412b676d3bb38;hpb=a581135c768ce6c60c38bbd47003477f8c557eea;p=jalview.git diff --git a/src/jalview/ws/DBRefFetcher.java b/src/jalview/ws/DBRefFetcher.java index 662bf31..5ce7d28 100644 --- a/src/jalview/ws/DBRefFetcher.java +++ b/src/jalview/ws/DBRefFetcher.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) - * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4.0.b2) + * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -31,9 +31,8 @@ import jalview.ws.dbsources.Uniprot; import jalview.ws.ebi.EBIFetchClient; /** - * Implements a runnable for validating a sequence - * against external databases and then propagating - * references and features onto the sequence(s) + * Implements a runnable for validating a sequence against external databases + * and then propagating references and features onto the sequence(s) * * @author $author$ * @version $Revision$ @@ -83,7 +82,7 @@ public class DBRefFetcher implements Runnable } this.dataset = ds; // TODO Jalview 2.5 lots of this code should be in the gui package! - sfetcher = jalview.gui.SequenceFetcher.getSequenceFetcherSingleton(af); + sfetcher = jalview.gui.SequenceFetcher.getSequenceFetcherSingleton(af); // select appropriate databases based on alignFrame context. if (af.getViewport().getAlignment().isNucleotide()) { @@ -194,8 +193,10 @@ public class DBRefFetcher implements Runnable { maxqlen = ((Integer) dbsource.getDbSourceProperties().get( DBRefSource.MULTIACC)).intValue(); - } else { - maxqlen=1; + } + else + { + maxqlen = 1; } // iterate through db for each remaining un-verified sequence SequenceI[] currSeqs = new SequenceI[sdataset.size()]; @@ -212,35 +213,38 @@ 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) { ex.printStackTrace(); - } - catch (OutOfMemoryError err) + } catch (OutOfMemoryError err) { - new OOMWarning("retrieving database references ("+queryString.toString()+")", err); + new OOMWarning("retrieving database references (" + + queryString.toString() + ")", err); } if (retrieved != null) { @@ -258,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++) { @@ -355,14 +359,15 @@ public class DBRefFetcher implements Runnable } } } - if (sequenceMatches.size()==0) + if (sequenceMatches.size() == 0) { - // failed to match directly on accessionId==query so just compare all sequences to entry + // failed to match directly on accessionId==query so just compare all + // sequences to entry Enumeration e = seqRefs.keys(); while (e.hasMoreElements()) { Vector sqs = (Vector) seqRefs.get(e.nextElement()); - if (sqs!=null && sqs.size()>0) + if (sqs != null && sqs.size() > 0) { Enumeration sqe = sqs.elements(); while (sqe.hasMoreElements()) @@ -392,9 +397,12 @@ public class DBRefFetcher implements Runnable for (int m = 0; m < sequenceMatches.size(); m++) { sequence = (SequenceI) sequenceMatches.elementAt(m); - // only update start and end positions and shift features if there are no existing references - // TODO: test for legacy where uniprot or EMBL refs exist but no mappings are made (but content matches retrieved set) - boolean updateRefFrame = sequence.getDBRef()==null || sequence.getDBRef().length==0; + // only update start and end positions and shift features if there are + // no existing references + // TODO: test for legacy where uniprot or EMBL refs exist but no + // mappings are made (but content matches retrieved set) + boolean updateRefFrame = sequence.getDBRef() == null + || sequence.getDBRef().length == 0; // verify sequence against the entry sequence String nonGapped = AlignSeq.extractGaps("-. ", @@ -414,20 +422,23 @@ public class DBRefFetcher implements Runnable + " SEQUENCE NOT %100 MATCH \n"); continue; } - + sbuffer.append(sequence.getName() + " HAS " + absStart - + " PREFIXED RESIDUES COMPARED TO " + dbSource+"\n"); + + " PREFIXED RESIDUES COMPARED TO " + dbSource + "\n"); // - // + " - ANY SEQUENCE FEATURES" - // + " HAVE BEEN ADJUSTED ACCORDINGLY \n"); + // + " - ANY SEQUENCE FEATURES" + // + " HAVE BEEN ADJUSTED ACCORDINGLY \n"); // absStart = 0; // create valid mapping between matching region of local sequence and // the mapped sequence mp = new Mapping(null, new int[] - { sequence.getStart()+absStart, sequence.getStart()+absStart+entrySeq.length()-1 }, new int[] - { entry.getStart(), - entry.getStart() + entrySeq.length() - 1 }, 1, 1); - updateRefFrame=false; // mapping is based on current start/end so don't modify start and end + { sequence.getStart() + absStart, + sequence.getStart() + absStart + entrySeq.length() - 1 }, + new int[] + { entry.getStart(), + entry.getStart() + entrySeq.length() - 1 }, 1, 1); + updateRefFrame = false; // mapping is based on current start/end so + // don't modify start and end } else { @@ -447,7 +458,8 @@ public class DBRefFetcher implements Runnable SequenceFeature[] sf = sequence.getSequenceFeatures(); int start = sequence.getStart(); int end = sequence.getEnd(); - int startShift = 1-absStart-start; // how much the features are to be shifted by + int startShift = 1 - absStart - start; // how much the features are + // to be shifted by for (int sfi = 0; sfi < sf.length; sfi++) { if (sf[sfi].getBegin() >= start && sf[sfi].getEnd() <= end)