From: gmungoc Date: Thu, 1 Oct 2020 11:42:32 +0000 (+0100) Subject: JAL-3761 failing tests for locateInFrom/To with overlapping ranges X-Git-Tag: Release_2_11_2_0~34^2~26 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=fa76d5d684ed702e4c83549055524a0241c77baa;p=jalview.git JAL-3761 failing tests for locateInFrom/To with overlapping ranges --- diff --git a/test/jalview/util/MapListTest.java b/test/jalview/util/MapListTest.java index 71fbdfd..4017055 100644 --- a/test/jalview/util/MapListTest.java +++ b/test/jalview/util/MapListTest.java @@ -957,4 +957,57 @@ public class MapListTest 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)); + } }