X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2FDBRefFetcher.java;h=a2526a944df0e83999a2ea8a741244586067bed9;hb=c19d2a91ca05e052e3408bf5852d88eb5d0608f1;hp=e8494e4271da581915e4f062cfe7be8602f17fc4;hpb=47168f025aefdaa044802bd5f8f510ffe43a4808;p=jalview.git diff --git a/src/jalview/ws/DBRefFetcher.java b/src/jalview/ws/DBRefFetcher.java index e8494e4..a2526a9 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.8.2) - * Copyright (C) 2014 The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b2) + * Copyright (C) 2015 The Jalview Authors * * This file is part of Jalview. * @@ -81,9 +81,10 @@ public class DBRefFetcher implements Runnable private SequenceI[] alseqs; /** - * when true - retrieved sequences will be trimmed to cover longest derived alignment sequence + * when true - retrieved sequences will be trimmed to cover longest derived + * alignment sequence */ - private boolean trimDsSeqs=true; + private boolean trimDsSeqs = true; public DBRefFetcher() { @@ -124,14 +125,19 @@ public class DBRefFetcher implements Runnable { alseqs[i] = seqs[i]; if (seqs[i].getDatasetSequence() != null) + { ds[i] = seqs[i].getDatasetSequence(); + } else + { ds[i] = seqs[i]; + } } this.dataset = ds; // TODO Jalview 2.5 lots of this code should be in the gui package! sfetcher = jalview.gui.SequenceFetcher.getSequenceFetcherSingleton(af); - // set default behaviour for transferring excess sequence data to the dataset + // set default behaviour for transferring excess sequence data to the + // dataset trimDsSeqs = Cache.getDefault("TRIM_FETCHED_DATASET_SEQS", true); if (sources == null) { @@ -281,11 +287,14 @@ public class DBRefFetcher implements Runnable { if (dbSources == null) { - throw new Error("Implementation error. Must initialise dbSources"); + throw new Error( + MessageManager + .getString("error.implementation_error_must_init_dbsources")); } running = true; long startTime = System.currentTimeMillis(); - af.setProgressBar("Fetching db refs", startTime); + af.setProgressBar(MessageManager.getString("status.fetching_db_refs"), + startTime); try { if (Cache.getDefault("DBREFFETCH_USEPICR", false)) @@ -381,7 +390,7 @@ public class DBRefFetcher implements Runnable if (retrieved != null) { transferReferences(sdataset, dbsource.getDbSource(), - retrieved,trimDsSeqs); + retrieved, trimDsSeqs); } } else @@ -391,8 +400,8 @@ public class DBRefFetcher implements Runnable { SequenceI sequence = dataset[seqIndex]; DBRefEntry[] uprefs = jalview.util.DBRefUtils.selectRefs( - sequence.getDBRef(), new String[] - { dbsource.getDbSource() }); // jalview.datamodel.DBRefSource.UNIPROT + sequence.getDBRef(), + new String[] { dbsource.getDbSource() }); // jalview.datamodel.DBRefSource.UNIPROT // }); // check for existing dbrefs to use if (uprefs != null && uprefs.length > 0) @@ -460,15 +469,20 @@ public class DBRefFetcher implements Runnable } // all databases have been queries. if (sbuffer.length() > 0) { - output.setText(MessageManager.getString("label.your_sequences_have_been_verified") + output.setText(MessageManager + .getString("label.your_sequences_have_been_verified") + sbuffer.toString()); - Desktop.addInternalFrame(output, MessageManager.getString("label.sequence_names_updated"), 600, 300); + Desktop.addInternalFrame(output, + MessageManager.getString("label.sequence_names_updated"), + 600, 300); // The above is the dataset, we must now find out the index // of the viewed sequence } - af.setProgressBar(MessageManager.getString("label.dbref_search_completed"), startTime); + af.setProgressBar( + MessageManager.getString("label.dbref_search_completed"), + startTime); // promptBeforeBlast(); running = false; @@ -478,14 +492,15 @@ public class DBRefFetcher implements Runnable /** * Verify local sequences in seqRefs against the retrieved sequence database * records. - * @param trimDatasetSeqs + * + * @param trimDatasetSeqs * */ void transferReferences(Vector sdataset, String dbSource, AlignmentI retrievedAl, boolean trimDatasetSeqs) // File // file) { - System.out.println("trimming ? "+trimDatasetSeqs); + System.out.println("trimming ? " + trimDatasetSeqs); if (retrievedAl == null || retrievedAl.getHeight() == 0) { return; @@ -509,8 +524,7 @@ public class DBRefFetcher implements Runnable Vector sequenceMatches = new Vector(); // look for corresponding accession ids DBRefEntry[] entryRefs = jalview.util.DBRefUtils.selectRefs( - entry.getDBRef(), new String[] - { dbSource }); + entry.getDBRef(), new String[] { dbSource }); if (entryRefs == null) { System.err @@ -586,9 +600,9 @@ public class DBRefFetcher implements Runnable sequence.getSequenceAsString()).toUpperCase(); int absStart = entrySeq.indexOf(nonGapped); - int mapStart = entry.getStart(); - jalview.datamodel.Mapping mp; + Mapping mp; + final int sequenceStart = sequence.getStart(); if (absStart == -1) { // Is local sequence contained in dataset sequence? @@ -608,12 +622,10 @@ public class DBRefFetcher implements Runnable // 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); + mp = new Mapping(null, new int[] { sequenceStart + absStart, + sequenceStart + 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 } @@ -636,7 +648,7 @@ public class DBRefFetcher implements Runnable if (sequence.getSequenceFeatures() != null) { SequenceFeature[] sf = sequence.getSequenceFeatures(); - int start = sequence.getStart(); + int start = sequenceStart; int end = sequence.getEnd(); int startShift = 1 - absStart - start; // how much the features // are @@ -658,9 +670,10 @@ public class DBRefFetcher implements Runnable + " from " + dbSource + " sequence : " + entry.getName()); sequence.transferAnnotation(entry, mp); // unknownSequences.remove(sequence); - int absEnd = absStart + nonGapped.length(); - absStart += 1; - if (!trimDatasetSeqs) { + absStart += entry.getStart(); + int absEnd = absStart + nonGapped.length() - 1; + if (!trimDatasetSeqs) + { // insert full length sequence from record sequence.setSequence(entry.getSequenceAsString()); sequence.setStart(entry.getStart()); @@ -668,7 +681,8 @@ public class DBRefFetcher implements Runnable if (updateRefFrame) { // finally, update local sequence reference frame if we're allowed - if (trimDatasetSeqs) { + if (trimDatasetSeqs) + { // just fix start/end sequence.setStart(absStart); sequence.setEnd(absEnd);