assertFalse(cs.equals(cs2));
assertFalse(cs2.equals(cs));
+ // with the wrong kind of object
+ assertFalse(cs.equals(new HiddenColumnsCursor()));
+
+ // with a different hiddenColumns object - by size
+ HiddenColumns cs3 = new HiddenColumns();
+ cs3.hideColumns(2, 3);
+ assertFalse(cs.equals(cs3));
+
// with hidden columns added in a different order
cs2.hideColumns(6, 9);
+ assertFalse(cs.equals(cs2));
+ assertFalse(cs2.equals(cs));
+
cs2.hideColumns(5, 8);
assertTrue(cs.equals(cs2));
assertTrue(cs.equals(cs));
assertTrue(cs2.equals(cs));
assertTrue(cs2.equals(cs2));
+
+ // different ranges, same size
+ cs.hideColumns(10, 12);
+ cs2.hideColumns(10, 15);
+ assertFalse(cs.equals(cs2));
+
}
@Test(groups = "Functional")
* Test the code used to locate the reference sequence ruler origin
*/
@Test(groups = { "Functional" })
- public void testLocateVisibleBoundsofSequence()
+ public void testLocateVisibleStartofSequence()
{
// create random alignment
AlignmentGenerator gen = new AlignmentGenerator(false);
}
@Test(groups = { "Functional" })
- public void testLocateVisibleBoundsPathologicals()
+ public void testLocateVisibleStartPathologicals()
{
// test some pathological cases we missed
AlignmentI al = new Alignment(
cs.hideInsertionsFor(al.getSequenceAt(0));
assertEquals("G", ""
+ al.getSequenceAt(0).getCharAt(cs.adjustForHiddenColumns(9)));
+
+ // KM: no idea what this is meant to be testing... seems to be an unfinished
+ // test
}
@Test(groups = { "Functional" })
{
ColumnSelection colsel = new ColumnSelection();
HiddenColumns cs = new HiddenColumns();
+
+ // test with null hidden columns
+ cs.revealHiddenColumns(5, colsel);
+ assertTrue(colsel.getSelected().isEmpty());
+
cs.hideColumns(5, 8);
colsel.addElement(10);
cs.revealHiddenColumns(5, colsel);
cs.revealHiddenColumns(6, colsel);
assertEquals(prevSize, cs.getSize());
assertTrue(colsel.getSelected().isEmpty());
+
+ // reveal hidden columns when there is more than one region
+ cs.hideColumns(20, 23);
+ // now there are 2 hidden regions
+ assertEquals(2, cs.getNumberOfRegions());
+
+ cs.revealHiddenColumns(20, colsel);
+
+ // hiddenColumns now has one region
+ assertEquals(1, cs.getNumberOfRegions());
+
+ // revealed columns are marked as selected (added to selection):
+ assertEquals("[20, 21, 22, 23]", colsel.getSelected().toString());
+
+ // call with a column past the end of the hidden column ranges
+ colsel.clear();
+ cs.revealHiddenColumns(20, colsel);
+ // hiddenColumns still has 1 region
+ assertEquals(1, cs.getNumberOfRegions());
+ assertTrue(colsel.getSelected().isEmpty());
}
@Test(groups = { "Functional" })
{
HiddenColumns hidden = new HiddenColumns();
ColumnSelection colsel = new ColumnSelection();
+
+ // test with null hidden columns
+ hidden.revealAllHiddenColumns(colsel);
+ assertTrue(colsel.getSelected().isEmpty());
+
hidden.hideColumns(5, 8);
hidden.hideColumns(2, 3);
colsel.addElement(11);
{ number.nextLong(), number.nextLong(), number.nextLong() });
toMark.set(n * number.nextInt(10), n * (25 + number.nextInt(25)));
HiddenColumns hc = new HiddenColumns();
+
+ if (n == 0)
+ {
+ hc.markHiddenRegions(fromMark = new BitSet());
+ assertTrue(fromMark.isEmpty());
+ }
+
hc.hideMarkedBits(toMark);
// see if we can recover bitfield
System.out.println(startEnd[0] + " : " + startEnd[1]);
assertEquals(1, startEnd[0]);
assertEquals(23, startEnd[1]);
+
+ // force lowest range to start of alignment
+ hc = new HiddenColumns();
+ hc.hideColumns(3, 4);
+ startEnd = hc.getVisibleStartAndEndIndex(align.getWidth());
+ assertEquals(0, startEnd[0]);
+ assertEquals(25, startEnd[1]);
}
@Test(groups = "Functional")
assertEquals(3, result[0]);
assertEquals(7, result[1]);
+ result = hc.getRegionWithEdgeAtRes(4);
+ assertEquals(10, result[0]);
+ assertEquals(10, result[1]);
+
result = hc.getRegionWithEdgeAtRes(5);
assertEquals(10, result[0]);
assertEquals(10, result[1]);
gappedseq.insertCharAt(7, al.getGapCharacter());
gappedseq.insertCharAt(8, al.getGapCharacter());
+ // force different kinds of padding
+ al.getSequenceAt(3).deleteChars(2, 23);
+ al.getSequenceAt(4).deleteChars(2, 27);
+ al.getSequenceAt(5).deleteChars(10, 27);
+
// create an alignment view with the gapped sequence
SequenceI[] seqs = new SequenceI[1];
seqs[0] = gappedseq;
AlignmentAnnotation ann = new AlignmentAnnotation("an", "some an",
anns);
+ // null annotation
+ AlignmentAnnotation nullann = null;
+ h.makeVisibleAnnotation(nullann);
+ assertNull(nullann);
+
+ h.makeVisibleAnnotation(1, 2, nullann);
+ assertNull(nullann);
+
+ // null annotations
+ AlignmentAnnotation emptyann = new AlignmentAnnotation("an", "some ann", null);
+ h.makeVisibleAnnotation(emptyann);
+ assertNull(emptyann.annotations);
+
+ h.makeVisibleAnnotation(3, 4, emptyann);
+ assertNull(emptyann.annotations);
+
+ // without bounds, does everything
+ h.makeVisibleAnnotation(ann);
+ assertEquals(12, ann.annotations.length);
+ assertNull(ann.annotations[0]);
+ assertNull(ann.annotations[1]);
+ assertEquals(1.0f, ann.annotations[2].value);
+ assertEquals(2.0f, ann.annotations[3].value);
+ assertEquals(3.0f, ann.annotations[4].value);
+ assertNull(ann.annotations[5]);
+ assertNull(ann.annotations[6]);
+ assertEquals(4.0f, ann.annotations[7].value);
+ assertEquals(5.0f, ann.annotations[8].value);
+ assertEquals(6.0f, ann.annotations[9].value);
+ assertEquals(7.0f, ann.annotations[10].value);
+ assertEquals(8.0f, ann.annotations[11].value);
+
// without hidden cols, just truncates
h.makeVisibleAnnotation(3, 5, ann);
assertEquals(3, ann.annotations.length);
assertEquals(2.0f, ann.annotations[0].value);
assertEquals(5.0f, ann.annotations[1].value);
assertEquals(6.0f, ann.annotations[2].value);
+
+ anns = new Annotation[] { null, null, new Annotation(1),
+ new Annotation(2), new Annotation(3), null, null, new Annotation(4),
+ new Annotation(5), new Annotation(6), new Annotation(7),
+ new Annotation(8), new Annotation(9), new Annotation(10),
+ new Annotation(11), new Annotation(12), new Annotation(13),
+ new Annotation(14), new Annotation(15) };
+ ann = new AlignmentAnnotation("an", "some an", anns);
+ h = new HiddenColumns();
+ h.hideColumns(5, 18);
+ h.hideColumns(20, 21);
+ h.makeVisibleAnnotation(1, 21, ann);
+ assertEquals(5, ann.annotations.length);
+ assertEquals(1.0f, ann.annotations[1].value);
+ assertEquals(2.0f, ann.annotations[2].value);
+ assertEquals(3.0f, ann.annotations[3].value);
+ assertNull(ann.annotations[0]);
+ assertNull(ann.annotations[4]);
}
@Test(groups = "Functional")
assertEquals(42, region[1]);
assertFalse(regions.hasNext());
}
+
+ /*
+ * the VisibleColsIterator is tested elsewhere, this just tests that
+ * it can be retrieved from HiddenColumns
+ */
+ @Test(groups = "Functional")
+ public void testGetVisibleColsIterator()
+ {
+ HiddenColumns h = new HiddenColumns();
+ Iterator<Integer> it = h.getVisibleColsIterator(0, 10);
+
+ assertTrue(it instanceof VisibleColsIterator);
+ }
+
+ @Test(groups = "Functional")
+ public void testHashCode()
+ {
+ HiddenColumns h = new HiddenColumns();
+ h.hideColumns(0, 25);
+
+ int result = h.hashCode();
+ assertTrue(result > 0);
+
+ h.hideColumns(30, 50);
+ assertTrue(h.hashCode() > 0);
+ assertTrue(result != h.hashCode());
+ }
}