JAL-3746 apply copyright to tests
[jalview.git] / test / jalview / schemes / Blosum62ColourSchemeTest.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3
10  * of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
19  * The Jalview Authors are detailed in the 'AUTHORS' file.
20  */
21 package jalview.schemes;
22
23 import static org.testng.Assert.assertEquals;
24
25 import java.awt.Color;
26
27 import org.testng.annotations.Test;
28
29 public class Blosum62ColourSchemeTest
30 {
31   /**
32    * Test the method that determines colour as:
33    * <ul>
34    * <li>white if there is no consensus</li>
35    * <li>white if 'residue' is a gap</li>
36    * <li>dark blue if residue matches consensus (or joint consensus)</li>
37    * <li>else, total the residue's Blosum score with the consensus
38    * residue(s)</li>
39    * <ul>
40    * <li>if positive, light blue, else white</li>
41    * </ul>
42    * <ul>
43    */
44   @Test(groups = "Functional")
45   public void testFindColour()
46   {
47     ColourSchemeI blosum = new Blosum62ColourScheme();
48     Color lightBlue = new Color(204, 204, 255);
49     Color darkBlue = new Color(154, 154, 255);
50
51     /*
52      * findColour does not use column, sequence or pid score
53      * we assume consensus residue is computed as upper case
54      */
55     assertEquals(blosum.findColour('A', 0, null, "A", 0f), darkBlue);
56     assertEquals(blosum.findColour('a', 0, null, "A", 0f), darkBlue);
57
58     /*
59      * L has a Blosum score of 
60      * -1 with A
61      * -4 with B
62      * 0 with F
63      * 2 with I
64      * -1 with T
65      * 1 with V
66      * etc
67      */
68     assertEquals(blosum.findColour('L', 0, null, "A", 0f), Color.white); // -1
69     assertEquals(blosum.findColour('L', 0, null, "B", 0f), Color.white); // -4
70     assertEquals(blosum.findColour('L', 0, null, "F", 0f), Color.white); // 0
71     assertEquals(blosum.findColour('L', 0, null, "I", 0f), lightBlue); // 2
72     assertEquals(blosum.findColour('L', 0, null, "TV", 0f), Color.white); // 0
73     assertEquals(blosum.findColour('L', 0, null, "IV", 0f), lightBlue); // 3
74     assertEquals(blosum.findColour('L', 0, null, "IT", 0f), lightBlue); // 1
75     assertEquals(blosum.findColour('L', 0, null, "IAT", 0f), Color.white); // 0
76   }
77 }