X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=test%2Fjalview%2Fschemes%2FResiduePropertiesTest.java;h=4dff315b5b9495b69d3fbb2f1f759470103f27f7;hb=5cd32d19826b02d519fd79b7cd26c68bb981c378;hp=b976e4457c3ed276175bfbcd20de5ba843b1465a;hpb=be32c14cd8e48fe0a207cd7030cb9cd46f894678;p=jalview.git diff --git a/test/jalview/schemes/ResiduePropertiesTest.java b/test/jalview/schemes/ResiduePropertiesTest.java index b976e44..4dff315 100644 --- a/test/jalview/schemes/ResiduePropertiesTest.java +++ b/test/jalview/schemes/ResiduePropertiesTest.java @@ -1,9 +1,32 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ package jalview.schemes; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNull; -import org.junit.Test; +import java.util.Collections; +import java.util.List; + +import org.testng.annotations.Test; public class ResiduePropertiesTest { @@ -11,7 +34,7 @@ public class ResiduePropertiesTest /** * Test 'standard' codon translations (no ambiguity codes) */ - @Test + @Test(groups = { "Functional" }) public void testCodonTranslate() { // standard translation table order column 1/2/3/4 @@ -85,7 +108,7 @@ public class ResiduePropertiesTest * Test a sample of codon translations involving ambiguity codes. Should * return a protein value where the ambiguity does not affect the translation. */ - @Test + @Test(groups = { "Functional" }) public void testCodonTranslate_ambiguityCodes() { // Y is C or T @@ -171,4 +194,65 @@ public class ResiduePropertiesTest assertNull(ResidueProperties.codonTranslate("VHD")); assertNull(ResidueProperties.codonTranslate("WSK")); } + + @Test(groups = { "Functional" }) + public void testGetResidues_nucleotide() + { + /* + * Non-ambiguous only; we don't care about the order of the list, it is just + * sorted here to make assertions reliable + */ + List residues = ResidueProperties.getResidues(true, false); + Collections.sort(residues); + assertEquals("[A, C, G, T, U]", residues.toString()); + + /* + * Including ambiguity codes I N R X Y + */ + residues = ResidueProperties.getResidues(true, true); + Collections.sort(residues); + assertEquals("[A, C, G, I, N, R, T, U, X, Y]", residues.toString()); + } + + @Test(groups = { "Functional" }) + public void testGetResidues_peptide() + { + /* + * Non-ambiguous only; we don't care about the order of the list, it is just + * sorted here to make assertions reliable + */ + List residues = ResidueProperties.getResidues(false, false); + Collections.sort(residues); + assertEquals( + "[ALA, ARG, ASN, ASP, CYS, GLN, GLU, GLY, HIS, ILE, LEU, LYS, MET, PHE, PRO, SER, THR, TRP, TYR, VAL]", + residues.toString()); + + /* + * Including ambiguity codes ASX, GLX, XAA + */ + residues = ResidueProperties.getResidues(false, true); + Collections.sort(residues); + assertEquals( + "[ALA, ARG, ASN, ASP, ASX, CYS, GLN, GLU, GLX, GLY, HIS, ILE, LEU, LYS, MET, PHE, PRO, SER, THR, TRP, TYR, VAL, XAA]", + residues.toString()); + } + + @Test(groups = { "Functional" }) + public void testGetCanonicalAminoAcid() + { + assertEquals("MET", ResidueProperties.getCanonicalAminoAcid("MET")); + assertEquals("MET", ResidueProperties.getCanonicalAminoAcid("MSE")); + assertEquals(null, ResidueProperties.getCanonicalAminoAcid(null)); + } + + @Test(groups = { "Functional" }) + public void testGetSingleCharacterCode() + { + assertEquals('0', ResidueProperties.getSingleCharacterCode(null)); + assertEquals('0', ResidueProperties.getSingleCharacterCode(null)); + assertEquals('0', ResidueProperties.getSingleCharacterCode("")); + assertEquals('Q', ResidueProperties.getSingleCharacterCode("GLN")); + assertEquals('Q', ResidueProperties.getSingleCharacterCode("Gln")); + assertEquals('Q', ResidueProperties.getSingleCharacterCode("gln")); + } }