MapList ml7 = new MapList(codons, protein, 3, 1); // toShifts differ
assertTrue(ml.equals(ml));
+ assertEquals(ml.hashCode(), ml.hashCode());
assertTrue(ml.equals(ml1));
+ assertEquals(ml.hashCode(), ml1.hashCode());
assertTrue(ml1.equals(ml));
assertFalse(ml.equals(null));
@Test(groups = { "Functional" })
public void testGetRanges()
{
- List<int[]> ranges = new ArrayList<int[]>();
+ List<int[]> ranges = new ArrayList<>();
ranges.add(new int[] { 2, 3 });
ranges.add(new int[] { 5, 6 });
assertEquals("[2, 3, 5, 6]", Arrays.toString(MapList.getRanges(ranges)));
public void testAddRange()
{
int[] range = { 1, 5 };
- List<int[]> ranges = new ArrayList<int[]>();
+ List<int[]> ranges = new ArrayList<>();
// add to empty list:
MapList.addRange(range, ranges);
public void testCoalesceRanges()
{
assertNull(MapList.coalesceRanges(null));
- List<int[]> ranges = new ArrayList<int[]>();
+ List<int[]> ranges = new ArrayList<>();
assertSame(ranges, MapList.coalesceRanges(ranges));
ranges.add(new int[] { 1, 3 });
assertSame(ranges, MapList.coalesceRanges(ranges));
@Test(groups = { "Functional" })
public void testCoalesceRanges_withOverlap()
{
- List<int[]> ranges = new ArrayList<int[]>();
+ List<int[]> ranges = new ArrayList<>();
ranges.add(new int[] { 1, 3 });
ranges.add(new int[] { 2, 5 });
*/
MapList ml1 = new MapList(new int[] { 3, 4, 8, 12 }, new int[] { 5, 8,
11, 13 }, 1, 1);
+ assertEquals("{[3, 4], [8, 12]}", prettyPrint(ml1.getFromRanges()));
+ assertEquals("{[5, 8], [11, 13]}", prettyPrint(ml1.getToRanges()));
+
MapList ml2 = new MapList(new int[] { 1, 50 }, new int[] { 40, 45, 70,
75, 90, 127 }, 1, 1);
+ assertEquals("{[1, 50]}", prettyPrint(ml2.getFromRanges()));
+ assertEquals("{[40, 45], [70, 75], [90, 127]}",
+ prettyPrint(ml2.getToRanges()));
+
MapList compound = ml1.traverse(ml2);
- assertEquals(compound.getFromRatio(), 1);
- assertEquals(compound.getToRatio(), 1);
+ assertEquals(1, compound.getFromRatio());
+ assertEquals(1, compound.getToRatio());
List<int[]> fromRanges = compound.getFromRanges();
- assertEquals(fromRanges.size(), 2);
+ assertEquals(2, fromRanges.size());
assertArrayEquals(new int[] { 3, 4 }, fromRanges.get(0));
assertArrayEquals(new int[] { 8, 12 }, fromRanges.get(1));
List<int[]> toRanges = compound.getToRanges();
- assertEquals(toRanges.size(), 2);
+ assertEquals(4, toRanges.size());
// 5-8 maps to 44-45,70-71
// 11-13 maps to 74-75,90
- assertArrayEquals(new int[] { 44, 45, 70, 71 }, toRanges.get(0));
- assertArrayEquals(new int[] { 74, 75, 90, 90 }, toRanges.get(1));
+ assertArrayEquals(new int[] { 44, 45 }, toRanges.get(0));
+ assertArrayEquals(new int[] { 70, 71 }, toRanges.get(1));
+ assertArrayEquals(new int[] { 74, 75 }, toRanges.get(2));
+ assertArrayEquals(new int[] { 90, 90 }, toRanges.get(3));
/*
* 1:1 over 1:1 backwards ('reverse strand')
new int[] { 1000, 901, 600, 201 }, 1, 1);
compound = ml1.traverse(ml2);
- assertEquals(compound.getFromRatio(), 1);
- assertEquals(compound.getToRatio(), 1);
+ assertEquals(1, compound.getFromRatio());
+ assertEquals(1, compound.getToRatio());
fromRanges = compound.getFromRanges();
- assertEquals(fromRanges.size(), 1);
+ assertEquals(1, fromRanges.size());
assertArrayEquals(new int[] { 1, 50 }, fromRanges.get(0));
toRanges = compound.getToRanges();
- assertEquals(toRanges.size(), 1);
- assertArrayEquals(new int[] { 931, 901, 600, 582 }, toRanges.get(0));
+ assertEquals(2, toRanges.size());
+ assertArrayEquals(new int[] { 931, 901 }, toRanges.get(0));
+ assertArrayEquals(new int[] { 600, 582 }, toRanges.get(1));
/*
* 1:1 plus 1:3 should result in 1:3
1, 3);
compound = ml1.traverse(ml2);
- assertEquals(compound.getFromRatio(), 1);
- assertEquals(compound.getToRatio(), 3);
+ assertEquals(1, compound.getFromRatio());
+ assertEquals(3, compound.getToRatio());
fromRanges = compound.getFromRanges();
- assertEquals(fromRanges.size(), 1);
+ assertEquals(1, fromRanges.size());
assertArrayEquals(new int[] { 1, 30 }, fromRanges.get(0));
// 11-40 maps to 31-50,91-160
toRanges = compound.getToRanges();
- assertEquals(toRanges.size(), 1);
- assertArrayEquals(new int[] { 31, 50, 91, 160 }, toRanges.get(0));
+ assertEquals(2, toRanges.size());
+ assertArrayEquals(new int[] { 31, 50 }, toRanges.get(0));
+ assertArrayEquals(new int[] { 91, 160 }, toRanges.get(1));
/*
* 3:1 plus 1:1 should result in 3:1
1, 1);
compound = ml1.traverse(ml2);
- assertEquals(compound.getFromRatio(), 3);
- assertEquals(compound.getToRatio(), 1);
+ assertEquals(3, compound.getFromRatio());
+ assertEquals(1, compound.getToRatio());
fromRanges = compound.getFromRanges();
- assertEquals(fromRanges.size(), 1);
+ assertEquals(1, fromRanges.size());
assertArrayEquals(new int[] { 1, 30 }, fromRanges.get(0));
// 11-20 maps to 11-15, 91-95
toRanges = compound.getToRanges();
- assertEquals(toRanges.size(), 1);
- assertArrayEquals(new int[] { 11, 15, 91, 95 }, toRanges.get(0));
+ assertEquals(2, toRanges.size());
+ assertArrayEquals(new int[] { 11, 15 }, toRanges.get(0));
+ assertArrayEquals(new int[] { 91, 95 }, toRanges.get(1));
/*
* 1:3 plus 3:1 should result in 1:1
3, 1);
compound = ml1.traverse(ml2);
- assertEquals(compound.getFromRatio(), 1);
- assertEquals(compound.getToRatio(), 1);
+ assertEquals(1, compound.getFromRatio());
+ assertEquals(1, compound.getToRatio());
fromRanges = compound.getFromRanges();
- assertEquals(fromRanges.size(), 1);
+ assertEquals(1, fromRanges.size());
assertArrayEquals(new int[] { 21, 40 }, fromRanges.get(0));
// 13-72 maps 3:1 to 55-70, 121-124
toRanges = compound.getToRanges();
- assertEquals(toRanges.size(), 1);
- assertArrayEquals(new int[] { 55, 70, 121, 124 }, toRanges.get(0));
+ assertEquals(2, toRanges.size());
+ assertArrayEquals(new int[] { 55, 70 }, toRanges.get(0));
+ assertArrayEquals(new int[] { 121, 124 }, toRanges.get(1));
/*
* 3:1 plus 1:3 should result in 1:1
1, 3);
compound = ml1.traverse(ml2);
- assertEquals(compound.getFromRatio(), 1);
- assertEquals(compound.getToRatio(), 1);
+ assertEquals(1, compound.getFromRatio());
+ assertEquals(1, compound.getToRatio());
fromRanges = compound.getFromRanges();
- assertEquals(fromRanges.size(), 1);
+ assertEquals(1, fromRanges.size());
assertArrayEquals(new int[] { 31, 90 }, fromRanges.get(0));
// 13-32 maps to 47-50,71-126
toRanges = compound.getToRanges();
- assertEquals(toRanges.size(), 1);
- assertArrayEquals(new int[] { 47, 50, 71, 126 }, toRanges.get(0));
+ assertEquals(2, toRanges.size());
+ assertArrayEquals(new int[] { 47, 50 }, toRanges.get(0));
+ assertArrayEquals(new int[] { 71, 126 }, toRanges.get(1));
/*
* method returns null if not all regions are mapped through
compound = ml1.traverse(ml2);
assertNull(compound);
}
+
+ /**
+ * Test that method that inspects for the (first) forward or reverse 'to' range.
+ * Single position ranges are ignored.
+ */
+ @Test(groups = { "Functional" })
+ public void testIsToForwardsStrand()
+ {
+ // [3-9] declares forward strand
+ MapList ml = new MapList(new int[] { 20, 11 },
+ new int[]
+ { 2, 2, 3, 9, 12, 11 }, 1, 1);
+ assertTrue(ml.isToForwardStrand());
+
+ // [11-5] declares reverse strand ([13-14] is ignored)
+ ml = new MapList(new int[] { 20, 11 },
+ new int[]
+ { 2, 2, 11, 5, 13, 14 }, 1, 1);
+ assertFalse(ml.isToForwardStrand());
+
+ // all single position ranges - defaults to forward strand
+ ml = new MapList(new int[] { 3, 1 }, new int[] { 2, 2, 4, 4, 6, 6 }, 1,
+ 1);
+ assertTrue(ml.isToForwardStrand());
+ }
}