1 package jalview.schemes;
3 import static org.testng.Assert.assertEquals;
5 import jalview.datamodel.Alignment;
6 import jalview.datamodel.AlignmentI;
7 import jalview.datamodel.SequenceI;
8 import jalview.io.DataSourceType;
9 import jalview.io.HMMFile;
11 import java.awt.Color;
12 import java.io.IOException;
13 import java.net.MalformedURLException;
15 import org.testng.annotations.Test;
17 public class HmmerGlobalBackgroundTest {
19 @Test(groups = "Functional")
20 public void testFindColour() throws MalformedURLException, IOException
22 HMMFile file = new HMMFile("test/jalview/io/test_PKinase_hmm.txt",
25 SequenceI hmmSeq = file.getSeqsAsArray()[0];
26 AlignmentI al = new Alignment(new SequenceI[] { hmmSeq });
27 ColourSchemeI scheme = new HmmerGlobalBackground(al);
30 * 'A' in column 1, node 2, match emission 2.77204
32 * background frequency is 0.0826
33 * ratio is 0.757, log is negative, colour is Orange
35 Color actual = scheme.findColour('A', 1, null, null, 0);
36 assertEquals(actual, Color.ORANGE);
39 actual = scheme.findColour('-', 2, null, null, 0);
40 assertEquals(actual, Color.WHITE);
41 actual = scheme.findColour(' ', 2, null, null, 0);
42 assertEquals(actual, Color.WHITE);
43 actual = scheme.findColour('.', 2, null, null, 0);
44 assertEquals(actual, Color.WHITE);
47 * 'Y' in column 4, node 5, match emission 4.41426
49 * background frequency is 0.0292
50 * ratio is 0.414, log is negative, colour is Orange
52 actual = scheme.findColour('Y', 4, null, null, 0);
53 assertEquals(actual, Color.ORANGE);
56 * 'M' in column 109, no matching node, colour is reddish
58 actual = scheme.findColour('M', 109, null, null, 0);
59 assertEquals(actual, new Color(230, 0, 0));
62 * 'I' in column 6, node 7, match emission 1.33015
64 * background frequency is 0.0593
65 * ratio is 4.459, log is 1.495
66 * colour is graduated 1.495/4.52 or 84/255 of the way from
67 * white(255, 255, 255) to blue(0, 0, 255)
69 actual = scheme.findColour('I', 6, null, null, 0);
70 assertEquals(actual, new Color(171, 171, 255));
73 * 'V' in column 14, node 15, match emission 0.44769
75 * background frequency is 0.0686
76 * ratio is 9.316, log is 2.232
77 * colour is graduated 2.232/4.52 or 126/255 of the way from
78 * white(255, 255, 255) to blue(0, 0, 255)
80 actual = scheme.findColour('V', 14, null, null, 0);
81 assertEquals(actual, new Color(129, 129, 255));
84 * invalid symbol is White
86 actual = scheme.findColour('X', 2, null, null, 0);
87 assertEquals(actual, Color.WHITE);