From: kiramt Date: Thu, 1 Mar 2018 13:28:43 +0000 (+0000) Subject: JAL-2909 Updated tests X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Ffeature%2FJAL-2909bamfiles;p=jalview.git JAL-2909 Updated tests --- diff --git a/src/jalview/datamodel/CigarParser.java b/src/jalview/datamodel/CigarParser.java index d82bdec..0abe9bf 100644 --- a/src/jalview/datamodel/CigarParser.java +++ b/src/jalview/datamodel/CigarParser.java @@ -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); diff --git a/test/jalview/datamodel/CigarParserTest.java b/test/jalview/datamodel/CigarParserTest.java index db3e198..80121ee 100644 --- a/test/jalview/datamodel/CigarParserTest.java +++ b/test/jalview/datamodel/CigarParserTest.java @@ -38,15 +38,27 @@ public class CigarParserTest insertions3.put(8, 3); insertions3.put(105, 3); + SortedMap 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 it = builder.iterator(); CigarParser cp = new CigarParser('-'); SortedMap 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); } }