+
+ /**
+ * Test dna complementing
+ */
+ @Test(groups = "Functional")
+ public void testGetComplement()
+ {
+ assertEquals('t', Dna.getComplement('a'));
+ assertEquals('T', Dna.getComplement('A'));
+ assertEquals('a', Dna.getComplement('t'));
+ assertEquals('A', Dna.getComplement('T'));
+ assertEquals('c', Dna.getComplement('g'));
+ assertEquals('C', Dna.getComplement('G'));
+ assertEquals('g', Dna.getComplement('c'));
+ assertEquals('G', Dna.getComplement('C'));
+ // note uU --> aA but not vice versa
+ assertEquals('a', Dna.getComplement('u'));
+ assertEquals('A', Dna.getComplement('U'));
+ // ambiguity codes, see http://www.bioinformatics.org/sms/iupac.html
+ assertEquals('r', Dna.getComplement('y'));
+ assertEquals('R', Dna.getComplement('Y'));
+ assertEquals('y', Dna.getComplement('r'));
+ assertEquals('Y', Dna.getComplement('R'));
+ assertEquals('k', Dna.getComplement('m'));
+ assertEquals('K', Dna.getComplement('M'));
+ assertEquals('m', Dna.getComplement('k'));
+ assertEquals('M', Dna.getComplement('K'));
+ assertEquals('b', Dna.getComplement('v'));
+ assertEquals('B', Dna.getComplement('V'));
+ assertEquals('v', Dna.getComplement('b'));
+ assertEquals('V', Dna.getComplement('B'));
+ assertEquals('d', Dna.getComplement('h'));
+ assertEquals('D', Dna.getComplement('H'));
+ assertEquals('h', Dna.getComplement('d'));
+ assertEquals('H', Dna.getComplement('D'));
+ assertEquals('Q', Dna.getComplement('Q'));
+ }
+
+ @Test(groups = "Functional")
+ public void testReverseSequence()
+ {
+ String seq = "AcGtUrYkMbVdHNX";
+
+ // reverse:
+ SequenceI reversed = Dna.reverseSequence("Seq1", seq, false);
+ assertEquals(new StringBuilder(seq).reverse()
+ .toString(), reversed.getSequenceAsString());
+ assertEquals("Seq1|rev", reversed.getName());
+
+ // reverse complement:
+ SequenceI revcomp = Dna.reverseSequence("Seq1", seq, true);
+ assertEquals("XNDhBvKmRyAaCgT", revcomp.getSequenceAsString());
+ assertEquals("Seq1|revcomp", revcomp.getName());
+ }