+
+ /*
+ * Subregions (base 1) described as { [start1, end1], [start2, end2], ...}
+ */
+ private List<int[]> fromShifts = new ArrayList<int[]>();
+
+ /*
+ * Same format as fromShifts, for the 'mapped to' sequence
+ */
+ private List<int[]> toShifts = new ArrayList<int[]>();
+
+ /*
+ * number of steps in fromShifts to one toRatio unit
+ */
+ private int fromRatio;
+
+ /*
+ * number of steps in toShifts to one fromRatio
+ */
+ private int toRatio;
+
+ /*
+ * lowest and highest value in the from Map
+ */
+ private int fromLowest;
+
+ private int fromHighest;
+
+ /*
+ * lowest and highest value in the to Map
+ */
+ private int toLowest;
+
+ private int toHighest;
+
+ /**
+ * Two MapList objects are equal if they are the same object, or they both
+ * have populated shift ranges and all values are the same.
+ */
+ @Override
+ public boolean equals(Object o)
+ {
+ // TODO should also override hashCode to ensure equal objects have equal
+ // hashcodes
+ if (o == null || !(o instanceof MapList))
+ {
+ return false;
+ }
+
+ MapList obj = (MapList) o;
+ if (obj == this)
+ {
+ return true;
+ }
+ if (obj.fromRatio != fromRatio || obj.toRatio != toRatio
+ || obj.fromShifts == null || obj.toShifts == null)
+ {
+ return false;
+ }
+ return Arrays
+ .deepEquals(fromShifts.toArray(), obj.fromShifts.toArray())
+ && Arrays
+ .deepEquals(toShifts.toArray(), obj.toShifts.toArray());
+ }
+
+ /**
+ * Returns the 'from' ranges as {[start1, end1], [start2, end2], ...}
+ *
+ * @return
+ */
+ public List<int[]> getFromRanges()
+ {
+ return fromShifts;
+ }
+
+ /**
+ * Returns the 'to' ranges as {[start1, end1], [start2, end2], ...}
+ *
+ * @return
+ */
+ public List<int[]> getToRanges()
+ {
+ return toShifts;
+ }
+
+ /**
+ * Flattens a list of [start, end] into a single [start1, end1, start2,
+ * end2,...] array.
+ *
+ * @param shifts
+ * @return
+ */
+ protected static int[] getRanges(List<int[]> shifts)
+ {
+ int[] rnges = new int[2 * shifts.size()];
+ int i = 0;
+ for (int[] r : shifts)
+ {
+ rnges[i++] = r[0];
+ rnges[i++] = r[1];
+ }
+ return rnges;
+ }
+
+ /**
+ *
+ * @return length of mapped phrase in from
+ */
+ public int getFromRatio()
+ {
+ return fromRatio;
+ }
+
+ /**
+ *
+ * @return length of mapped phrase in to
+ */
+ public int getToRatio()
+ {
+ return toRatio;
+ }
+
+ public int getFromLowest()
+ {
+ return fromLowest;
+ }
+
+ public int getFromHighest()
+ {
+ return fromHighest;
+ }
+
+ public int getToLowest()
+ {
+ return toLowest;
+ }
+
+ public int getToHighest()
+ {
+ return toHighest;
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param from
+ * contiguous regions as [start1, end1, start2, end2, ...]
+ * @param to
+ * same format as 'from'
+ * @param fromRatio
+ * phrase length in 'from' (e.g. 3 for dna)
+ * @param toRatio
+ * phrase length in 'to' (e.g. 1 for protein)
+ */