X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=test%2Fjalview%2Fschemes%2FResiduePropertiesTest.java;h=28f39d858012fbd9df809ec33b54494c53c07628;hb=HEAD;hp=b68ca6898ddc84879f7f20cd8c6c5f4c05589139;hpb=6dacd9d2805d0899a59329fdc4e43dfacdf93044;p=jalview.git diff --git a/test/jalview/schemes/ResiduePropertiesTest.java b/test/jalview/schemes/ResiduePropertiesTest.java index b68ca68..28f39d8 100644 --- a/test/jalview/schemes/ResiduePropertiesTest.java +++ b/test/jalview/schemes/ResiduePropertiesTest.java @@ -25,12 +25,23 @@ import static org.testng.AssertJUnit.assertNull; import java.util.Collections; import java.util.List; +import java.util.Map; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import jalview.gui.JvOptionPane; + public class ResiduePropertiesTest { + @BeforeClass(alwaysRun = true) + public void setUpJvOptionPane() + { + JvOptionPane.setInteractiveMode(false); + JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); + } + /** * Test 'standard' codon translations (no ambiguity codes) */ @@ -211,7 +222,8 @@ public class ResiduePropertiesTest */ residues = ResidueProperties.getResidues(true, true); Collections.sort(residues); - assertEquals("[A, C, G, I, N, R, T, U, X, Y]", residues.toString()); + assertEquals("[A, B, C, D, G, H, I, K, M, N, R, S, T, U, V, W, X, Y]", + residues.toString()); } @Test(groups = { "Functional" }) @@ -1556,4 +1568,72 @@ public class ResiduePropertiesTest assertEquals('Q', ResidueProperties.getSingleCharacterCode("Gln")); assertEquals('Q', ResidueProperties.getSingleCharacterCode("gln")); } + + @Test(groups = { "Functional" }) + public void testGetDssp3State() + { + assertNull(ResidueProperties.getDssp3state(null)); + assertEquals("", ResidueProperties.getDssp3state("")); + String foo = "0123 []<>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; + String bar = " E E HHH "; + assertEquals(bar, ResidueProperties.getDssp3state(foo)); + } + + @Test(groups = { "Functional" }) + public void testPhysicoChemicalProperties() + { + checkProperty("aromatic", "FYWH-*"); + checkProperty("aliphatic", "IVL-*"); + checkProperty("tiny", "GAS-*"); + checkProperty("small", "VCTGACSDNP-*"); + checkProperty("charged", "HKRDE-*"); + checkProperty("negative", "DE-*"); + checkProperty("polar", "YWHRKTSNDEQ-*X"); + checkProperty("positive", "HKR-*"); + checkProperty("proline", "P-*"); + checkProperty("hydrophobic", "MILVFYWHKTGAC-*X"); + } + + /** + * Verify that the residues in the list have the named property, and other + * residues do not + * + * @param property + * @param residues + */ + void checkProperty(String property, String residues) + { + Map props = ResidueProperties.propHash.get(property); + + /* + * assert residues have the property (value 1 in lookup) + */ + for (char res : residues.toCharArray()) + { + assertEquals(res + " should be " + property, 1, + props.get(String.valueOf(res)).intValue()); + } + + /* + * assert other residues do not (value 0 in lookup) + */ + for (String res : ResidueProperties.aa) + { + if (!residues.contains(res)) + { + Integer propValue = props.get(String.valueOf(res)); + + if (propValue != null) + { + /* + * conservation calculation assigns unexpected symbols + * the same value as '-'; here we just check those which + * explicitly do not have the property + */ + assertEquals(res + " should not be " + property, 0, + propValue.intValue()); + } + } + } + } }