2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 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.schemes;
23 import static org.junit.Assert.*;
25 import jalview.datamodel.AlignmentI;
26 import jalview.datamodel.ColumnSelection;
27 import jalview.datamodel.Sequence;
28 import jalview.datamodel.SequenceI;
30 import java.io.IOException;
32 import java.util.Vector;
34 import org.junit.AfterClass;
35 import org.junit.BeforeClass;
36 import org.junit.Test;
38 public class DnaCodonTests
42 public void testAmbiguityCodeGeneration()
44 assertTrue(ResidueProperties.ambiguityCodes.size() > 0);
48 public void testAmbiguityCodon()
50 for (String ac : ResidueProperties.ambiguityCodes.keySet())
52 assertTrue("Couldn't resolve GGN as glycine codon",
53 ResidueProperties.codonHash2.get("GG" + ac).equals("G"));
58 public void regenerateCodonTable()
60 for (Map.Entry<String, String> codon : ResidueProperties.codonHash2
63 System.out.println("ResidueProperties.codonHash2.set(\""
64 + codon.getKey() + "\", \"" + codon.getValue() + "\");");
69 public void checkOldCodonagainstNewCodonTable()
71 // note - this test will be removed once the old codon table (including
72 // Vectors) is removed
73 String additional = "", failtrans = "", differentTr = "";
74 for (Object aa : ResidueProperties.codonHash.keySet())
76 String amacid = (String) aa;
77 for (Object codons : ((Vector) ResidueProperties.codonHash
80 String codon = (String) codons;
81 String trans = ResidueProperties.codonTranslate(codon);
82 String oldtrans = ResidueProperties._codonTranslate(codon);
85 additional += "\nOld translation table includes additional codons for "
86 + amacid + " : " + codon;
90 failtrans += ("\nold translation routine failed for old translation entry (aa was "
91 + amacid + " codon was " + codon + ")");
93 if (!oldtrans.equals(trans))
95 differentTr += ("\nDifferent translation for old and new routines: "
101 + " and got " + trans);
105 assertTrue("" + additional + "\n" + failtrans + "\n" + differentTr,
106 additional.length() == 0 && failtrans.length() == 0
107 && differentTr.length() == 0);