public String toString()
{
StringBuilder sb = new StringBuilder(64);
- sb.append("From (").append(fromRatio).append(":").append(toRatio)
- .append(") [");
+ sb.append("[");
for (int[] shift : fromShifts)
{
sb.append(" ").append(Arrays.toString(shift));
*/
addTo.add(range);
}
+
+ /**
+ * Returns true if mapping is from forward strand, false if from reverse
+ * strand. Result is just based on the first 'from' range that is not a single
+ * position. Default is true unless proven to be false. Behaviour is not well
+ * defined if the mapping has a mixture of forward and reverse ranges.
+ *
+ * @return
+ */
+ public boolean isFromForwardStrand()
+ {
+ boolean forwardStrand = true;
+ for (int[] range : getFromRanges())
+ {
+ if (range[1] > range[0])
+ {
+ break; // forward strand confirmed
+ }
+ else if (range[1] < range[0])
+ {
+ forwardStrand = false;
+ break; // reverse strand confirmed
+ }
+ }
+ return forwardStrand;
+ }
}
MapList ml = new MapList(new int[] { 1, 5, 10, 15, 25, 20 }, new int[] {
51, 1 }, 1, 3);
String s = ml.toString();
- assertEquals("From (1:3) [ [1, 5] [10, 15] [25, 20] ] To [ [51, 1] ]",
+ assertEquals("[ [1, 5] [10, 15] [25, 20] ] To [ [51, 1] ]",
s);
}
String s = ml.toString();
assertEquals(
- "From (1:3) [ [11, 15] [20, 25] [35, 30] [2, 4] [37, 40] ] To [ [72, 22] [12, 17] [78, 83] [88, 96] ]",
+ "[ [11, 15] [20, 25] [35, 30] [2, 4] [37, 40] ] To [ [72, 22] [12, 17] [78, 83] [88, 96] ]",
s);
}
MapList ml2 = new MapList(new int[] { 15, 16 }, new int[] { 58, 53 },
1, 3);
ml.addMapList(ml2);
- assertEquals("From (1:3) [ [11, 16] ] To [ [72, 53] ]", ml.toString());
+ assertEquals("[ [11, 16] ] To [ [72, 53] ]", ml.toString());
}
@Test(groups = "Functional")
assertEquals(79, ml.getToLowest());
assertEquals(100, ml.getToHighest());
}
+
+ /**
+ * Test that method that inspects for the (first) forward or reverse from
+ * range. Single position ranges are ignored.
+ */
+ @Test(groups = { "Functional" })
+ public void testIsFromForwardStrand()
+ {
+ MapList ml = new MapList(new int[] { 2, 2, 3, 9, 12, 11 },
+ new int[] { 20, 11 }, 1, 1);
+ assertTrue(ml.isFromForwardStrand());
+
+ ml = new MapList(new int[] { 2, 2, 11, 5, 13, 14 },
+ new int[] { 20, 11 }, 1, 1);
+ assertFalse(ml.isFromForwardStrand());
+
+ ml = new MapList(new int[] { 2, 2, 4, 4, 6, 6 }, new int[] { 3, 1 }, 1,
+ 1);
+ assertTrue(ml.isFromForwardStrand());
+ }
}