1696bf6dc8d93e6fb8175185cb25175d7ec96df3
[jalview.git] / test / jalview / schemes / Blosum62ColourSchemeTest.java
1 package jalview.schemes;
2
3 import static org.testng.Assert.assertEquals;
4
5 import java.awt.Color;
6
7 import org.testng.annotations.Test;
8
9 public class Blosum62ColourSchemeTest
10 {
11   /**
12    * Test the method that determines colour as:
13    * <ul>
14    * <li>white if there is no consensus</li>
15    * <li>white if 'residue' is a gap</li>
16    * <li>dark blue if residue matches consensus (or joint consensus)</li>
17    * <li>else, total the residue's Blosum score with the consensus
18    * residue(s)</li>
19    * <ul>
20    * <li>if positive, light blue, else white</li>
21    * </ul>
22    * <ul>
23    */
24   @Test(groups = "Functional")
25   public void testFindColour()
26   {
27     ColourSchemeI blosum = new Blosum62ColourScheme();
28     Color lightBlue = new Color(204, 204, 255);
29     Color darkBlue = new Color(154, 154, 255);
30
31     /*
32      * findColour does not use column, sequence or pid score
33      * we assume consensus residue is computed as upper case
34      */
35     assertEquals(blosum.findColour('A', 0, null, "A", 0f), darkBlue);
36     assertEquals(blosum.findColour('a', 0, null, "A", 0f), darkBlue);
37
38     /*
39      * L has a Blosum score of 
40      * -1 with A
41      * -4 with B
42      * 0 with F
43      * 2 with I
44      * -1 with T
45      * 1 with V
46      * etc
47      */
48     assertEquals(blosum.findColour('L', 0, null, "A", 0f), Color.white); // -1
49     assertEquals(blosum.findColour('L', 0, null, "B", 0f), Color.white); // -4
50     assertEquals(blosum.findColour('L', 0, null, "F", 0f), Color.white); // 0
51     assertEquals(blosum.findColour('L', 0, null, "I", 0f), lightBlue); // 2
52     assertEquals(blosum.findColour('L', 0, null, "TV", 0f), Color.white); // 0
53     assertEquals(blosum.findColour('L', 0, null, "IV", 0f), lightBlue); // 3
54     assertEquals(blosum.findColour('L', 0, null, "IT", 0f), lightBlue); // 1
55     assertEquals(blosum.findColour('L', 0, null, "IAT", 0f), Color.white); // 0
56   }
57 }