Clover icon

Coverage Report

  1. Project Clover database Thu Nov 7 2024 17:01:39 GMT
  2. Package jalview.renderer

File ResidueColourFinderTest.java

 

Code metrics

2
40
4
1
142
90
5
0.12
10
4
1.25

Classes

Class Line # Actions
ResidueColourFinderTest 39 40 5
0.00%
 

Contributing tests

No tests hitting this source file were found.

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.renderer;
22   
23    import static org.testng.AssertJUnit.assertEquals;
24   
25    import jalview.datamodel.Alignment;
26    import jalview.datamodel.AlignmentI;
27    import jalview.datamodel.Sequence;
28    import jalview.datamodel.SequenceI;
29    import jalview.gui.AlignViewport;
30    import jalview.gui.JvOptionPane;
31    import jalview.schemes.UserColourScheme;
32    import jalview.schemes.ZappoColourScheme;
33   
34    import java.awt.Color;
35   
36    import org.testng.annotations.BeforeClass;
37    import org.testng.annotations.Test;
38   
 
39    public class ResidueColourFinderTest
40    {
41   
 
42  0 toggle @BeforeClass(alwaysRun = true)
43    public void setUpJvOptionPane()
44    {
45  0 JvOptionPane.setInteractiveMode(false);
46  0 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
47    }
48   
 
49  0 toggle @Test(groups = { "Functional" })
50    public void testGetResidueColour_zappo()
51    {
52  0 SequenceI seq = new Sequence("name", "MATVLGSPRAPAFF"); // FER1_MAIZE...
53  0 AlignmentI al = new Alignment(new SequenceI[] { seq });
54  0 final AlignViewport av = new AlignViewport(al);
55  0 ResidueColourFinder rcf = new ResidueColourFinder();
56  0 av.setGlobalColourScheme(new ZappoColourScheme());
57   
58    // @see ResidueProperties.zappo
59  0 assertEquals(Color.pink, rcf.getResidueColour(true,
60    av.getResidueShading(), null, seq, 0, null)); // M
61  0 assertEquals(Color.green, rcf.getResidueColour(true,
62    av.getResidueShading(), null, seq, 2, null)); // T
63  0 assertEquals(Color.magenta, rcf.getResidueColour(true,
64    av.getResidueShading(), null, seq, 5, null)); // G
65  0 assertEquals(Color.orange, rcf.getResidueColour(true,
66    av.getResidueShading(), null, seq, 12, null)); // F
67   
68    // everything is white if showBoxes is false
69  0 assertEquals(Color.white, rcf.getResidueColour(false,
70    av.getResidueShading(), null, seq, 0, null)); // M
71  0 assertEquals(Color.white, rcf.getResidueColour(false,
72    av.getResidueShading(), null, seq, 2, null)); // T
73  0 assertEquals(Color.white, rcf.getResidueColour(false,
74    av.getResidueShading(), null, seq, 5, null)); // G
75  0 assertEquals(Color.white, rcf.getResidueColour(false,
76    av.getResidueShading(), null, seq, 12, null)); // F
77    }
78   
 
79  0 toggle @Test(groups = { "Functional" })
80    public void testGetResidueColour_none()
81    {
82  0 SequenceI seq = new Sequence("name", "MA--TVLGSPRAPAFF");
83  0 AlignmentI al = new Alignment(new SequenceI[] { seq });
84  0 final AlignViewport av = new AlignViewport(al);
85  0 ResidueColourFinder rcf = new ResidueColourFinder();
86   
87  0 assertEquals(Color.white, rcf.getResidueColour(true,
88    av.getResidueShading(), null, seq, 0, null));
89  0 assertEquals(Color.white, rcf.getResidueColour(true,
90    av.getResidueShading(), null, seq, 2, null));
91   
92    // no change if showBoxes is false
93  0 assertEquals(Color.white, rcf.getResidueColour(false,
94    av.getResidueShading(), null, seq, 0, null));
95  0 assertEquals(Color.white, rcf.getResidueColour(false,
96    av.getResidueShading(), null, seq, 2, null));
97    }
98   
 
99  0 toggle @Test(groups = { "Functional" })
100    public void testGetResidueColour_userdef()
101    {
102  0 SequenceI seq = new Sequence("name", "MAT--GSPRAPAFF"); // FER1_MAIZE... + a
103    // gap
104  0 AlignmentI al = new Alignment(new SequenceI[] { seq });
105  0 final AlignViewport av = new AlignViewport(al);
106  0 ResidueColourFinder rcf = new ResidueColourFinder();
107   
108  0 Color[] newColours = new Color[24];
109  0 for (int i = 0; i < 24; i++)
110    {
111  0 newColours[i] = null;
112    }
113   
114  0 av.setGlobalColourScheme(new UserColourScheme(newColours));
115   
116    // gap colour not specified so gap colour is null
117    // this is consistent with previous behaviour, but may not be correct?
118  0 assertEquals(null, rcf.getResidueColour(true, av.getResidueShading(),
119    null, seq, 3, null));
120   
121  0 newColours[23] = Color.pink;
122  0 av.setGlobalColourScheme(new UserColourScheme(newColours));
123   
124    // gap colour specified as pink
125  0 assertEquals(Color.pink, rcf.getResidueColour(true,
126    av.getResidueShading(), null, seq, 3, null));
127   
128    // everything is white if showBoxes is false
129  0 newColours[23] = null;
130  0 assertEquals(Color.white, rcf.getResidueColour(false,
131    av.getResidueShading(), null, seq, 3, null));
132   
133  0 newColours[23] = Color.pink;
134  0 av.setGlobalColourScheme(new UserColourScheme(newColours));
135   
136    // gap colour specified as pink
137  0 assertEquals(Color.white, rcf.getResidueColour(false,
138    av.getResidueShading(), null, seq, 3, null));
139    }
140   
141    // TODO more tests for getResidueColour covering groups, feature rendering...
142    }