JAL-1851 add retrieved sequence's start (-1) to match offset for start
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 14 Sep 2015 12:10:05 +0000 (13:10 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 14 Sep 2015 12:10:05 +0000 (13:10 +0100)
of trimmed sequence

src/jalview/ws/DBRefFetcher.java

index 5f03ec7..03632c8 100644 (file)
@@ -125,9 +125,13 @@ 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!
@@ -596,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?
@@ -619,8 +623,8 @@ public class DBRefFetcher implements Runnable
           // 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 },
+              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
@@ -645,7 +649,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
@@ -667,8 +671,8 @@ public class DBRefFetcher implements Runnable
                 + " from " + dbSource + " sequence : " + entry.getName());
         sequence.transferAnnotation(entry, mp);
         // unknownSequences.remove(sequence);
-        int absEnd = absStart + nonGapped.length();
-        absStart += 1;
+        absStart += entry.getStart();
+        int absEnd = absStart + nonGapped.length() - 1;
         if (!trimDatasetSeqs)
         {
           // insert full length sequence from record