sq.checkValidRange();
assertEquals(22, sq.getEnd());
}
+
+ @Test(groups = { "Functional" })
+ public void testDeleteChars_withGaps()
+ {
+ /*
+ * delete gaps only
+ */
+ SequenceI sq = new Sequence("test/8-10", "A-B-C");
+ sq.createDatasetSequence();
+ assertEquals("ABC", sq.getDatasetSequence().getSequenceAsString());
+ sq.deleteChars(1, 2); // delete first gap
+ assertEquals("AB-C", sq.getSequenceAsString());
+ assertEquals(8, sq.getStart());
+ assertEquals(10, sq.getEnd());
+ assertEquals("ABC", sq.getDatasetSequence().getSequenceAsString());
+
+ /*
+ * delete gaps and residues at start (no new dataset sequence)
+ */
+ sq = new Sequence("test/8-10", "A-B-C");
+ sq.createDatasetSequence();
+ sq.deleteChars(0, 3); // delete A-B
+ assertEquals("-C", sq.getSequenceAsString());
+ assertEquals(10, sq.getStart());
+ assertEquals(10, sq.getEnd());
+ assertEquals("ABC", sq.getDatasetSequence().getSequenceAsString());
+
+ /*
+ * delete gaps and residues at end (no new dataset sequence)
+ */
+ sq = new Sequence("test/8-10", "A-B-C");
+ sq.createDatasetSequence();
+ sq.deleteChars(2, 5); // delete B-C
+ assertEquals("A-", sq.getSequenceAsString());
+ assertEquals(8, sq.getStart());
+ assertEquals(8, sq.getEnd());
+ assertEquals("ABC", sq.getDatasetSequence().getSequenceAsString());
+
+ /*
+ * delete gaps and residues internally (new dataset sequence)
+ */
+ sq = new Sequence("test/8-10", "A-B-C");
+ sq.createDatasetSequence();
+ sq.deleteChars(1, 3); // delete -B
+ assertEquals("A-C", sq.getSequenceAsString());
+ assertEquals(8, sq.getStart());
+ assertEquals(9, sq.getEnd());
+ assertEquals("ACDEF", sq.getDatasetSequence().getSequenceAsString());
+ assertEquals(8, sq.getDatasetSequence().getStart());
+ }
}