X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fschemes%2FClustalxColourSchemeTest.java;h=d35ca76ecdbfcbd3b81ffa73132440377919ef67;hb=e305cfe169bc0ba6ee04f78b7720ca985392f114;hp=fda7d27a4e211011b6450648b0795eea111e27d3;hpb=a09d6f5c16b0e222806e035cd38bfb4c4eb92c75;p=jalview.git diff --git a/test/jalview/schemes/ClustalxColourSchemeTest.java b/test/jalview/schemes/ClustalxColourSchemeTest.java index fda7d27..d35ca76 100644 --- a/test/jalview/schemes/ClustalxColourSchemeTest.java +++ b/test/jalview/schemes/ClustalxColourSchemeTest.java @@ -33,7 +33,7 @@ public class ClustalxColourSchemeTest AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(FASTA, DataSourceType.PASTE); AlignmentI al = af.getViewport().getAlignment(); - ColourSchemeI cs = new ClustalxColourScheme(al, null); + ClustalxColourScheme cs = new ClustalxColourScheme(al, null); /* * column 1 is 70% A which is above Clustalx threshold of 60% @@ -85,4 +85,50 @@ public class ClustalxColourSchemeTest // TODO more test cases; check if help documentation matches implementation } + + // @formatter:on + + /** + * Test for colour calculation when the consensus percentage ignores gapped + * sequences + */ + @Test(groups = "Functional") + public void testFindColour_ignoreGaps() + { + /* + * CCC + * CCC + * -CC + * first column is 66% C (blue) including gaps + * or 100% C ignoring gaps + */ + String fasta = ">seq1\nCCC\n>seq2\nccc\n>seq3\n-CC\n"; + AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(fasta, + DataSourceType.PASTE); + AlignmentI al = af.getViewport().getAlignment(); + ClustalxColourScheme cs = new ClustalxColourScheme(al, null); + + /* + * column 1 is 66% C which is above Clustalx threshold of 60% + */ + Color clustalBlue = ClustalxColourScheme.ClustalColour.BLUE.colour; + assertEquals(cs.findColour('C', 0, al.getSequenceAt(0)), clustalBlue); + + /* + * set directly to ignore gaps + */ + cs.setIncludeGaps(false); + Color clustalPink = ClustalxColourScheme.ClustalColour.PINK.colour; + assertEquals(cs.findColour('C', 0, al.getSequenceAt(0)), clustalPink); + + /* + * set ignore gaps on the viewport... + */ + cs.setIncludeGaps(true); + assertEquals(cs.findColour('C', 0, al.getSequenceAt(0)), clustalBlue); + af.getViewport().setIgnoreGapsConsensus(true, af.alignPanel); + // next test fails: colour scheme does not read ignore gaps flag from + // viewport + // assertEquals(cs.findColour('C', 0, al.getSequenceAt(0)), clustalPink); + } }