Clover icon

Coverage Report

  1. Project Clover database Wed Sep 18 2024 02:54:09 BST
  2. Package jalview.schemes

File Blosum62ColourSchemeTest.java

 

Code metrics

0
13
1
1
77
24
1
0.08
13
1
1

Classes

Class Line # Actions
Blosum62ColourSchemeTest 29 13 1
1.0100%
 

Contributing tests

This file is covered by 1 test. .

Source view

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  1 toggle @Test(groups = "Functional")
45    public void testFindColour()
46    {
47  1 ColourSchemeI blosum = new Blosum62ColourScheme();
48  1 Color lightBlue = new Color(204, 204, 255);
49  1 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  1 assertEquals(blosum.findColour('A', 0, null, "A", 0f), darkBlue);
56  1 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  1 assertEquals(blosum.findColour('L', 0, null, "A", 0f), Color.white); // -1
69  1 assertEquals(blosum.findColour('L', 0, null, "B", 0f), Color.white); // -4
70  1 assertEquals(blosum.findColour('L', 0, null, "F", 0f), Color.white); // 0
71  1 assertEquals(blosum.findColour('L', 0, null, "I", 0f), lightBlue); // 2
72  1 assertEquals(blosum.findColour('L', 0, null, "TV", 0f), Color.white); // 0
73  1 assertEquals(blosum.findColour('L', 0, null, "IV", 0f), lightBlue); // 3
74  1 assertEquals(blosum.findColour('L', 0, null, "IT", 0f), lightBlue); // 1
75  1 assertEquals(blosum.findColour('L', 0, null, "IAT", 0f), Color.white); // 0
76    }
77    }