1 package jalview.schemes;
3 import static org.testng.Assert.assertEquals;
5 import jalview.datamodel.AlignmentI;
6 import jalview.gui.AlignFrame;
7 import jalview.io.DataSourceType;
8 import jalview.io.FileLoader;
10 import java.awt.Color;
12 import org.testng.annotations.Test;
14 public class ClustalxColourSchemeTest
17 private static final String FASTA =
30 @Test(groups = "Functional")
31 public void testFindColour()
33 AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(FASTA,
34 DataSourceType.PASTE);
35 AlignmentI al = af.getViewport().getAlignment();
36 ColourSchemeI cs = new ClustalxColourScheme(al, null);
39 * column 1 is 70% A which is above Clustalx threshold of 60%
41 Color clustalBlue = new Color(0.5f, 0.7f, 0.9f);
42 assertEquals(cs.findColour('A', 0, al.getSequenceAt(0)), clustalBlue);
45 * column 2 is 70% A or V which is above Clustalx threshold for group
47 assertEquals(cs.findColour('A', 0, al.getSequenceAt(1)), clustalBlue);
50 * column 3 is 60% A which is not above Clustalx threshold
51 * the Ks in the other rows are not in the same Clustalx group
53 assertEquals(cs.findColour('A', 2, al.getSequenceAt(1)), Color.white);
56 * column 4 is 60% N which is above Clustalx threshold of 50%
58 Color clustalGreen = new Color(0.1f, 0.8f, 0.1f);
59 assertEquals(cs.findColour('N', 3, al.getSequenceAt(1)), clustalGreen);
62 * column 5 is 40% N and 40% Y which fails to pass the threshold of
65 assertEquals(cs.findColour('N', 4, al.getSequenceAt(1)), Color.white);
68 * column 6 is 40% N and 50% Y which fails to pass the threshold of
71 assertEquals(cs.findColour('N', 5, al.getSequenceAt(1)), Color.white);
74 * column 7 is 40% R and 30% K which combine to make > 60%
76 Color clustalRed = new Color(0.9f, 0.2f, 0.1f);
77 assertEquals(cs.findColour('R', 6, al.getSequenceAt(1)), clustalRed);
78 assertEquals(cs.findColour('K', 6, al.getSequenceAt(7)), clustalRed);
81 * column 8 is >85% Q which qualifies K and R to be red
83 assertEquals(cs.findColour('R', 7, al.getSequenceAt(1)), clustalRed);
84 assertEquals(cs.findColour('K', 7, al.getSequenceAt(1)), clustalRed);
86 // TODO more test cases; check if help documentation matches implementation