X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fschemes%2FResiduePropertiesTest.java;fp=test%2Fjalview%2Fschemes%2FResiduePropertiesTest.java;h=7fbad50bc9909d9fc1fcb2cfa1b5c9e80deca372;hb=2595e9d4ee0dbbd3406a98c4e49a61ccde806479;hp=b68ca6898ddc84879f7f20cd8c6c5f4c05589139;hpb=e20075ba805d744d7cc4976e2b8d5e5840fb0a8d;p=jalview.git diff --git a/test/jalview/schemes/ResiduePropertiesTest.java b/test/jalview/schemes/ResiduePropertiesTest.java index b68ca68..7fbad50 100644 --- a/test/jalview/schemes/ResiduePropertiesTest.java +++ b/test/jalview/schemes/ResiduePropertiesTest.java @@ -23,14 +23,25 @@ package jalview.schemes; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertNull; +import jalview.gui.JvOptionPane; + import java.util.Collections; import java.util.List; +import java.util.Map; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; public class ResiduePropertiesTest { + @BeforeClass(alwaysRun = true) + public void setUpJvOptionPane() + { + JvOptionPane.setInteractiveMode(false); + JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); + } + /** * Test 'standard' codon translations (no ambiguity codes) */ @@ -1556,4 +1567,62 @@ public class ResiduePropertiesTest assertEquals('Q', ResidueProperties.getSingleCharacterCode("Gln")); assertEquals('Q', ResidueProperties.getSingleCharacterCode("gln")); } + + @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()); + } + } + } + } }