X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fschemes%2FResidueColourSchemeTest.java;h=b45e0d352fe0b80eb090ebae16cf2167f4cd7cb8;hb=a17d89e1193d22cb05cd0f7605c7dc14564ede28;hp=809dce32c53668ea6d94b918332216e283acc882;hpb=b0cee3aaf7d8873910939f97b6acb217d518968d;p=jalview.git diff --git a/test/jalview/schemes/ResidueColourSchemeTest.java b/test/jalview/schemes/ResidueColourSchemeTest.java index 809dce3..b45e0d3 100644 --- a/test/jalview/schemes/ResidueColourSchemeTest.java +++ b/test/jalview/schemes/ResidueColourSchemeTest.java @@ -29,21 +29,21 @@ import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.AnnotatedCollectionI; import jalview.datamodel.Annotation; -import jalview.datamodel.Profile; -import jalview.datamodel.ProfileI; -import jalview.datamodel.Profiles; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceI; import jalview.gui.JvOptionPane; import jalview.io.TCoffeeScoreFile; -import java.awt.Color; - import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; public class ResidueColourSchemeTest { + @BeforeClass(alwaysRun = true) + public void setUp() + { + + } @BeforeClass(alwaysRun = true) public void setUpJvOptionPane() @@ -53,139 +53,6 @@ public class ResidueColourSchemeTest } @Test(groups = "Functional") - public void testAboveThreshold() - { - /* - * make up profiles for this alignment: - * AR-Q - * AR-- - * SR-T - * SR-T - */ - ProfileI[] profiles = new ProfileI[4]; - profiles[0] = new Profile(4, 0, 2, "AS"); - profiles[1] = new Profile(4, 0, 4, "R"); - profiles[2] = new Profile(4, 4, 0, ""); - profiles[3] = new Profile(4, 1, 2, "T"); - ResidueColourScheme rcs = new ResidueColourScheme(); - rcs.setConsensus(new Profiles(profiles)); - - /* - * no threshold - */ - rcs.setThreshold(0, true); - assertTrue(rcs.aboveThreshold('a', 0)); - assertTrue(rcs.aboveThreshold('S', 0)); - assertFalse(rcs.aboveThreshold('W', 0)); - assertTrue(rcs.aboveThreshold('R', 1)); - assertFalse(rcs.aboveThreshold('W', 2)); - assertTrue(rcs.aboveThreshold('t', 3)); - assertFalse(rcs.aboveThreshold('Q', 3)); - - /* - * with threshold, include gaps - */ - rcs.setThreshold(60, false); - assertFalse(rcs.aboveThreshold('a', 0)); - assertFalse(rcs.aboveThreshold('S', 0)); - assertTrue(rcs.aboveThreshold('R', 1)); - assertFalse(rcs.aboveThreshold('W', 2)); - assertFalse(rcs.aboveThreshold('t', 3)); // 50% < 60% - - /* - * with threshold, ignore gaps - */ - rcs.setThreshold(60, true); - assertFalse(rcs.aboveThreshold('a', 0)); - assertFalse(rcs.aboveThreshold('S', 0)); - assertTrue(rcs.aboveThreshold('R', 1)); - assertFalse(rcs.aboveThreshold('W', 2)); - assertTrue(rcs.aboveThreshold('t', 3)); // 67% > 60% - } - - /** - * Test colour bleaching based on conservation score and conservation slider. - * Scores of 10 or 11 should leave colours unchanged. Gap is always white. - */ - @Test(groups = "Functional") - public void testApplyConservation() - { - ResidueColourScheme rcs = new ResidueColourScheme(); - - // no conservation present - no fading - assertEquals(Color.RED, rcs.applyConservation(Color.RED, 12)); - - // cheat by setting conservation sequence directly - // rather than calculating it - good enough for this test - String consensus = "0123456789+*-"; - rcs.conservation = consensus.toCharArray(); - - // column out of range: - assertEquals(Color.RED, - rcs.applyConservation(Color.RED, consensus.length())); - - /* - * with 100% threshold, 'fade factor' is - * (11-score)/10 * 100/20 = (11-score)/2 - * which is >= 1 for all scores i.e. all fade to white except +, * - */ - rcs.setConservationInc(100); - assertEquals(Color.WHITE, rcs.applyConservation(Color.RED, 0)); - assertEquals(Color.WHITE, rcs.applyConservation(Color.RED, 1)); - assertEquals(Color.WHITE, rcs.applyConservation(Color.RED, 2)); - assertEquals(Color.WHITE, rcs.applyConservation(Color.RED, 3)); - assertEquals(Color.WHITE, rcs.applyConservation(Color.RED, 4)); - assertEquals(Color.WHITE, rcs.applyConservation(Color.RED, 5)); - assertEquals(Color.WHITE, rcs.applyConservation(Color.RED, 6)); - assertEquals(Color.WHITE, rcs.applyConservation(Color.RED, 7)); - assertEquals(Color.WHITE, rcs.applyConservation(Color.RED, 8)); - assertEquals(Color.WHITE, rcs.applyConservation(Color.RED, 9)); - assertEquals(Color.RED, rcs.applyConservation(Color.RED, 10)); - assertEquals(Color.RED, rcs.applyConservation(Color.RED, 11)); - assertEquals(Color.WHITE, rcs.applyConservation(Color.RED, 12)); - - /* - * with 0% threshold, there should be no fading - */ - rcs.setConservationInc(0); - assertEquals(Color.RED, rcs.applyConservation(Color.RED, 0)); - assertEquals(Color.RED, rcs.applyConservation(Color.RED, 1)); - assertEquals(Color.RED, rcs.applyConservation(Color.RED, 2)); - assertEquals(Color.RED, rcs.applyConservation(Color.RED, 3)); - assertEquals(Color.RED, rcs.applyConservation(Color.RED, 4)); - assertEquals(Color.RED, rcs.applyConservation(Color.RED, 5)); - assertEquals(Color.RED, rcs.applyConservation(Color.RED, 6)); - assertEquals(Color.RED, rcs.applyConservation(Color.RED, 7)); - assertEquals(Color.RED, rcs.applyConservation(Color.RED, 8)); - assertEquals(Color.RED, rcs.applyConservation(Color.RED, 9)); - assertEquals(Color.RED, rcs.applyConservation(Color.RED, 10)); - assertEquals(Color.RED, rcs.applyConservation(Color.RED, 11)); - assertEquals(Color.WHITE, rcs.applyConservation(Color.RED, 12)); // gap - - /* - * with 40% threshold, 'fade factor' is - * (11-score)/10 * 40/20 = (11-score)/5 - * which is {>1, >1, >1, >1, >1, >1, 1, 0.8, 0.6, 0.4} for score 0-9 - * e.g. score 7 colour fades 80% of the way to white (255, 255, 255) - */ - rcs.setConservationInc(40); - Color colour = new Color(155, 105, 55); - assertEquals(Color.WHITE, rcs.applyConservation(colour, 0)); - assertEquals(Color.WHITE, rcs.applyConservation(colour, 1)); - assertEquals(Color.WHITE, rcs.applyConservation(colour, 2)); - assertEquals(Color.WHITE, rcs.applyConservation(colour, 3)); - assertEquals(Color.WHITE, rcs.applyConservation(colour, 4)); - assertEquals(Color.WHITE, rcs.applyConservation(colour, 5)); - assertEquals(Color.WHITE, rcs.applyConservation(colour, 6)); - assertEquals(new Color(235, 225, 215), rcs.applyConservation(colour, 7)); - assertEquals(new Color(215, 195, 175), rcs.applyConservation(colour, 8)); - assertEquals(new Color(195, 165, 135), rcs.applyConservation(colour, 9)); - assertEquals(colour, rcs.applyConservation(colour, 10)); - assertEquals(colour, rcs.applyConservation(colour, 11)); - assertEquals(Color.WHITE, rcs.applyConservation(colour, 12)); - } - - @Test public void testIsApplicableTo() { SequenceI pep1 = new Sequence("pep1", "APQTWLS"); @@ -239,8 +106,9 @@ public class ResidueColourSchemeTest .isApplicableTo(peptide)); assertTrue(new ScoreColourScheme(new int[] {}, new double[] {}, 0, 0d) .isApplicableTo(nucleotide)); - assertTrue(new ResidueColourScheme().isApplicableTo(peptide)); - assertTrue(new ResidueColourScheme().isApplicableTo(nucleotide)); + ResidueColourScheme rcs = new PIDColourScheme(); + assertTrue(rcs.isApplicableTo(peptide)); + assertTrue(rcs.isApplicableTo(nucleotide)); assertTrue(new PIDColourScheme().isApplicableTo(peptide)); assertTrue(new PIDColourScheme().isApplicableTo(nucleotide)); assertTrue(new FollowerColourScheme().isApplicableTo(peptide)); @@ -275,7 +143,7 @@ public class ResidueColourSchemeTest assertTrue(new RNAHelicesColour(nucleotide).isApplicableTo(nucleotide)); } - @Test + @Test(groups = "Functional") public void testIsApplicableTo_dynamicColourScheme() { SequenceI pep1 = new Sequence("pep1", "APQTWLS"); @@ -301,7 +169,7 @@ public class ResidueColourSchemeTest assertTrue(cs.isApplicableTo(peptide)); } - @Test + @Test(groups = "Functional") public void testGetName() { SequenceI pep1 = new Sequence("pep1", "APQTWLS"); @@ -323,7 +191,6 @@ public class ResidueColourSchemeTest assertEquals("User Defined", new UserColourScheme().getSchemeName()); assertEquals("Score", new ScoreColourScheme(new int[] {}, new double[] {}, 0, 0d).getSchemeName()); - assertEquals("Residue", new ResidueColourScheme().getSchemeName()); assertEquals("% Identity", new PIDColourScheme().getSchemeName()); assertEquals("Follower", new FollowerColourScheme().getSchemeName()); assertEquals("T-Coffee Scores",