JAL-2909 Fixed a bug in the insertions code
authorkiramt <k.mourao@dundee.ac.uk>
Wed, 28 Feb 2018 19:43:55 +0000 (19:43 +0000)
committerkiramt <k.mourao@dundee.ac.uk>
Wed, 28 Feb 2018 19:43:55 +0000 (19:43 +0000)
src/jalview/datamodel/CigarParser.java

index 786896b..fd5694c 100644 (file)
@@ -194,11 +194,12 @@ public class CigarParser
     StringBuilder newRead = new StringBuilder();
     String read = rec.getReadString();
 
-    int nextPos = next;
+    int nextPos = next; // location of next position in read
     while (nextPos < next + length)
     {
-      int insertPos = next + length;
-      int insertLen = 0;
+      int insertPos = next + length; // location of next insert in read (or end
+                                     // of read)
+      int insertLen = 0; // no of gaps to insert after insertPos
       if (it.hasNext())
       {
         // account for sequence already having insertion
@@ -220,6 +221,11 @@ public class CigarParser
         {
           insertPos = rec.getReadPositionAtReferencePosition(key) - 1;
         }
+        else
+        {
+          insertPos = nextPos; // bugfix - trigger by override + insertions in
+                               // same M stretch
+        }
       }
       newRead.append(read.substring(nextPos, insertPos));
       nextPos = insertPos;