X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fschemes%2FClustalxColourSchemeTest.java;h=6731465dbdad4d02b04ef355337f883cb90d641c;hb=e9a1c2c372f4bbf6cf658de3dba73ef326b20c20;hp=16317d94acbdcb7a74fbfb26b0ac3382d9c5a831;hpb=db371136969ed3f5b7a6b08b431e53fc752f30e7;p=jalview.git diff --git a/test/jalview/schemes/ClustalxColourSchemeTest.java b/test/jalview/schemes/ClustalxColourSchemeTest.java index 16317d9..6731465 100644 --- a/test/jalview/schemes/ClustalxColourSchemeTest.java +++ b/test/jalview/schemes/ClustalxColourSchemeTest.java @@ -1,3 +1,23 @@ +/* + * 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.testng.Assert.assertEquals; @@ -27,13 +47,13 @@ public class ClustalxColourSchemeTest ">seq0\nKKKWWWQW\n"; // @formatter:on - @Test + @Test(groups = "Functional") public void testFindColour() { 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 +105,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); + } }