JAL-2106 tidy up and comments for DBRefFetcher
authorJim Procter <jprocter@issues.jalview.org>
Wed, 24 Aug 2016 16:29:55 +0000 (17:29 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Wed, 24 Aug 2016 16:30:54 +0000 (17:30 +0100)
src/jalview/ws/DBRefFetcher.java

index 3ba0e34..6213568 100644 (file)
@@ -622,33 +622,43 @@ public class DBRefFetcher implements Runnable
         final int sequenceStart = sequence.getStart();
         if (absStart == -1)
         {
-          // Is local sequence contained in dataset sequence?
+          // couldn't find local sequence in sequence from database, so check if
+          // the database sequence is a subsequence of local sequence
           absStart = nonGapped.indexOf(entrySeq);
           if (absStart == -1)
-          { // verification failed.
+          {
+            // verification failed. couldn't find any relationship between
+            // entrySeq and local sequence
             messages.append(sequence.getName()
                     + " SEQUENCE NOT %100 MATCH \n");
             continue;
           }
+          /*
+           * found match for the whole of the database sequence within the local
+           * sequence's reference frame. 
+           */
           transferred = true;
           sbuffer.append(sequence.getName() + " HAS " + absStart
                   + " PREFIXED RESIDUES COMPARED TO " + dbSource + "\n");
-          //
-          // + " - ANY SEQUENCE FEATURES"
-          // + " HAVE BEEN ADJUSTED ACCORDINGLY \n");
-          // absStart = 0;
-          // create valid mapping between matching region of local sequence and
-          // the mapped sequence
+
+          /*
+           * So create a mapping to the external entry from the matching region of 
+           * the local sequence, and leave local start/end untouched. 
+           */
           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
+          updateRefFrame = false;
         }
         else
         {
+          /*
+           * found a match for the local sequence within sequence from 
+           * the external database 
+           */
           transferred = true;
+
           // update start and end of local sequence to place it in entry's
           // reference frame.
           // apply identity map map from whole of local sequence to matching
@@ -660,10 +670,14 @@ public class DBRefFetcher implements Runnable
           // absStart+sequence.getStart()+entrySeq.length()-1},
           // new int[] { entry.getStart(), entry.getEnd() }, 1, 1);
           // relocate local features for updated start
+
           if (updateRefFrame)
           {
             if (sequence.getSequenceFeatures() != null)
             {
+              /*
+               * relocate existing sequence features by offset
+               */
               SequenceFeature[] sf = sequence.getSequenceFeatures();
               int start = sequenceStart;
               int end = sequence.getEnd();
@@ -686,7 +700,7 @@ public class DBRefFetcher implements Runnable
         System.out.println("Adding dbrefs to " + sequence.getName()
                 + " from " + dbSource + " sequence : " + entry.getName());
         sequence.transferAnnotation(entry, mp);
-        // unknownSequences.remove(sequence);
+
         absStart += entry.getStart();
         int absEnd = absStart + nonGapped.length() - 1;
         if (!trimDatasetSeqs)