JAL-2909 Updated tests feature/JAL-2909bamfiles
authorkiramt <k.mourao@dundee.ac.uk>
Thu, 1 Mar 2018 13:28:43 +0000 (13:28 +0000)
committerkiramt <k.mourao@dundee.ac.uk>
Thu, 1 Mar 2018 13:28:43 +0000 (13:28 +0000)
src/jalview/datamodel/CigarParser.java
test/jalview/datamodel/CigarParserTest.java

index d82bdec..0abe9bf 100644 (file)
@@ -68,11 +68,12 @@ public class CigarParser
         {
           // ERROR
           int pos = rec.getStart() + refnext;
-          System.out.println("Insertion not added to seqInserts: " + pos);
+          System.out.println(
+                  "Read " + rec.getReadName() + " has an insertion at "
+                          + pos + " which is not in seqInserts");
         }
         else
         {
-
           // we just inserted something
           // remove these inserts now - should be very first entry
           int count = seqInserts.get(rec.getStart() + refnext);
index db3e198..80121ee 100644 (file)
@@ -38,15 +38,27 @@ public class CigarParserTest
     insertions3.put(8, 3);
     insertions3.put(105, 3);
 
+    SortedMap<Integer, Integer> insertions4 = new TreeMap<>();
+    insertions4.put(8, 3);
+    insertions4.put(105, 2);
+    insertions4.put(109, 3);
+    insertions4.put(112, 1);
+
     String read = "CGAAGCTCTTTACCCGGAAACCATTGAAATCGGACGGTTTAGTGAAATGGAGGATCAAGTTGGGTTTGGGTTCCGTCCGAACGACGAGGAGCTCGTTGGTC";
 
     return new Object[][] { { "1S84M2I14M", read, 21,
         "-----------------------GAAGCTCTTTACCCGGAAACCATTGAAATCGGACGGTTTAGTGAAATGGAGGATCAAGTTGGGTTTGGGTTCCGTCCGAACGACGAGGAGCTCGTTGGTC",
-        insertions },
+        insertions }, // first residue is G (accounting for C soft clip) at
+                      // position 21 + 3 (insertions at position 8)
         { "1S84M2I14M", read, 21,
             "-----------------------GAAGCTCTTTACCCGGAAACCATTGAAATCGGACGGTTTAGTGAAATGGAGGATCAAGTTGGGTTTGGGTTCCGTCCGAACGACGA-GGAGCTCGTTGGTC",
-            insertions3 },
-
+            insertions3 }, // read has 2 insertions accounted for in
+                           // insertions3, 3rd insertion is added as gap at
+                           // position 105
+        { "1S84M2I14M", read, 21,
+            "-----------------------GAAGCTCTTTACCCGGAAACCATTGAAATCGGACGGTTTAGTGAAATGGAGGATCAAGTTGGGTTTGGGTTCCGTCCGAACGACGAGGAG---CTC-GTTGGTC",
+            insertions4 }, // 2 insertions in read accounted for at position
+                           // 105; 3 insertions at 109 and 1 insertion at 112
         { "44M1D57M",
         read,
         3,
@@ -112,10 +124,12 @@ public class CigarParserTest
     builder.addFrag("read_6", 22, 27000, false, false, "2M4I90M5S", "", 0);
     builder.addFrag("read_7", 22, 27000, false, false, "2M1I98M", "", 0);
 
+    builder.addFrag("read_8", 22, 27000, false, false, "3M200N2I5M", "", 0);
+
     Iterator<SAMRecord> it = builder.iterator();
     CigarParser cp = new CigarParser('-');
     SortedMap<Integer, Integer> insertions = cp.getInsertions(it);
-    Assert.assertEquals(insertions.size(), 5);
+    Assert.assertEquals(insertions.size(), 6);
     Assert.assertTrue(insertions.containsKey(28838));
     Assert.assertEquals((int) insertions.get(28838), 1);
     Assert.assertTrue(insertions.containsKey(28885));
@@ -126,5 +140,7 @@ public class CigarParserTest
     Assert.assertEquals((int) insertions.get(28914), 3);
     Assert.assertTrue(insertions.containsKey(27002));
     Assert.assertEquals((int) insertions.get(27002), 4);
+    Assert.assertTrue(insertions.containsKey(27203));
+    Assert.assertEquals((int) insertions.get(27203), 2);
   }
 }