--- /dev/null
+package jalview.schemes;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Test;
+
+public class ResiduePropertiesTest
+{
+
+ /**
+ * Test 'standard' codon translations (no ambiguity codes)
+ */
+ @Test
+ public void testCodonTranslate()
+ {
+ // standard translation table order column 1/2/3/4
+ assertEquals("F", ResidueProperties.codonTranslate("TTT"));
+ assertEquals("F", ResidueProperties.codonTranslate("TTC"));
+ assertEquals("L", ResidueProperties.codonTranslate("TTA"));
+ assertEquals("L", ResidueProperties.codonTranslate("TTG"));
+ assertEquals("L", ResidueProperties.codonTranslate("CTT"));
+ assertEquals("L", ResidueProperties.codonTranslate("CTC"));
+ assertEquals("L", ResidueProperties.codonTranslate("CTA"));
+ assertEquals("L", ResidueProperties.codonTranslate("CTG"));
+ assertEquals("I", ResidueProperties.codonTranslate("ATT"));
+ assertEquals("I", ResidueProperties.codonTranslate("ATC"));
+ assertEquals("I", ResidueProperties.codonTranslate("ATA"));
+ assertEquals("M", ResidueProperties.codonTranslate("ATG"));
+ assertEquals("V", ResidueProperties.codonTranslate("GTT"));
+ assertEquals("V", ResidueProperties.codonTranslate("GTC"));
+ assertEquals("V", ResidueProperties.codonTranslate("GTA"));
+ assertEquals("V", ResidueProperties.codonTranslate("GTG"));
+ assertEquals("S", ResidueProperties.codonTranslate("TCT"));
+ assertEquals("S", ResidueProperties.codonTranslate("TCC"));
+ assertEquals("S", ResidueProperties.codonTranslate("TCA"));
+ assertEquals("S", ResidueProperties.codonTranslate("TCG"));
+ assertEquals("P", ResidueProperties.codonTranslate("CCT"));
+ assertEquals("P", ResidueProperties.codonTranslate("CCC"));
+ assertEquals("P", ResidueProperties.codonTranslate("CCA"));
+ assertEquals("P", ResidueProperties.codonTranslate("CCG"));
+ assertEquals("T", ResidueProperties.codonTranslate("ACT"));
+ assertEquals("T", ResidueProperties.codonTranslate("ACC"));
+ assertEquals("T", ResidueProperties.codonTranslate("ACA"));
+ assertEquals("T", ResidueProperties.codonTranslate("ACG"));
+ assertEquals("A", ResidueProperties.codonTranslate("GCT"));
+ assertEquals("A", ResidueProperties.codonTranslate("GCC"));
+ assertEquals("A", ResidueProperties.codonTranslate("GCA"));
+ assertEquals("A", ResidueProperties.codonTranslate("GCG"));
+ assertEquals("Y", ResidueProperties.codonTranslate("TAT"));
+ assertEquals("Y", ResidueProperties.codonTranslate("TAC"));
+ assertEquals("STOP", ResidueProperties.codonTranslate("TAA"));
+ assertEquals("STOP", ResidueProperties.codonTranslate("TAG"));
+ assertEquals("H", ResidueProperties.codonTranslate("CAT"));
+ assertEquals("H", ResidueProperties.codonTranslate("CAC"));
+ assertEquals("Q", ResidueProperties.codonTranslate("CAA"));
+ assertEquals("Q", ResidueProperties.codonTranslate("CAG"));
+ assertEquals("N", ResidueProperties.codonTranslate("AAT"));
+ assertEquals("N", ResidueProperties.codonTranslate("AAC"));
+ assertEquals("K", ResidueProperties.codonTranslate("AAA"));
+ assertEquals("K", ResidueProperties.codonTranslate("AAG"));
+ assertEquals("D", ResidueProperties.codonTranslate("GAT"));
+ assertEquals("D", ResidueProperties.codonTranslate("GAC"));
+ assertEquals("E", ResidueProperties.codonTranslate("GAA"));
+ assertEquals("E", ResidueProperties.codonTranslate("GAG"));
+ assertEquals("C", ResidueProperties.codonTranslate("TGT"));
+ assertEquals("C", ResidueProperties.codonTranslate("TGC"));
+ assertEquals("STOP", ResidueProperties.codonTranslate("TGA"));
+ assertEquals("W", ResidueProperties.codonTranslate("TGG"));
+ assertEquals("R", ResidueProperties.codonTranslate("CGT"));
+ assertEquals("R", ResidueProperties.codonTranslate("CGC"));
+ assertEquals("R", ResidueProperties.codonTranslate("CGA"));
+ assertEquals("R", ResidueProperties.codonTranslate("CGG"));
+ assertEquals("S", ResidueProperties.codonTranslate("AGT"));
+ assertEquals("S", ResidueProperties.codonTranslate("AGC"));
+ assertEquals("R", ResidueProperties.codonTranslate("AGA"));
+ assertEquals("R", ResidueProperties.codonTranslate("AGG"));
+ assertEquals("G", ResidueProperties.codonTranslate("GGT"));
+ assertEquals("G", ResidueProperties.codonTranslate("GGC"));
+ assertEquals("G", ResidueProperties.codonTranslate("GGA"));
+ assertEquals("G", ResidueProperties.codonTranslate("GGG"));
+ }
+
+ /**
+ * Test a sample of codon translations involving ambiguity codes. Should
+ * return a protein value where the ambiguity does not affect the translation.
+ */
+ @Test
+ public void testCodonTranslate_ambiguityCodes()
+ {
+ // Y is C or T
+ assertEquals("C", ResidueProperties.codonTranslate("TGY"));
+ assertEquals("L", ResidueProperties.codonTranslate("YTA"));
+
+ // W is A or T
+ assertEquals("L", ResidueProperties.codonTranslate("CTW"));
+ assertNull(ResidueProperties.codonTranslate("TTW"));
+
+ // S is G or C
+ assertEquals("G", ResidueProperties.codonTranslate("GGS"));
+ assertNull(ResidueProperties.codonTranslate("ATS"));
+
+ // K is T or G
+ assertEquals("S", ResidueProperties.codonTranslate("TCS"));
+ assertNull(ResidueProperties.codonTranslate("ATK"));
+
+ // M is C or A
+ assertEquals("T", ResidueProperties.codonTranslate("ACM"));
+ assertNull(ResidueProperties.codonTranslate("TAM"));
+
+ // D is A, G or T
+ assertEquals("P", ResidueProperties.codonTranslate("CCD"));
+ assertNull(ResidueProperties.codonTranslate("AAD"));
+
+ // V is A, C or G
+ assertEquals("V", ResidueProperties.codonTranslate("GTV"));
+ assertNull(ResidueProperties.codonTranslate("TTV"));
+
+ // H is A, C or T
+ assertEquals("A", ResidueProperties.codonTranslate("GCH"));
+ assertEquals("I", ResidueProperties.codonTranslate("ATH"));
+ assertNull(ResidueProperties.codonTranslate("AGH"));
+
+ // B is C, G or T
+ assertEquals("P", ResidueProperties.codonTranslate("CCB"));
+ assertNull(ResidueProperties.codonTranslate("TAB"));
+
+ // R is A or G
+ assertEquals("R", ResidueProperties.codonTranslate("AGR"));
+ assertEquals("STOP", ResidueProperties.codonTranslate("TAR"));
+ assertEquals("STOP", ResidueProperties.codonTranslate("TRA"));
+ assertNull(ResidueProperties.codonTranslate("ATR"));
+
+ }
+}