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);
47 public void testAmbiguityCodon() {
48 for (String ac:ResidueProperties.ambiguityCodes.keySet())
50 assertTrue("Couldn't resolve GGN as glycine codon",ResidueProperties.codonHash2.get("GG"+ac).equals("G"));
54 public void regenerateCodonTable() {
55 for (Map.Entry<String, String> codon:ResidueProperties.codonHash2.entrySet())
57 System.out.println("ResidueProperties.codonHash2.set(\""+codon.getKey()+"\", \""+codon.getValue()+"\");");
61 public void checkOldCodonagainstNewCodonTable() {
62 // note - this test will be removed once the old codon table (including Vectors) is removed
63 String additional="",failtrans="",differentTr="";
64 for (Object aa:ResidueProperties.codonHash.keySet())
66 String amacid=(String) aa;
67 for (Object codons:((Vector)ResidueProperties.codonHash.get(amacid)))
69 String codon = (String) codons;
70 String trans = ResidueProperties.codonTranslate(codon);
71 String oldtrans = ResidueProperties._codonTranslate(codon);
73 additional+="\nOld translation table includes additional codons for "+amacid+" : "+codon;
76 failtrans+=("\nold translation routine failed for old translation entry (aa was "+amacid+" codon was "+codon+")");
78 if (!oldtrans.equals(trans))
80 differentTr+=("\nDifferent translation for old and new routines: "+amacid+" "+codon+" => expected "+oldtrans+" and got "+trans);
84 assertTrue(""+additional+"\n"+failtrans+"\n"+differentTr,additional.length()==0 && failtrans.length()==0 && differentTr.length()==0);