1);
assertTrue(ml.isToForwardStrand());
}
+
+ /**
+ * Test for mapping with overlapping ranges
+ */
+ @Test(groups = { "Functional" })
+ public void testLocateInFrom_withOverlap()
+ {
+ int[] codons = new int[] { 1, 12, 12, 17 };
+ int[] protein = new int[] { 1, 6 };
+ MapList ml = new MapList(codons, protein, 3, 1);
+ assertEquals("[1, 3]", Arrays.toString(ml.locateInFrom(1, 1)));
+ assertEquals("[4, 6]", Arrays.toString(ml.locateInFrom(2, 2)));
+ assertEquals("[7, 9]", Arrays.toString(ml.locateInFrom(3, 3)));
+ assertEquals("[10, 12]", Arrays.toString(ml.locateInFrom(4, 4)));
+ assertEquals("[12, 14]", Arrays.toString(ml.locateInFrom(5, 5)));
+ assertEquals("[15, 17]", Arrays.toString(ml.locateInFrom(6, 6)));
+ assertEquals("[1, 6]", Arrays.toString(ml.locateInFrom(1, 2)));
+ assertEquals("[1, 9]", Arrays.toString(ml.locateInFrom(1, 3)));
+ assertEquals("[1, 12]", Arrays.toString(ml.locateInFrom(1, 4)));
+ assertEquals("[1, 12, 12, 14]", Arrays.toString(ml.locateInFrom(1, 5)));
+ assertEquals("[1, 12, 12, 17]", Arrays.toString(ml.locateInFrom(1, 6)));
+ assertEquals("[4, 9]", Arrays.toString(ml.locateInFrom(2, 3)));
+ assertEquals("[7, 12, 12, 17]", Arrays.toString(ml.locateInFrom(3, 6)));
+
+ assertNull(ml.locateInFrom(0, 0));
+ assertNull(ml.locateInFrom(1, 7));
+ assertNull(ml.locateInFrom(-1, 1));
+ }
+
+ /**
+ * Test for mapping with overlapping ranges
+ */
+ @Test(groups = { "Functional" })
+ public void testLocateInTo_withOverlap()
+ {
+ int[] codons = new int[] { 1, 12, 12, 17 };
+ int[] protein = new int[] { 1, 6 };
+ MapList ml = new MapList(codons, protein, 3, 1);
+ assertEquals("[1, 1]", Arrays.toString(ml.locateInTo(1, 1)));
+ assertEquals("[1, 3]", Arrays.toString(ml.locateInTo(3, 8)));
+ assertEquals("[1, 4]", Arrays.toString(ml.locateInTo(2, 11)));
+ assertEquals("[1, 4]", Arrays.toString(ml.locateInTo(3, 11)));
+
+ // we want 'greedy' mapping of base 12 to both peptides it codes for
+ assertEquals("[4, 5]", Arrays.toString(ml.locateInTo(12, 12)));
+ assertEquals("[4, 5]", Arrays.toString(ml.locateInTo(11, 12)));
+ assertEquals("[4, 6]", Arrays.toString(ml.locateInTo(11, 15)));
+ assertEquals("[6, 6]", Arrays.toString(ml.locateInTo(15, 17)));
+
+ assertNull(ml.locateInTo(0, 0));
+ assertNull(ml.locateInTo(1, 18));
+ assertNull(ml.locateInTo(-1, 1));
+ }
}