+ @Test(groups = "Functional")
+ public void testRemoveStartPositions()
+ {
+ int[] ranges = new int[] { 1, 10 };
+ int[] adjusted = MappingUtils.removeStartPositions(0, ranges);
+ assertEquals("[1, 10]", Arrays.toString(adjusted));
+
+ adjusted = MappingUtils.removeStartPositions(1, ranges);
+ assertEquals("[2, 10]", Arrays.toString(adjusted));
+ assertEquals("[1, 10]", Arrays.toString(ranges));
+
+ ranges = adjusted;
+ adjusted = MappingUtils.removeStartPositions(1, ranges);
+ assertEquals("[3, 10]", Arrays.toString(adjusted));
+ assertEquals("[2, 10]", Arrays.toString(ranges));
+
+ ranges = new int[] { 2, 3, 10, 12 };
+ adjusted = MappingUtils.removeStartPositions(1, ranges);
+ assertEquals("[3, 3, 10, 12]", Arrays.toString(adjusted));
+ assertEquals("[2, 3, 10, 12]", Arrays.toString(ranges));
+
+ ranges = new int[] { 2, 2, 8, 12 };
+ adjusted = MappingUtils.removeStartPositions(1, ranges);
+ assertEquals("[8, 12]", Arrays.toString(adjusted));
+ assertEquals("[2, 2, 8, 12]", Arrays.toString(ranges));
+
+ ranges = new int[] { 2, 2, 8, 12 };
+ adjusted = MappingUtils.removeStartPositions(2, ranges);
+ assertEquals("[9, 12]", Arrays.toString(adjusted));
+ assertEquals("[2, 2, 8, 12]", Arrays.toString(ranges));
+
+ ranges = new int[] { 2, 2, 4, 4, 9, 12 };
+ adjusted = MappingUtils.removeStartPositions(1, ranges);
+ assertEquals("[4, 4, 9, 12]", Arrays.toString(adjusted));
+ assertEquals("[2, 2, 4, 4, 9, 12]", Arrays.toString(ranges));
+
+ ranges = new int[] { 2, 2, 4, 4, 9, 12 };
+ adjusted = MappingUtils.removeStartPositions(2, ranges);
+ assertEquals("[9, 12]", Arrays.toString(adjusted));
+ assertEquals("[2, 2, 4, 4, 9, 12]", Arrays.toString(ranges));
+
+ ranges = new int[] { 2, 3, 9, 12 };
+ adjusted = MappingUtils.removeStartPositions(3, ranges);
+ assertEquals("[10, 12]", Arrays.toString(adjusted));
+ assertEquals("[2, 3, 9, 12]", Arrays.toString(ranges));
+ }
+
+ /**
+ * Test the method that drops positions from the start of a mapped range, on
+ * the reverse strand
+ */
+ @Test(groups = "Functional")
+ public void testRemoveStartPositions_reverseStrand()
+ {
+ int[] ranges = new int[] { 10, 1 };
+ int[] adjusted = MappingUtils.removeStartPositions(0, ranges);
+ assertEquals("[10, 1]", Arrays.toString(adjusted));
+ assertEquals("[10, 1]", Arrays.toString(ranges));
+
+ ranges = adjusted;
+ adjusted = MappingUtils.removeStartPositions(1, ranges);
+ assertEquals("[9, 1]", Arrays.toString(adjusted));
+ assertEquals("[10, 1]", Arrays.toString(ranges));
+
+ ranges = adjusted;
+ adjusted = MappingUtils.removeStartPositions(1, ranges);
+ assertEquals("[8, 1]", Arrays.toString(adjusted));
+ assertEquals("[9, 1]", Arrays.toString(ranges));
+
+ ranges = new int[] { 12, 11, 9, 6 };
+ adjusted = MappingUtils.removeStartPositions(1, ranges);
+ assertEquals("[11, 11, 9, 6]", Arrays.toString(adjusted));
+ assertEquals("[12, 11, 9, 6]", Arrays.toString(ranges));
+
+ ranges = new int[] { 12, 12, 8, 4 };
+ adjusted = MappingUtils.removeStartPositions(1, ranges);
+ assertEquals("[8, 4]", Arrays.toString(adjusted));
+ assertEquals("[12, 12, 8, 4]", Arrays.toString(ranges));
+
+ ranges = new int[] { 12, 12, 8, 4 };
+ adjusted = MappingUtils.removeStartPositions(2, ranges);
+ assertEquals("[7, 4]", Arrays.toString(adjusted));
+ assertEquals("[12, 12, 8, 4]", Arrays.toString(ranges));
+
+ ranges = new int[] { 12, 12, 10, 10, 8, 4 };
+ adjusted = MappingUtils.removeStartPositions(1, ranges);
+ assertEquals("[10, 10, 8, 4]", Arrays.toString(adjusted));
+ assertEquals("[12, 12, 10, 10, 8, 4]", Arrays.toString(ranges));
+
+ ranges = new int[] { 12, 12, 10, 10, 8, 4 };
+ adjusted = MappingUtils.removeStartPositions(2, ranges);
+ assertEquals("[8, 4]", Arrays.toString(adjusted));
+ assertEquals("[12, 12, 10, 10, 8, 4]", Arrays.toString(ranges));
+
+ ranges = new int[] { 12, 11, 8, 4 };
+ adjusted = MappingUtils.removeStartPositions(3, ranges);
+ assertEquals("[7, 4]", Arrays.toString(adjusted));
+ assertEquals("[12, 11, 8, 4]", Arrays.toString(ranges));
+ }
+