1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.renderer; |
22 |
|
|
23 |
|
import static org.testng.AssertJUnit.assertEquals; |
24 |
|
|
25 |
|
import java.awt.Color; |
26 |
|
import java.util.ArrayList; |
27 |
|
|
28 |
|
import org.testng.annotations.BeforeClass; |
29 |
|
import org.testng.annotations.Test; |
30 |
|
|
31 |
|
import jalview.bin.Cache; |
32 |
|
import jalview.datamodel.Alignment; |
33 |
|
import jalview.datamodel.AlignmentI; |
34 |
|
import jalview.datamodel.Sequence; |
35 |
|
import jalview.datamodel.SequenceGroup; |
36 |
|
import jalview.datamodel.SequenceI; |
37 |
|
import jalview.gui.AlignViewport; |
38 |
|
import jalview.gui.JvOptionPane; |
39 |
|
import jalview.gui.OverviewCanvas; |
40 |
|
import jalview.schemes.ColourSchemeI; |
41 |
|
import jalview.schemes.UserColourScheme; |
42 |
|
import jalview.schemes.ZappoColourScheme; |
43 |
|
|
|
|
| 46.7% |
Uncovered Elements: 56 (105) |
Complexity: 7 |
Complexity Density: 0.07 |
|
44 |
|
public class OverviewResColourFinderTest |
45 |
|
{ |
46 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
47 |
1 |
@BeforeClass(alwaysRun = true)... |
48 |
|
public void setUpJvOptionPane() |
49 |
|
{ |
50 |
1 |
JvOptionPane.setInteractiveMode(false); |
51 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
52 |
1 |
Cache.loadProperties("test/jalview/io/testProps.jvprops"); |
53 |
|
} |
54 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
55 |
1 |
@Test(groups = { "Functional" })... |
56 |
|
public void testGetResidueBoxColour_none() |
57 |
|
{ |
58 |
1 |
SequenceI seq = new Sequence("name", "MA--TVLGSPRAPAFF"); |
59 |
1 |
AlignmentI al = new Alignment(new SequenceI[] { seq }); |
60 |
1 |
final AlignViewport av = new AlignViewport(al); |
61 |
1 |
ResidueColourFinder rcf = new OverviewResColourFinder(); |
62 |
|
|
63 |
|
|
64 |
1 |
assertEquals(Color.white, rcf.getResidueColour(true, |
65 |
|
av.getResidueShading(), null, seq, 0, null)); |
66 |
1 |
assertEquals(Color.lightGray, rcf.getResidueColour(true, |
67 |
|
av.getResidueShading(), null, seq, 2, null)); |
68 |
|
|
69 |
|
|
70 |
1 |
assertEquals(Color.white, rcf.getResidueColour(false, |
71 |
|
av.getResidueShading(), null, seq, 0, null)); |
72 |
1 |
assertEquals(Color.lightGray, rcf.getResidueColour(false, |
73 |
|
av.getResidueShading(), null, seq, 2, null)); |
74 |
|
} |
75 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
76 |
1 |
@Test(groups = { "Functional" })... |
77 |
|
public void testGetResidueBoxColour_zappo() |
78 |
|
{ |
79 |
1 |
SequenceI seq = new Sequence("name", "MAT--GSPRAPAFF"); |
80 |
|
|
81 |
1 |
AlignmentI al = new Alignment(new SequenceI[] { seq }); |
82 |
1 |
final AlignViewport av = new AlignViewport(al); |
83 |
1 |
ResidueColourFinder rcf = new OverviewResColourFinder(); |
84 |
1 |
av.setGlobalColourScheme(new ZappoColourScheme()); |
85 |
|
|
86 |
|
|
87 |
1 |
assertEquals(Color.pink, rcf.getResidueColour(true, |
88 |
|
av.getResidueShading(), null, seq, 0, null)); |
89 |
1 |
assertEquals(Color.green, rcf.getResidueColour(true, |
90 |
|
av.getResidueShading(), null, seq, 2, null)); |
91 |
1 |
assertEquals(Color.magenta, rcf.getResidueColour(true, |
92 |
|
av.getResidueShading(), null, seq, 5, null)); |
93 |
1 |
assertEquals(Color.orange, rcf.getResidueColour(true, |
94 |
|
av.getResidueShading(), null, seq, 12, null)); |
95 |
|
|
96 |
|
|
97 |
1 |
assertEquals(Color.lightGray, rcf.getResidueColour(true, |
98 |
|
av.getResidueShading(), null, seq, 3, null)); |
99 |
|
|
100 |
|
|
101 |
1 |
assertEquals(Color.pink, rcf.getResidueColour(false, |
102 |
|
av.getResidueShading(), null, seq, 0, null)); |
103 |
1 |
assertEquals(Color.green, rcf.getResidueColour(false, |
104 |
|
av.getResidueShading(), null, seq, 2, null)); |
105 |
1 |
assertEquals(Color.magenta, rcf.getResidueColour(false, |
106 |
|
av.getResidueShading(), null, seq, 5, null)); |
107 |
1 |
assertEquals(Color.orange, rcf.getResidueColour(false, |
108 |
|
av.getResidueShading(), null, seq, 12, null)); |
109 |
|
|
110 |
|
|
111 |
1 |
assertEquals(Color.lightGray, rcf.getResidueColour(false, |
112 |
|
av.getResidueShading(), null, seq, 3, null)); |
113 |
|
|
114 |
|
} |
115 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (19) |
Complexity: 2 |
Complexity Density: 0.12 |
1PASS
|
|
116 |
1 |
@Test(groups = { "Functional" })... |
117 |
|
public void testGetResidueBoxColour_userdef() |
118 |
|
{ |
119 |
1 |
SequenceI seq = new Sequence("name", "MAT--GSPRAPAFF"); |
120 |
|
|
121 |
1 |
AlignmentI al = new Alignment(new SequenceI[] { seq }); |
122 |
1 |
final AlignViewport av = new AlignViewport(al); |
123 |
1 |
ResidueColourFinder rcf = new OverviewResColourFinder(); |
124 |
|
|
125 |
1 |
Color[] newColours = new Color[24]; |
126 |
25 |
for (int i = 0; i < 24; i++) |
127 |
|
{ |
128 |
24 |
newColours[i] = null; |
129 |
|
} |
130 |
|
|
131 |
1 |
av.setGlobalColourScheme(new UserColourScheme(newColours)); |
132 |
|
|
133 |
|
|
134 |
1 |
assertEquals(Color.lightGray, rcf.getResidueColour(true, |
135 |
|
av.getResidueShading(), null, seq, 3, null)); |
136 |
|
|
137 |
1 |
newColours[23] = Color.pink; |
138 |
1 |
av.setGlobalColourScheme(new UserColourScheme(newColours)); |
139 |
|
|
140 |
|
|
141 |
1 |
assertEquals(Color.pink, rcf.getResidueColour(true, |
142 |
|
av.getResidueShading(), null, seq, 3, null)); |
143 |
|
|
144 |
|
|
145 |
|
|
146 |
1 |
newColours[23] = null; |
147 |
1 |
assertEquals(Color.lightGray, rcf.getResidueColour(false, |
148 |
|
av.getResidueShading(), null, seq, 3, null)); |
149 |
|
|
150 |
1 |
newColours[23] = Color.pink; |
151 |
1 |
av.setGlobalColourScheme(new UserColourScheme(newColours)); |
152 |
|
|
153 |
|
|
154 |
1 |
assertEquals(Color.pink, rcf.getResidueColour(false, |
155 |
|
av.getResidueShading(), null, seq, 3, null)); |
156 |
|
} |
157 |
|
|
|
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
158 |
0 |
@Test... |
159 |
|
public void testGetResidueBoxColour_group() |
160 |
|
{ |
161 |
0 |
SequenceI seq = new Sequence("name", "MA--TVLGSPRAPAFF"); |
162 |
0 |
AlignmentI al = new Alignment(new SequenceI[] { seq }); |
163 |
|
|
164 |
0 |
ColourSchemeI cs = new ZappoColourScheme(); |
165 |
0 |
ArrayList<SequenceI> seqlist = new ArrayList<>(); |
166 |
0 |
seqlist.add(seq); |
167 |
0 |
SequenceGroup sg = new SequenceGroup(seqlist, "testgroup", cs, true, |
168 |
|
true, true, 5, 9); |
169 |
0 |
al.addGroup(sg); |
170 |
0 |
SequenceGroup[] groups = new SequenceGroup[1]; |
171 |
0 |
groups[0] = sg; |
172 |
|
|
173 |
0 |
final AlignViewport av = new AlignViewport(al); |
174 |
0 |
ResidueColourFinder rcf = new OverviewResColourFinder(); |
175 |
|
|
176 |
|
|
177 |
0 |
assertEquals(Color.magenta, rcf.getResidueColour(false, |
178 |
|
av.getResidueShading(), groups, seq, 7, null)); |
179 |
|
|
180 |
|
|
181 |
0 |
assertEquals(Color.white, rcf.getResidueColour(false, |
182 |
|
av.getResidueShading(), groups, seq, 0, null)); |
183 |
|
|
184 |
|
|
185 |
0 |
assertEquals(Color.lightGray, rcf.getResidueColour(false, |
186 |
|
av.getResidueShading(), groups, seq, 2, null)); |
187 |
|
|
188 |
|
|
189 |
0 |
rcf = new OverviewResColourFinder(Color.white, Color.lightGray, |
190 |
|
Color.red); |
191 |
|
|
192 |
|
|
193 |
0 |
assertEquals(Color.magenta, rcf.getResidueColour(false, |
194 |
|
av.getResidueShading(), groups, seq, 7, null)); |
195 |
|
|
196 |
|
|
197 |
0 |
assertEquals(Color.lightGray, rcf.getResidueColour(false, |
198 |
|
av.getResidueShading(), groups, seq, 0, null)); |
199 |
|
|
200 |
|
|
201 |
0 |
assertEquals(Color.white, rcf.getResidueColour(false, |
202 |
|
av.getResidueShading(), groups, seq, 2, null)); |
203 |
|
|
204 |
|
|
205 |
0 |
rcf = new OverviewResColourFinder(Color.blue, Color.white, Color.red); |
206 |
|
|
207 |
|
|
208 |
0 |
assertEquals(Color.magenta, rcf.getResidueColour(false, |
209 |
|
av.getResidueShading(), groups, seq, 7, null)); |
210 |
|
|
211 |
|
|
212 |
0 |
assertEquals(Color.white, rcf.getResidueColour(false, |
213 |
|
av.getResidueShading(), groups, seq, 0, null)); |
214 |
|
|
215 |
|
|
216 |
0 |
assertEquals(Color.blue, rcf.getResidueColour(false, |
217 |
|
av.getResidueShading(), groups, seq, 2, null)); |
218 |
|
} |
219 |
|
|
|
|
| 0% |
Uncovered Elements: 32 (32) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
220 |
0 |
@Test... |
221 |
|
public void testGetBoxColour() |
222 |
|
{ |
223 |
0 |
SequenceI seq = new Sequence("name", "MAT--GSPRAPAFF"); |
224 |
|
|
225 |
0 |
AlignmentI al = new Alignment(new SequenceI[] { seq }); |
226 |
0 |
final AlignViewport av = new AlignViewport(al); |
227 |
|
|
228 |
|
|
229 |
0 |
ResidueColourFinder rcf = new OverviewResColourFinder(); |
230 |
0 |
ResidueShaderI shader = new ResidueShader(); |
231 |
|
|
232 |
|
|
233 |
0 |
Color c = rcf.getBoxColour(shader, seq, 0); |
234 |
0 |
assertEquals(Color.white, c); |
235 |
|
|
236 |
|
|
237 |
0 |
c = rcf.getBoxColour(shader, seq, 3); |
238 |
0 |
assertEquals(OverviewCanvas.OVERVIEW_DEFAULT_GAP, c); |
239 |
|
|
240 |
|
|
241 |
0 |
rcf = new OverviewResColourFinder(Color.white, Color.lightGray, |
242 |
|
Color.red); |
243 |
0 |
shader = new ResidueShader(); |
244 |
|
|
245 |
|
|
246 |
0 |
c = rcf.getBoxColour(shader, seq, 0); |
247 |
0 |
assertEquals(Color.lightGray, c); |
248 |
|
|
249 |
|
|
250 |
0 |
c = rcf.getBoxColour(shader, seq, 3); |
251 |
0 |
assertEquals(Color.white, c); |
252 |
|
|
253 |
|
|
254 |
0 |
rcf = new OverviewResColourFinder(); |
255 |
0 |
shader = new ResidueShader(); |
256 |
|
|
257 |
|
|
258 |
0 |
c = rcf.getBoxColour(shader, seq, 0); |
259 |
0 |
assertEquals(Color.white, c); |
260 |
|
|
261 |
|
|
262 |
0 |
c = rcf.getBoxColour(shader, seq, 3); |
263 |
0 |
assertEquals(OverviewCanvas.OVERVIEW_DEFAULT_GAP, c); |
264 |
|
|
265 |
|
|
266 |
0 |
rcf = new OverviewResColourFinder(Color.blue, Color.white, Color.red); |
267 |
0 |
shader = new ResidueShader(new ZappoColourScheme()); |
268 |
|
|
269 |
|
|
270 |
0 |
c = rcf.getBoxColour(shader, seq, 0); |
271 |
0 |
assertEquals(Color.pink, c); |
272 |
|
|
273 |
|
|
274 |
0 |
c = rcf.getBoxColour(shader, seq, 3); |
275 |
0 |
assertEquals(Color.blue, c); |
276 |
|
|
277 |
|
|
278 |
0 |
rcf = new OverviewResColourFinder(Color.white, Color.lightGray, |
279 |
|
Color.red); |
280 |
|
|
281 |
|
|
282 |
0 |
c = rcf.getBoxColour(shader, seq, 0); |
283 |
0 |
assertEquals(Color.pink, c); |
284 |
|
|
285 |
|
|
286 |
0 |
c = rcf.getBoxColour(shader, seq, 3); |
287 |
0 |
assertEquals(Color.white, c); |
288 |
|
} |
289 |
|
} |