2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
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 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
17 * The Jalview Authors are detailed in the 'AUTHORS' file.
19 package jalview.schemes;
21 import static org.junit.Assert.*;
23 import jalview.datamodel.AlignmentI;
24 import jalview.datamodel.ColumnSelection;
25 import jalview.datamodel.Sequence;
26 import jalview.datamodel.SequenceI;
28 import java.io.IOException;
30 import java.util.Vector;
32 import org.junit.AfterClass;
33 import org.junit.BeforeClass;
34 import org.junit.Test;
36 public class DnaCodonTests
40 public void testAmbiguityCodeGeneration()
42 assertTrue(ResidueProperties.ambiguityCodes.size()>0);
45 public void testAmbiguityCodon() {
46 for (String ac:ResidueProperties.ambiguityCodes.keySet())
48 assertTrue("Couldn't resolve GGN as glycine codon",ResidueProperties.codonHash2.get("GG"+ac).equals("G"));
52 public void regenerateCodonTable() {
53 for (Map.Entry<String, String> codon:ResidueProperties.codonHash2.entrySet())
55 System.out.println("ResidueProperties.codonHash2.set(\""+codon.getKey()+"\", \""+codon.getValue()+"\");");
59 public void checkOldCodonagainstNewCodonTable() {
60 // note - this test will be removed once the old codon table (including Vectors) is removed
61 String additional="",failtrans="",differentTr="";
62 for (Object aa:ResidueProperties.codonHash.keySet())
64 String amacid=(String) aa;
65 for (Object codons:((Vector)ResidueProperties.codonHash.get(amacid)))
67 String codon = (String) codons;
68 String trans = ResidueProperties.codonTranslate(codon);
69 String oldtrans = ResidueProperties._codonTranslate(codon);
71 additional+="\nOld translation table includes additional codons for "+amacid+" : "+codon;
74 failtrans+=("\nold translation routine failed for old translation entry (aa was "+amacid+" codon was "+codon+")");
76 if (!oldtrans.equals(trans))
78 differentTr+=("\nDifferent translation for old and new routines: "+amacid+" "+codon+" => expected "+oldtrans+" and got "+trans);
82 assertTrue(""+additional+"\n"+failtrans+"\n"+differentTr,additional.length()==0 && failtrans.length()==0 && differentTr.length()==0);