1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.schemes; |
22 |
|
|
23 |
|
import static org.testng.Assert.assertEquals; |
24 |
|
import static org.testng.Assert.assertFalse; |
25 |
|
import static org.testng.Assert.assertSame; |
26 |
|
import static org.testng.Assert.assertTrue; |
27 |
|
|
28 |
|
import java.awt.Color; |
29 |
|
import java.util.Iterator; |
30 |
|
import java.util.Map; |
31 |
|
|
32 |
|
import org.testng.annotations.AfterClass; |
33 |
|
import org.testng.annotations.BeforeClass; |
34 |
|
import org.testng.annotations.Test; |
35 |
|
|
36 |
|
import jalview.api.AlignViewportI; |
37 |
|
import jalview.bin.Cache; |
38 |
|
import jalview.bin.Jalview; |
39 |
|
import jalview.datamodel.AnnotatedCollectionI; |
40 |
|
import jalview.datamodel.SequenceCollectionI; |
41 |
|
import jalview.datamodel.SequenceI; |
42 |
|
import jalview.gui.AlignFrame; |
43 |
|
import jalview.gui.Desktop; |
44 |
|
import jalview.gui.SequenceRenderer; |
45 |
|
import jalview.io.DataSourceType; |
46 |
|
import jalview.io.FileLoader; |
47 |
|
import jalview.schemes.ClustalxColourScheme.ClustalColour; |
48 |
|
|
|
|
| 0% |
Uncovered Elements: 75 (75) |
Complexity: 9 |
Complexity Density: 0.14 |
|
49 |
|
public class ColourSchemesTest |
50 |
|
{ |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 6 |
Complexity Density: 0.67 |
|
55 |
|
class Stripy extends ResidueColourScheme |
56 |
|
{ |
57 |
|
private ResidueColourScheme odd; |
58 |
|
|
59 |
|
private ResidueColourScheme even; |
60 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
61 |
0 |
private Stripy()... |
62 |
|
{ |
63 |
|
} |
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
@param |
69 |
|
@param |
70 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
71 |
0 |
private Stripy(ColourSchemeI cs1, ColourSchemeI cs2)... |
72 |
|
{ |
73 |
0 |
odd = (ResidueColourScheme) cs1; |
74 |
0 |
even = (ResidueColourScheme) cs2; |
75 |
|
} |
76 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
77 |
0 |
@Override... |
78 |
|
public ColourSchemeI getInstance(AlignViewportI view, |
79 |
|
AnnotatedCollectionI sg) |
80 |
|
{ |
81 |
0 |
final ColourSchemeI cs1 = ColourSchemes.getInstance().getColourScheme( |
82 |
|
JalviewColourScheme.Taylor.toString(), |
83 |
|
(AnnotatedCollectionI) null); |
84 |
0 |
final ColourSchemeI cs2 = ColourSchemes.getInstance().getColourScheme( |
85 |
|
JalviewColourScheme.Zappo.toString(), |
86 |
|
(AnnotatedCollectionI) null); |
87 |
0 |
return new Stripy(cs1, cs2); |
88 |
|
} |
89 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
90 |
0 |
@Override... |
91 |
|
public Color findColour(char c, int j, SequenceI seq) |
92 |
|
{ |
93 |
0 |
if (j % 2 == 1) |
94 |
|
{ |
95 |
0 |
return odd.findColour(c, j, seq); |
96 |
|
} |
97 |
|
else |
98 |
|
{ |
99 |
0 |
return even.findColour(c, j, seq); |
100 |
|
} |
101 |
|
} |
102 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
103 |
0 |
@Override... |
104 |
|
public String getSchemeName() |
105 |
|
{ |
106 |
0 |
return "stripy"; |
107 |
|
} |
108 |
|
}; |
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
|
|
|
| 0% |
Uncovered Elements: 43 (43) |
Complexity: 13 |
Complexity Density: 0.59 |
|
113 |
|
class MyClustal extends ResidueColourScheme |
114 |
|
{ |
115 |
|
ClustalxColourScheme delegate; |
116 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
117 |
0 |
private MyClustal()... |
118 |
|
{ |
119 |
|
} |
120 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
121 |
0 |
private MyClustal(AnnotatedCollectionI sg,... |
122 |
|
Map<SequenceI, SequenceCollectionI> hiddenRepSequences) |
123 |
|
{ |
124 |
0 |
delegate = new ClustalxColourScheme(sg, hiddenRepSequences); |
125 |
|
} |
126 |
|
|
|
|
| 0% |
Uncovered Elements: 35 (35) |
Complexity: 9 |
Complexity Density: 0.47 |
|
127 |
0 |
@Override... |
128 |
|
public Color findColour(char c, int j, SequenceI seq) |
129 |
|
{ |
130 |
0 |
Color col = delegate.findColour(c, j, seq); |
131 |
0 |
Color result = col; |
132 |
0 |
if (col.equals(ClustalColour.BLUE.colour)) |
133 |
|
{ |
134 |
0 |
result = Color.blue; |
135 |
|
} |
136 |
0 |
else if (col.equals(ClustalColour.CYAN.colour)) |
137 |
|
{ |
138 |
0 |
result = Color.cyan; |
139 |
|
} |
140 |
0 |
else if (col.equals(ClustalColour.GREEN.colour)) |
141 |
|
{ |
142 |
0 |
result = Color.green; |
143 |
|
} |
144 |
0 |
else if (col.equals(ClustalColour.MAGENTA.colour)) |
145 |
|
{ |
146 |
0 |
result = Color.magenta; |
147 |
|
} |
148 |
0 |
else if (col.equals(ClustalColour.ORANGE.colour)) |
149 |
|
{ |
150 |
0 |
result = Color.orange; |
151 |
|
} |
152 |
0 |
else if (col.equals(ClustalColour.PINK.colour)) |
153 |
|
{ |
154 |
0 |
result = Color.pink; |
155 |
|
} |
156 |
0 |
else if (col.equals(ClustalColour.RED.colour)) |
157 |
|
{ |
158 |
0 |
result = Color.red; |
159 |
|
} |
160 |
0 |
else if (col.equals(ClustalColour.YELLOW.colour)) |
161 |
|
{ |
162 |
0 |
result = Color.yellow; |
163 |
|
} |
164 |
0 |
return result; |
165 |
|
} |
166 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
167 |
0 |
@Override... |
168 |
|
public ColourSchemeI getInstance(AlignViewportI view, |
169 |
|
AnnotatedCollectionI sg) |
170 |
|
{ |
171 |
0 |
return new MyClustal(sg, view.getHiddenRepSequences()); |
172 |
|
} |
173 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
174 |
0 |
@Override... |
175 |
|
public String getSchemeName() |
176 |
|
{ |
177 |
0 |
return "MyClustal"; |
178 |
|
} |
179 |
|
|
180 |
|
} |
181 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
182 |
0 |
@BeforeClass(alwaysRun = true)... |
183 |
|
public static void setUpBeforeClass() throws Exception |
184 |
|
{ |
185 |
|
|
186 |
|
|
187 |
|
|
188 |
0 |
Cache.loadProperties("test/jalview/io/testProps.jvprops"); |
189 |
0 |
Jalview.main(new String[] { "--nonews" }); |
190 |
|
} |
191 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
192 |
0 |
@AfterClass(alwaysRun = true)... |
193 |
|
public static void tearDownAfterClass() throws Exception |
194 |
|
{ |
195 |
0 |
if (Desktop.instance != null) |
196 |
0 |
Desktop.instance.closeAll_actionPerformed(null); |
197 |
|
} |
198 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.5 |
4-
|
|
199 |
0 |
@Test(groups = "Functional")... |
200 |
|
public void testGetColourSchemes() |
201 |
|
{ |
202 |
|
|
203 |
|
|
204 |
|
|
205 |
|
|
206 |
|
|
207 |
0 |
Iterator<ColourSchemeI> schemes = ColourSchemes.getInstance() |
208 |
|
.getColourSchemes().iterator(); |
209 |
0 |
JalviewColourScheme[] jalviewSchemes = JalviewColourScheme.values(); |
210 |
0 |
int i = 0; |
211 |
0 |
while (schemes.hasNext() && i < jalviewSchemes.length) |
212 |
|
{ |
213 |
0 |
assertTrue(schemes.next().getSchemeName() |
214 |
|
.equals(jalviewSchemes[i].toString())); |
215 |
0 |
i++; |
216 |
|
} |
217 |
|
} |
218 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
4-
|
|
219 |
0 |
@Test(groups = "Functional")... |
220 |
|
public void testGetColourScheme() |
221 |
|
{ |
222 |
0 |
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( |
223 |
|
">seq1\nAGLRTWQU", DataSourceType.PASTE); |
224 |
0 |
ColourSchemes schemes = ColourSchemes.getInstance(); |
225 |
|
|
226 |
0 |
AnnotatedCollectionI al = af.getViewport().getAlignment(); |
227 |
|
|
228 |
0 |
for (JalviewColourScheme cs : JalviewColourScheme.values()) |
229 |
|
{ |
230 |
0 |
ColourSchemeI registered = schemes.getColourScheme(cs.toString(), al); |
231 |
0 |
assertSame(registered.getClass(), cs.getSchemeClass()); |
232 |
|
} |
233 |
0 |
af.closeMenuItem_actionPerformed(true); |
234 |
|
} |
235 |
|
|
|
|
| 0% |
Uncovered Elements: 40 (40) |
Complexity: 1 |
Complexity Density: 0.03 |
4-
|
|
236 |
0 |
@Test(groups = "Functional")... |
237 |
|
public void testRegisterColourScheme() |
238 |
|
{ |
239 |
0 |
ColourSchemes.getInstance().registerColourScheme(new Stripy()); |
240 |
0 |
ColourSchemes.getInstance().registerColourScheme(new MyClustal()); |
241 |
0 |
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( |
242 |
|
"examples/uniref50.fa", DataSourceType.FILE); |
243 |
|
|
244 |
|
|
245 |
|
|
246 |
|
|
247 |
0 |
SequenceRenderer sr = new SequenceRenderer(af.getViewport()); |
248 |
0 |
SequenceI seq = af.getViewport().getAlignment().findName("FER_CAPAA"); |
249 |
|
|
250 |
|
|
251 |
|
|
252 |
|
|
253 |
0 |
af.changeColour_actionPerformed(JalviewColourScheme.Taylor.toString()); |
254 |
0 |
Color taylor1 = sr.getResidueColour(seq, 88, null); |
255 |
0 |
Color taylor2 = sr.getResidueColour(seq, 89, null); |
256 |
0 |
Color taylor3 = sr.getResidueColour(seq, 90, null); |
257 |
0 |
assertEquals(taylor1, new Color(255, 0, 102)); |
258 |
0 |
assertEquals(taylor2, new Color(204, 255, 0)); |
259 |
0 |
assertEquals(taylor3, new Color(255, 153, 0)); |
260 |
|
|
261 |
|
|
262 |
|
|
263 |
|
|
264 |
0 |
af.changeColour_actionPerformed(JalviewColourScheme.Zappo.toString()); |
265 |
0 |
Color zappo1 = sr.getResidueColour(seq, 88, null); |
266 |
0 |
Color zappo2 = sr.getResidueColour(seq, 89, null); |
267 |
0 |
Color zappo3 = sr.getResidueColour(seq, 90, null); |
268 |
0 |
assertEquals(zappo1, Color.red); |
269 |
0 |
assertEquals(zappo2, Color.pink); |
270 |
0 |
assertEquals(zappo3, Color.magenta); |
271 |
|
|
272 |
|
|
273 |
|
|
274 |
|
|
275 |
0 |
af.changeColour_actionPerformed("stripy"); |
276 |
0 |
Color stripy1 = sr.getResidueColour(seq, 88, null); |
277 |
0 |
Color stripy2 = sr.getResidueColour(seq, 89, null); |
278 |
0 |
Color stripy3 = sr.getResidueColour(seq, 90, null); |
279 |
0 |
assertEquals(stripy1, zappo1); |
280 |
0 |
assertEquals(stripy2, taylor2); |
281 |
0 |
assertEquals(stripy3, zappo3); |
282 |
|
|
283 |
|
|
284 |
|
|
285 |
|
|
286 |
0 |
af.changeColour_actionPerformed(JalviewColourScheme.Clustal.toString()); |
287 |
0 |
Color clustal1 = sr.getResidueColour(seq, 88, null); |
288 |
0 |
Color clustal2 = sr.getResidueColour(seq, 89, null); |
289 |
0 |
Color clustal3 = sr.getResidueColour(seq, 90, null); |
290 |
0 |
assertEquals(clustal1, ClustalColour.MAGENTA.colour); |
291 |
0 |
assertEquals(clustal2, ClustalColour.BLUE.colour); |
292 |
0 |
assertEquals(clustal3, ClustalColour.ORANGE.colour); |
293 |
|
|
294 |
|
|
295 |
|
|
296 |
|
|
297 |
0 |
af.changeColour_actionPerformed("MyClustal"); |
298 |
0 |
Color myclustal1 = sr.getResidueColour(seq, 88, null); |
299 |
0 |
Color myclustal2 = sr.getResidueColour(seq, 89, null); |
300 |
0 |
Color myclustal3 = sr.getResidueColour(seq, 90, null); |
301 |
0 |
assertEquals(myclustal1, Color.MAGENTA); |
302 |
0 |
assertEquals(myclustal2, Color.BLUE); |
303 |
0 |
assertEquals(myclustal3, Color.ORANGE); |
304 |
|
} |
305 |
|
|
306 |
|
|
307 |
|
|
308 |
|
|
309 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
4-
|
|
310 |
0 |
@Test(groups = "Functional")... |
311 |
|
public void testNameExists() |
312 |
|
{ |
313 |
0 |
ColourSchemes cs = ColourSchemes.getInstance(); |
314 |
0 |
assertFalse(cs.nameExists(null)); |
315 |
0 |
assertFalse(cs.nameExists("")); |
316 |
0 |
assertTrue(cs.nameExists("Clustal")); |
317 |
0 |
assertTrue(cs.nameExists("CLUSTAL")); |
318 |
0 |
assertFalse(cs.nameExists("CLUSTAL ")); |
319 |
0 |
assertTrue(cs.nameExists("% Identity")); |
320 |
0 |
assertFalse(cs.nameExists("PID")); |
321 |
|
} |
322 |
|
} |