2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.analysis;
23 import static org.testng.AssertJUnit.assertEquals;
24 import static org.testng.AssertJUnit.assertNotNull;
25 import static org.testng.AssertJUnit.assertTrue;
27 import jalview.api.AlignViewportI;
28 import jalview.datamodel.AlignedCodon;
29 import jalview.datamodel.Alignment;
30 import jalview.datamodel.AlignmentI;
31 import jalview.datamodel.ColumnSelection;
32 import jalview.datamodel.SequenceI;
33 import jalview.gui.AlignViewport;
34 import jalview.io.FormatAdapter;
36 import java.io.IOException;
38 import org.testng.annotations.Test;
43 // AA encoding codons as ordered on the Jalview help page Amino Acid Table
44 private static String fasta = ">B\n" + "GCT" + "GCC" + "GCA" + "GCG"
45 + "TGT" + "TGC" + "GAT" + "GAC" + "GAA" + "GAG" + "TTT" + "TTC"
46 + "GGT" + "GGC" + "GGA" + "GGG" + "CAT" + "CAC" + "ATT" + "ATC"
47 + "ATA" + "AAA" + "AAG" + "TTG" + "TTA" + "CTT" + "CTC" + "CTA"
48 + "CTG" + "ATG" + "AAT" + "AAC" + "CCT" + "CCC" + "CCA" + "CCG"
49 + "CAA" + "CAG" + "CGT" + "CGC" + "CGA" + "CGG" + "AGA" + "AGG"
50 + "TCT" + "TCC" + "TCA" + "TCG" + "AGT" + "AGC" + "ACT" + "ACC"
51 + "ACA" + "ACG" + "GTT" + "GTC" + "GTA" + "GTG" + "TGG" + "TAT"
52 + "TAC" + "TAA" + "TAG" + "TGA";
54 private static String JAL_1312_example_align_fasta = ">B.FR.83.HXB2_LAI_IIIB_BRU_K03455/45-306\n"
55 + "ATGGGAAAAAATTCGGTTAAGGCCAGGGGGAAAGAAAAAATATAAATTAAAACATATAGTATGGGCAAGCAG\n"
56 + "GGAGCTAGAACGATTCGCAGTTAATCCTGGCCTGTTAGAAACATCAGAAGGCTGTAGACAAATACTGGGACA\n"
57 + "GCTACAACCATCCCTTCAGACAGGATCAGAAGAACTTAGATCATTATATAATACAGTAGCAACCCTCTATTG\n"
58 + "TGTGCATCAAAGGATAGAGATAAAAGACACCAAGGAAGCTTTAGAC\n"
59 + ">gi|27804621|gb|AY178912.1|/1-259\n"
60 + "-TGGGAGAA-ATTCGGTT-CGGCCAGGGGGAAAGAAAAAATATCAGTTAAAACATATAGTATGGGCAAGCAG\n"
61 + "AGAGCTAGAACGATTCGCAGTTAACCCTGGCCTTTTAGAGACATCACAAGGCTGTAGACAAATACTGGGACA\n"
62 + "GCTACAACCATCCCTTCAGACAGGATCAGAAGAACTTAAATCATTATATAATACAGTAGCAACCCTCTATTG\n"
63 + "TGTTCATCAAAGGATAGATATAAAAGACACCAAGGAAGCTTTAGAT\n"
64 + ">gi|27804623|gb|AY178913.1|/1-259\n"
65 + "-TGGGAGAA-ATTCGGTT-CGGCCAGGGGGAAAGAAAAAATATCAGTTAAAACATATAGTATGGGCAAGCAG\n"
66 + "AGAGCTAGAACGATTCGCAGTTAACCCTGGCCTTTTAGAGACATCACAAGGCTGTAGACAAATACTGGAACA\n"
67 + "GCTACAACCATCCCTTCAGACAGGATCAGAAGAACTTAAATCATTATATAATACAGTAGCAACCCTCTATTG\n"
68 + "TGTTCATCAAAGGATAGATGTAAAAGACACCAAGGAAGCTTTAGAT\n"
69 + ">gi|27804627|gb|AY178915.1|/1-260\n"
70 + "-TGGGAAAA-ATTCGGTTAAGGCCAGGGGGAAAGAAAAAATATAAGTTAAAACATATAGTATGGGCAAGCAG\n"
71 + "GGAGCTAGAACGATTCGCAGTTAACCCTGGCCTGTTAGAAACATCAGAAGGTTGTAGACAAATATTGGGACA\n"
72 + "GCTACAACCATCCCTTGAGACAGGATCAGAAGAACTTAAATCATTATWTAATACCATAGCAGTCCTCTATTG\n"
73 + "TGTACATCAAAGGATAGATATAAAAGACACCAAGGAAGCTTTAGAG\n"
74 + ">gi|27804631|gb|AY178917.1|/1-261\n"
75 + "-TGGGAAAAAATTCGGTTGAGGCCAGGGGGAAAGAAAAAATATAAGTTAAAACATATAGTATGGGCAAGCAG\n"
76 + "GGAGCTAGAACGATTCGCAGTCAACCCTGGCCTGTTAGAAACACCAGAAGGCTGTAGACAAATACTGGGACA\n"
77 + "GCTACAACCGTCCCTTCAGACAGGATCGGAAGAACTTAAATCATTATATAATACAGTAGCAACCCTCTATTG\n"
78 + "TGTGCATCAAAGGATAGATGTAAAAGACACCAAGGAGGCTTTAGAC\n"
79 + ">gi|27804635|gb|AY178919.1|/1-261\n"
80 + "-TGGGAGAGAATTCGGTTACGGCCAGGAGGAAAGAAAAAATATAAATTGAAACATATAGTATGGGCAGGCAG\n"
81 + "AGAGCTAGATCGATTCGCAGTCAATCCTGGCCTGTTAGAAACATCAGAAGGCTGCAGACAGATATTGGGACA\n"
82 + "GCTACAACCGTCCCTTAAGACAGGATCAGAAGAACTTAAATCATTATATAATACAGTAGCAACCCTCTATTG\n"
83 + "TGTACATCAAAGGATAGATGTAAAAGACACCAAGGAAGCTTTAGAT\n"
84 + ">gi|27804641|gb|AY178922.1|/1-261\n"
85 + "-TGGGAGAAAATTCGGTTACGGCCAGGGGGAAAGAAAAGATATAAGTTAAAACATATAGTATGGGCAAGCAG\n"
86 + "GGAGCTAGAACGATTCGCAGTCAACCCTGGCCTGTTAGAAACATCAGAAGGCTGCAGACAAATACTGGGACA\n"
87 + "GTTACACCCATCCCTTCATACAGGATCAGAAGAACTTAAATCATTATATAATACAGTAGCAACCCTCTATTG\n"
88 + "TGTGCATCAAAGGATAGAAGTAAAAGACACCAAGGAAGCTTTAGAC\n"
89 + ">gi|27804647|gb|AY178925.1|/1-261\n"
90 + "-TGGGAAAAAATTCGGTTAAGGCCAGGGGGAAAGAAAAAATATCAATTAAAACATGTAGTATGGGCAAGCAG\n"
91 + "GGAACTAGAACGATTCGCAGTTAATCCTGGCCTGTTAGAAACATCAGAAGGCTGTAGACAAATATTGGGACA\n"
92 + "GCTACAACCATCCCTTCAGACAGGATCAGAGGAACTTAAATCATTATTTAATACAGTAGCAGTCCTCTATTG\n"
93 + "TGTACATCAAAGAATAGATGTAAAAGACACCAAGGAAGCTCTAGAA\n"
94 + ">gi|27804649|gb|AY178926.1|/1-261\n"
95 + "-TGGGAAAAAATTCGGTTAAGGCCAGGGGGAAAGAAAAAATATAAGTTAAAACATATAGTATGGGCAAGCAG\n"
96 + "GGAGCTAGAACGATTCGCGGTCAATCCTGGCCTGTTAGAAACATCAGAAGGCTGTAGACAACTACTGGGACA\n"
97 + "GTTACAACCATCCCTTCAGACAGGATCAGAAGAACTCAAATCATTATATAATACAATAGCAACCCTCTATTG\n"
98 + "TGTGCATCAAAGGATAGAGATAAAAGACACCAAGGAAGCCTTAGAT\n"
99 + ">gi|27804653|gb|AY178928.1|/1-261\n"
100 + "-TGGGAAAGAATTCGGTTAAGGCCAGGGGGAAAGAAACAATATAAATTAAAACATATAGTATGGGCAAGCAG\n"
101 + "GGAGCTAGACCGATTCGCACTTAACCCCGGCCTGTTAGAAACATCAGAAGGCTGTAGACAAATATTGGGACA\n"
102 + "GCTACAATCGTCCCTTCAGACAGGATCAGAAGAACTTAGATCACTATATAATACAGTAGCAGTCCTCTATTG\n"
103 + "TGTGCATCAAAAGATAGATGTAAAAGACACCAAGGAAGCCTTAGAC\n"
104 + ">gi|27804659|gb|AY178931.1|/1-261\n"
105 + "-TGGGAAAAAATTCGGTTACGGCCAGGAGGAAAGAAAAGATATAAATTAAAACATATAGTATGGGCAAGCAG\n"
106 + "GGAGCTAGAACGATTYGCAGTTAATCCTGGCCTTTTAGAAACAGCAGAAGGCTGTAGACAAATACTGGGACA\n"
107 + "GCTACAACCATCCCTTCAGACAGGATCAGAAGAACTTAAATCATTATATAATACAGTAGCAACCCTCTATTG\n"
108 + "TGTACATCAAAGGATAGAGATAAAAGACACCAAGGAAGCTTTAGAA\n";
112 * Corner case for this test is the presence of codons after codons that were
115 * @throws IOException
117 @Test(groups = { "Functional" })
118 public void testTranslateCdna_withUntranslatableCodons()
121 AlignmentI alf = new FormatAdapter().readFile(
122 JAL_1312_example_align_fasta, jalview.io.FormatAdapter.PASTE,
124 ColumnSelection cs = new ColumnSelection();
125 AlignViewportI av = new AlignViewport(alf, cs);
126 Dna dna = new Dna(av, new int[] { 0, alf.getWidth() - 1 });
127 AlignmentI translated = dna.translateCdna();
128 assertNotNull("Couldn't do a full width translation of test data.",
133 * Test variant in which 15 column blocks at a time are translated (the rest
136 * @throws IOException
138 @Test(groups = { "Functional" })
139 public void testTranslateCdna_withUntranslatableCodonsAndHiddenColumns()
142 AlignmentI alf = new FormatAdapter().readFile(
143 JAL_1312_example_align_fasta, jalview.io.FormatAdapter.PASTE,
146 for (int ipos = 0; ipos + vwidth < alf.getWidth(); ipos += vwidth)
148 ColumnSelection cs = new ColumnSelection();
151 cs.hideColumns(0, ipos - 1);
153 cs.hideColumns(ipos + vwidth, alf.getWidth());
154 int[] vcontigs = cs.getVisibleContigs(0, alf.getWidth());
155 AlignViewportI av = new AlignViewport(alf, cs);
156 Dna dna = new Dna(av, vcontigs);
157 AlignmentI transAlf = dna.translateCdna();
159 assertTrue("Translation failed (ipos=" + ipos
160 + ") No alignment data.", transAlf != null);
161 assertTrue("Translation failed (ipos=" + ipos + ") Empty alignment.",
162 transAlf.getHeight() > 0);
163 assertTrue("Translation failed (ipos=" + ipos + ") Translated "
164 + transAlf.getHeight() + " sequences from " + alf.getHeight()
165 + " sequences", alf.getHeight() == transAlf.getHeight());
170 * Test simple translation to Amino Acids (with STOP codons translated to *).
172 * @throws IOException
174 @Test(groups = { "Functional" })
175 public void testTranslateCdna_simple() throws IOException
177 AlignmentI alf = new FormatAdapter().readFile(fasta,
178 FormatAdapter.PASTE, "FASTA");
179 ColumnSelection cs = new ColumnSelection();
180 AlignViewportI av = new AlignViewport(alf, cs);
181 Dna dna = new Dna(av, new int[] { 0, alf.getWidth() - 1 });
182 AlignmentI translated = dna.translateCdna();
183 String aa = translated.getSequenceAt(0).getSequenceAsString();
185 "AAAACCDDEEFFGGGGHHIIIKKLLLLLLMNNPPPPQQRRRRRRSSSSSSTTTTVVVVWYY***",
190 * Test translation excluding hidden columns.
192 * @throws IOException
194 @Test(groups = { "Functional" })
195 public void testTranslateCdna_hiddenColumns() throws IOException
197 AlignmentI alf = new FormatAdapter().readFile(fasta,
198 FormatAdapter.PASTE, "FASTA");
199 ColumnSelection cs = new jalview.datamodel.ColumnSelection();
200 cs.hideColumns(6, 14); // hide codons 3/4/5
201 cs.hideColumns(24, 35); // hide codons 9-12
202 cs.hideColumns(177, 191); // hide codons 60-64
203 AlignViewportI av = new AlignViewport(alf, cs);
204 Dna dna = new Dna(av, new int[] { 0, alf.getWidth() - 1 });
205 AlignmentI translated = dna.translateCdna();
206 String aa = translated.getSequenceAt(0).getSequenceAsString();
207 assertEquals("AACDDGGGGHHIIIKKLLLLLLMNNPPPPQQRRRRRRSSSSSSTTTTVVVVW", aa);
211 * Use this test to help debug into any cases of interest.
213 @Test(groups = { "Functional" })
214 public void testCompareCodonPos_oneOnly()
216 assertFollows("-AA--A", "G--GG"); // 2 shifted seq2, 3 shifted seq1
220 * Tests for method that compares 'alignment' of two codon position triplets.
222 @Test(groups = { "Functional" })
223 public void testCompareCodonPos()
226 * Returns 0 for any null argument
228 assertEquals(0, Dna.compareCodonPos(new AlignedCodon(1, 2, 3), null));
229 assertEquals(0, Dna.compareCodonPos(null, new AlignedCodon(1, 2, 3)));
232 * Work through 27 combinations. First 9 cases where first position matches.
234 assertMatches("AAA", "GGG"); // 2 and 3 match
235 assertFollows("AA-A", "GGG"); // 2 matches, 3 shifted seq1
236 assertPrecedes("AAA", "GG-G"); // 2 matches, 3 shifted seq2
237 assertFollows("A-AA", "GG-G"); // 2 shifted seq1, 3 matches
238 assertFollows("A-A-A", "GG-G"); // 2 shifted seq1, 3 shifted seq1
239 assertPrecedes("A-AA", "GG--G"); // 2 shifted seq1, 3 shifted seq2
240 assertPrecedes("AA-A", "G-GG"); // 2 shifted seq2, 3 matches
241 assertFollows("AA--A", "G-GG"); // 2 shifted seq2, 3 shifted seq1
242 assertPrecedes("AAA", "G-GG"); // 2 shifted seq2, 3 shifted seq2
245 * 9 cases where first position is shifted in first sequence.
247 assertFollows("-AAA", "G-GG"); // 2 and 3 match
248 assertFollows("-AA-A", "G-GG"); // 2 matches, 3 shifted seq1
249 // 'enclosing' case: pick first to start precedes
250 assertFollows("-AAA", "G-G-G"); // 2 matches, 3 shifted seq2
251 assertFollows("-A-AA", "G-G-G"); // 2 shifted seq1, 3 matches
252 assertFollows("-A-A-A", "G-G-G"); // 2 shifted seq1, 3 shifted seq1
253 // 'enclosing' case: pick first to start precedes
254 assertFollows("-A-AA", "G-G--G"); // 2 shifted seq1, 3 shifted seq2
255 assertFollows("-AA-A", "G--GG"); // 2 shifted seq2, 3 matches
256 assertFollows("-AA--A", "G--GG"); // 2 shifted seq2, 3 shifted seq1
257 assertPrecedes("-AAA", "G--GG"); // 2 shifted seq2, 3 shifted seq2
260 * 9 cases where first position is shifted in second sequence.
262 assertPrecedes("A-AA", "-GGG"); // 2 and 3 match
263 assertPrecedes("A-A-A", "-GGG"); // 2 matches, 3 shifted seq1
264 assertPrecedes("A-AA", "-GG-G"); // 2 matches, 3 shifted seq2
265 assertPrecedes("A--AA", "-GG-G"); // 2 shifted seq1, 3 matches
266 // 'enclosing' case with middle base deciding:
267 assertFollows("A--AA", "-GGG"); // 2 shifted seq1, 3 shifted seq1
268 assertPrecedes("A--AA", "-GG--G"); // 2 shifted seq1, 3 shifted seq2
269 assertPrecedes("AA-A", "-GGG"); // 2 shifted seq2, 3 matches
270 assertPrecedes("AA--A", "-GGG"); // 2 shifted seq2, 3 shifted seq1
271 assertPrecedes("AAA", "-GGG"); // 2 shifted seq2, 3 shifted seq2
275 * This test generates a random cDNA alignment and its translation, then
276 * reorders the cDNA and retranslates, and verifies that the translations are
277 * the same (apart from ordering).
279 @Test(groups = { "Functional" })
280 public void testTranslateCdna_sequenceOrderIndependent()
283 * Generate cDNA - 8 sequences of 12 bases each.
285 AlignmentI cdna = new DnaAlignmentGenerator().generate(12, 8, 97, 5, 5);
286 ColumnSelection cs = new ColumnSelection();
287 AlignViewportI av = new AlignViewport(cdna, cs);
288 Dna dna = new Dna(av, new int[] { 0, cdna.getWidth() - 1 });
289 AlignmentI translated = dna.translateCdna();
292 * Jumble the cDNA sequences and translate.
294 SequenceI[] sorted = new SequenceI[cdna.getHeight()];
295 final int[] jumbler = new int[] { 6, 7, 3, 4, 2, 0, 1, 5 };
297 for (int i : jumbler)
299 sorted[seqNo++] = cdna.getSequenceAt(i);
301 AlignmentI cdnaReordered = new Alignment(sorted);
302 av = new AlignViewport(cdnaReordered, cs);
303 dna = new Dna(av, new int[] { 0, cdna.getWidth() - 1 });
304 AlignmentI translated2 = dna.translateCdna();
307 * Check translated sequences are the same in both alignments.
309 System.out.println("Original");
310 System.out.println(translated.toString());
311 System.out.println("Sorted");
312 System.out.println(translated2.toString());
314 int sortedSequenceIndex = 0;
315 for (int originalSequenceIndex : jumbler)
317 final String translation1 = translated.getSequenceAt(
318 originalSequenceIndex).getSequenceAsString();
319 final String translation2 = translated2.getSequenceAt(
320 sortedSequenceIndex).getSequenceAsString();
321 assertEquals(translation2, translation1);
322 sortedSequenceIndex++;
327 * Test that all the cases in testCompareCodonPos have a 'symmetric'
328 * comparison (without checking the actual comparison result).
330 @Test(groups = { "Functional" })
331 public void testCompareCodonPos_isSymmetric()
333 assertSymmetric("AAA", "GGG");
334 assertSymmetric("AA-A", "GGG");
335 assertSymmetric("AAA", "GG-G");
336 assertSymmetric("A-AA", "GG-G");
337 assertSymmetric("A-A-A", "GG-G");
338 assertSymmetric("A-AA", "GG--G");
339 assertSymmetric("AA-A", "G-GG");
340 assertSymmetric("AA--A", "G-GG");
341 assertSymmetric("AAA", "G-GG");
342 assertSymmetric("-AAA", "G-GG");
343 assertSymmetric("-AA-A", "G-GG");
344 assertSymmetric("-AAA", "G-G-G");
345 assertSymmetric("-A-AA", "G-G-G");
346 assertSymmetric("-A-A-A", "G-G-G");
347 assertSymmetric("-A-AA", "G-G--G");
348 assertSymmetric("-AA-A", "G--GG");
349 assertSymmetric("-AA--A", "G--GG");
350 assertSymmetric("-AAA", "G--GG");
351 assertSymmetric("A-AA", "-GGG");
352 assertSymmetric("A-A-A", "-GGG");
353 assertSymmetric("A-AA", "-GG-G");
354 assertSymmetric("A--AA", "-GG-G");
355 assertSymmetric("A--AA", "-GGG");
356 assertSymmetric("A--AA", "-GG--G");
357 assertSymmetric("AA-A", "-GGG");
358 assertSymmetric("AA--A", "-GGG");
359 assertSymmetric("AAA", "-GGG");
362 private void assertSymmetric(String codon1, String codon2)
364 assertEquals("Comparison of '" + codon1 + "' and '" + codon2
365 + " not symmetric", Integer.signum(compare(codon1, codon2)),
366 -Integer.signum(compare(codon2, codon1)));
370 * Assert that the first sequence should map to the same position as the
371 * second in a translated alignment. Also checks that this is true if the
372 * order of the codons is reversed.
377 private void assertMatches(String codon1, String codon2)
379 assertEquals("Expected '" + codon1 + "' matches '" + codon2 + "'", 0,
380 compare(codon1, codon2));
381 assertEquals("Expected '" + codon2 + "' matches '" + codon1 + "'", 0,
382 compare(codon2, codon1));
386 * Assert that the first sequence should precede the second in a translated
392 private void assertPrecedes(String codon1, String codon2)
394 assertEquals("Expected '" + codon1 + "' precedes '" + codon2 + "'",
395 -1, compare(codon1, codon2));
399 * Assert that the first sequence should follow the second in a translated
405 private void assertFollows(String codon1, String codon2)
407 assertEquals("Expected '" + codon1 + "' follows '" + codon2 + "'", 1,
408 compare(codon1, codon2));
412 * Convert two nucleotide strings to base positions and pass to
413 * Dna.compareCodonPos, return the result.
419 private int compare(String s1, String s2)
421 final AlignedCodon cd1 = convertCodon(s1);
422 final AlignedCodon cd2 = convertCodon(s2);
423 System.out.println("K: " + s1 + " " + cd1.toString());
424 System.out.println("G: " + s2 + " " + cd2.toString());
425 System.out.println();
426 return Dna.compareCodonPos(cd1, cd2);
430 * Convert a string e.g. "-GC-T" to base positions e.g. [1, 2, 4]. The string
431 * should have exactly 3 non-gap characters, and use '-' for gaps.
436 private AlignedCodon convertCodon(String s)
438 int[] codon = new int[3];
440 for (int j = 0; j < s.length(); j++)
442 if (s.charAt(j) != '-')
447 return new AlignedCodon(codon[0], codon[1], codon[2]);
451 * Weirdly, maybe worth a test to prove the helper method of this test class.
453 @Test(groups = { "Functional" })
454 public void testConvertCodon()
456 assertEquals("[0, 1, 2]", convertCodon("AAA").toString());
457 assertEquals("[0, 2, 5]", convertCodon("A-A--A").toString());
458 assertEquals("[1, 3, 4]", convertCodon("-A-AA-").toString());
462 * Test dna complementing
464 @Test(groups = "Functional")
465 public void testGetComplement()
467 assertEquals('t', Dna.getComplement('a'));
468 assertEquals('T', Dna.getComplement('A'));
469 assertEquals('a', Dna.getComplement('t'));
470 assertEquals('A', Dna.getComplement('T'));
471 assertEquals('c', Dna.getComplement('g'));
472 assertEquals('C', Dna.getComplement('G'));
473 assertEquals('g', Dna.getComplement('c'));
474 assertEquals('G', Dna.getComplement('C'));
475 // note uU --> aA but not vice versa
476 assertEquals('a', Dna.getComplement('u'));
477 assertEquals('A', Dna.getComplement('U'));
478 // ambiguity codes, see http://www.bioinformatics.org/sms/iupac.html
479 assertEquals('r', Dna.getComplement('y'));
480 assertEquals('R', Dna.getComplement('Y'));
481 assertEquals('y', Dna.getComplement('r'));
482 assertEquals('Y', Dna.getComplement('R'));
483 assertEquals('k', Dna.getComplement('m'));
484 assertEquals('K', Dna.getComplement('M'));
485 assertEquals('m', Dna.getComplement('k'));
486 assertEquals('M', Dna.getComplement('K'));
487 assertEquals('b', Dna.getComplement('v'));
488 assertEquals('B', Dna.getComplement('V'));
489 assertEquals('v', Dna.getComplement('b'));
490 assertEquals('V', Dna.getComplement('B'));
491 assertEquals('d', Dna.getComplement('h'));
492 assertEquals('D', Dna.getComplement('H'));
493 assertEquals('h', Dna.getComplement('d'));
494 assertEquals('H', Dna.getComplement('D'));
495 assertEquals('Q', Dna.getComplement('Q'));
498 @Test(groups = "Functional")
499 public void testReverseSequence()
501 String seq = "AcGtUrYkMbVdHNX";
504 SequenceI reversed = Dna.reverseSequence("Seq1", seq, false);
505 assertEquals(new StringBuilder(seq).reverse()
506 .toString(), reversed.getSequenceAsString());
507 assertEquals("Seq1|rev", reversed.getName());
509 // reverse complement:
510 SequenceI revcomp = Dna.reverseSequence("Seq1", seq, true);
511 assertEquals("XNDhBvKmRyAaCgT", revcomp.getSequenceAsString());
512 assertEquals("Seq1|revcomp", revcomp.getName());