sq.sequenceChanged();
assertEquals(6, sq.findIndex(9));
- sq = new Sequence("test/8-13", "-A--B-C-D-E-F--");
+ final String aligned = "-A--B-C-D-E-F--";
+ assertEquals(15, aligned.length());
+ sq = new Sequence("test/8-13", aligned);
assertEquals(2, sq.findIndex(8));
sq.sequenceChanged();
assertEquals(5, sq.findIndex(9));
// beyond end returns last residue column
sq.sequenceChanged();
assertEquals(13, sq.findIndex(99));
+
+ /*
+ * residue before sequence 'end' but beyond end of sequence returns
+ * length of sequence (last column) (rightly or wrongly!)
+ */
+ sq = new Sequence("test/8-15", "A-B-C-"); // trailing gap case
+ assertEquals(6, sq.getLength());
+ sq.sequenceChanged();
+ assertEquals(sq.getLength(), sq.findIndex(14));
+ sq = new Sequence("test/8-99", "-A--B-C-D"); // trailing residue case
+ sq.sequenceChanged();
+ assertEquals(sq.getLength(), sq.findIndex(65));
+
+ /*
+ * residue after sequence 'start' but before first residue returns
+ * zero (before first column) (rightly or wrongly!)
+ */
+ sq = new Sequence("test/8-15", "-A-B-C-"); // leading gap case
+ sq.sequenceChanged();
+ assertEquals(0, sq.findIndex(3));
+ sq = new Sequence("test/8-15", "A-B-C-"); // leading residue case
+ sq.sequenceChanged();
+ assertEquals(0, sq.findIndex(2));
}
/**
// find C given C
assertEquals(6, sq.findIndex(10, new SequenceCursor(sq, 10, 6, 0)));
+
+ /*
+ * sequence 'end' beyond end of sequence returns length of sequence
+ * (for compatibility with pre-cursor code)
+ */
+ sq = new Sequence("test/8-99", "-A--B-C-D-E-F--"); // trailing gap case
+ sq.findIndex(10); // establishes a cursor
+ assertEquals(sq.getLength(), sq.findIndex(65));
+ sq = new Sequence("test/8-99", "-A--B-C-D-E-F"); // trailing residue case
+ sq.findIndex(10); // establishes a cursor
+ assertEquals(sq.getLength(), sq.findIndex(65));
+
+ /*
+ * residue after sequence 'start' but before first residue should return
+ * zero (for compatibility with pre-cursor code)
+ */
+ sq = new Sequence("test/8-15", "-A-B-C-"); // leading gap case
+ sq.findIndex(10); // establishes a cursor
+ assertEquals(0, sq.findIndex(3));
+ sq = new Sequence("test/8-15", "A-B-C-"); // leading residue case
+ sq.findIndex(10); // establishes a cursor
+ assertEquals(0, sq.findIndex(2));
}
@Test(groups = { "Functional" })