1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.analysis; |
22 |
|
|
23 |
|
import static org.testng.Assert.assertEquals; |
24 |
|
import static org.testng.Assert.assertTrue; |
25 |
|
|
26 |
|
import jalview.datamodel.Sequence; |
27 |
|
import jalview.datamodel.SequenceI; |
28 |
|
import jalview.gui.JvOptionPane; |
29 |
|
|
30 |
|
import java.util.ArrayList; |
31 |
|
import java.util.HashMap; |
32 |
|
import java.util.List; |
33 |
|
import java.util.Map; |
34 |
|
|
35 |
|
import org.testng.annotations.BeforeClass; |
36 |
|
import org.testng.annotations.Test; |
37 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (188) |
Complexity: 6 |
Complexity Density: 0.03 |
|
38 |
|
public class ConservationTest |
39 |
|
{ |
40 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
41 |
1 |
@BeforeClass(alwaysRun = true)... |
42 |
|
public void setUpJvOptionPane() |
43 |
|
{ |
44 |
1 |
JvOptionPane.setInteractiveMode(false); |
45 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
46 |
|
} |
47 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
48 |
1 |
@Test(groups = "Functional")... |
49 |
|
public void testRecordConservation() |
50 |
|
{ |
51 |
1 |
Map<String, Integer> resultMap = new HashMap<String, Integer>(); |
52 |
|
|
53 |
|
|
54 |
1 |
Conservation.recordConservation(resultMap, "V"); |
55 |
1 |
assertEquals(resultMap.get("hydrophobic").intValue(), 1); |
56 |
1 |
assertEquals(resultMap.get("aliphatic").intValue(), 1); |
57 |
1 |
assertEquals(resultMap.get("small").intValue(), 1); |
58 |
1 |
assertEquals(resultMap.get("tiny").intValue(), 0); |
59 |
1 |
assertEquals(resultMap.get("polar").intValue(), 0); |
60 |
1 |
assertEquals(resultMap.get("charged").intValue(), 0); |
61 |
|
|
62 |
|
|
63 |
1 |
Conservation.recordConservation(resultMap, "s"); |
64 |
1 |
assertEquals(resultMap.get("hydrophobic").intValue(), -1); |
65 |
1 |
assertEquals(resultMap.get("aliphatic").intValue(), -1); |
66 |
1 |
assertEquals(resultMap.get("small").intValue(), 1); |
67 |
1 |
assertEquals(resultMap.get("tiny").intValue(), -1); |
68 |
1 |
assertEquals(resultMap.get("polar").intValue(), -1); |
69 |
1 |
assertEquals(resultMap.get("charged").intValue(), 0); |
70 |
|
} |
71 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
72 |
1 |
@Test(groups = "Functional")... |
73 |
|
public void testCountConservationAndGaps() |
74 |
|
{ |
75 |
1 |
List<SequenceI> seqs = new ArrayList<SequenceI>(); |
76 |
1 |
seqs.add(new Sequence("seq1", "VGnY")); |
77 |
1 |
seqs.add(new Sequence("seq2", "-G-y")); |
78 |
1 |
seqs.add(new Sequence("seq3", "VG-Y")); |
79 |
1 |
seqs.add(new Sequence("seq4", "VGNW")); |
80 |
|
|
81 |
1 |
Conservation cons = new Conservation("", seqs, 0, 50); |
82 |
1 |
int[] counts = cons.countConservationAndGaps(0); |
83 |
1 |
assertEquals(counts[0], 1); |
84 |
1 |
assertEquals(counts[1], 1); |
85 |
1 |
counts = cons.countConservationAndGaps(1); |
86 |
1 |
assertEquals(counts[0], 1); |
87 |
1 |
assertEquals(counts[1], 0); |
88 |
1 |
counts = cons.countConservationAndGaps(2); |
89 |
1 |
assertEquals(counts[0], 1); |
90 |
1 |
assertEquals(counts[1], 2); |
91 |
1 |
counts = cons.countConservationAndGaps(3); |
92 |
1 |
assertEquals(counts[0], 0); |
93 |
1 |
assertEquals(counts[1], 0); |
94 |
|
} |
95 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (73) |
Complexity: 1 |
Complexity Density: 0.01 |
1PASS
|
|
96 |
1 |
@Test(groups = "Functional")... |
97 |
|
public void testCalculate_noThreshold() |
98 |
|
{ |
99 |
1 |
List<SequenceI> seqs = new ArrayList<SequenceI>(); |
100 |
1 |
seqs.add(new Sequence("seq1", "VGIV-N")); |
101 |
1 |
seqs.add(new Sequence("seq2", "V-iL-N")); |
102 |
1 |
seqs.add(new Sequence("seq3", "V-IW-N")); |
103 |
1 |
seqs.add(new Sequence("seq4", "VGLH-L")); |
104 |
|
|
105 |
1 |
Conservation cons = new Conservation("", 0, seqs, 0, 5); |
106 |
1 |
cons.calculate(); |
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
|
111 |
1 |
Map<String, Integer> colCons = cons.total[0]; |
112 |
1 |
assertEquals(colCons.get("hydrophobic").intValue(), 1); |
113 |
1 |
assertEquals(colCons.get("aliphatic").intValue(), 1); |
114 |
1 |
assertEquals(colCons.get("small").intValue(), 1); |
115 |
1 |
assertEquals(colCons.get("tiny").intValue(), 0); |
116 |
1 |
assertEquals(colCons.get("proline").intValue(), 0); |
117 |
1 |
assertEquals(colCons.get("charged").intValue(), 0); |
118 |
1 |
assertEquals(colCons.get("negative").intValue(), 0); |
119 |
1 |
assertEquals(colCons.get("polar").intValue(), 0); |
120 |
1 |
assertEquals(colCons.get("positive").intValue(), 0); |
121 |
1 |
assertEquals(colCons.get("aromatic").intValue(), 0); |
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
|
127 |
1 |
colCons = cons.total[1]; |
128 |
1 |
assertEquals(colCons.get("hydrophobic").intValue(), 1); |
129 |
1 |
assertEquals(colCons.get("aliphatic").intValue(), -1); |
130 |
1 |
assertEquals(colCons.get("small").intValue(), 1); |
131 |
1 |
assertEquals(colCons.get("tiny").intValue(), 1); |
132 |
1 |
assertEquals(colCons.get("proline").intValue(), -1); |
133 |
1 |
assertEquals(colCons.get("charged").intValue(), -1); |
134 |
1 |
assertEquals(colCons.get("negative").intValue(), -1); |
135 |
1 |
assertEquals(colCons.get("polar").intValue(), -1); |
136 |
1 |
assertEquals(colCons.get("positive").intValue(), -1); |
137 |
1 |
assertEquals(colCons.get("aromatic").intValue(), -1); |
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
|
142 |
1 |
colCons = cons.total[2]; |
143 |
1 |
assertEquals(colCons.get("hydrophobic").intValue(), 1); |
144 |
1 |
assertEquals(colCons.get("aliphatic").intValue(), 1); |
145 |
1 |
assertEquals(colCons.get("small").intValue(), 0); |
146 |
1 |
assertEquals(colCons.get("tiny").intValue(), 0); |
147 |
1 |
assertEquals(colCons.get("proline").intValue(), 0); |
148 |
1 |
assertEquals(colCons.get("charged").intValue(), 0); |
149 |
1 |
assertEquals(colCons.get("negative").intValue(), 0); |
150 |
1 |
assertEquals(colCons.get("polar").intValue(), 0); |
151 |
1 |
assertEquals(colCons.get("positive").intValue(), 0); |
152 |
1 |
assertEquals(colCons.get("aromatic").intValue(), 0); |
153 |
|
|
154 |
|
|
155 |
|
|
156 |
|
|
157 |
1 |
colCons = cons.total[3]; |
158 |
1 |
assertEquals(colCons.get("hydrophobic").intValue(), 1); |
159 |
1 |
assertEquals(colCons.get("aliphatic").intValue(), -1); |
160 |
1 |
assertEquals(colCons.get("small").intValue(), -1); |
161 |
1 |
assertEquals(colCons.get("tiny").intValue(), 0); |
162 |
1 |
assertEquals(colCons.get("proline").intValue(), 0); |
163 |
1 |
assertEquals(colCons.get("charged").intValue(), -1); |
164 |
1 |
assertEquals(colCons.get("negative").intValue(), 0); |
165 |
1 |
assertEquals(colCons.get("polar").intValue(), -1); |
166 |
1 |
assertEquals(colCons.get("positive").intValue(), -1); |
167 |
1 |
assertEquals(colCons.get("aromatic").intValue(), -1); |
168 |
|
|
169 |
|
|
170 |
|
|
171 |
|
|
172 |
1 |
colCons = cons.total[4]; |
173 |
1 |
assertEquals(colCons.get("hydrophobic").intValue(), 1); |
174 |
1 |
assertEquals(colCons.get("aliphatic").intValue(), 1); |
175 |
1 |
assertEquals(colCons.get("small").intValue(), 1); |
176 |
1 |
assertEquals(colCons.get("tiny").intValue(), 1); |
177 |
1 |
assertEquals(colCons.get("proline").intValue(), 1); |
178 |
1 |
assertEquals(colCons.get("charged").intValue(), 1); |
179 |
1 |
assertEquals(colCons.get("negative").intValue(), 1); |
180 |
1 |
assertEquals(colCons.get("polar").intValue(), 1); |
181 |
1 |
assertEquals(colCons.get("positive").intValue(), 1); |
182 |
1 |
assertEquals(colCons.get("aromatic").intValue(), 1); |
183 |
|
|
184 |
|
|
185 |
|
|
186 |
|
|
187 |
|
|
188 |
1 |
colCons = cons.total[5]; |
189 |
1 |
assertEquals(colCons.get("hydrophobic").intValue(), -1); |
190 |
1 |
assertEquals(colCons.get("aliphatic").intValue(), -1); |
191 |
1 |
assertEquals(colCons.get("small").intValue(), -1); |
192 |
1 |
assertEquals(colCons.get("tiny").intValue(), 0); |
193 |
1 |
assertEquals(colCons.get("proline").intValue(), 0); |
194 |
1 |
assertEquals(colCons.get("charged").intValue(), 0); |
195 |
1 |
assertEquals(colCons.get("negative").intValue(), 0); |
196 |
1 |
assertEquals(colCons.get("polar").intValue(), -1); |
197 |
1 |
assertEquals(colCons.get("positive").intValue(), 0); |
198 |
1 |
assertEquals(colCons.get("aromatic").intValue(), 0); |
199 |
|
} |
200 |
|
|
201 |
|
|
202 |
|
|
203 |
|
|
204 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (54) |
Complexity: 1 |
Complexity Density: 0.02 |
1PASS
|
|
205 |
1 |
@Test(groups = "Functional")... |
206 |
|
public void testCalculate_threshold() |
207 |
|
{ |
208 |
1 |
List<SequenceI> seqs = new ArrayList<SequenceI>(); |
209 |
1 |
seqs.add(new Sequence("seq1", "VGIV-")); |
210 |
1 |
seqs.add(new Sequence("seq2", "V-iL-")); |
211 |
1 |
seqs.add(new Sequence("seq3", "V-IW-")); |
212 |
1 |
seqs.add(new Sequence("seq4", "VGLH-")); |
213 |
1 |
seqs.add(new Sequence("seq5", "VGLH-")); |
214 |
|
|
215 |
|
|
216 |
|
|
217 |
|
|
218 |
|
|
219 |
|
|
220 |
|
|
221 |
|
|
222 |
1 |
Conservation cons = new Conservation("", 50, seqs, 0, 4); |
223 |
1 |
cons.calculate(); |
224 |
|
|
225 |
|
|
226 |
|
|
227 |
|
|
228 |
1 |
Map<String, Integer> colCons = cons.total[0]; |
229 |
1 |
assertEquals(colCons.get("hydrophobic").intValue(), 1); |
230 |
1 |
assertEquals(colCons.get("aliphatic").intValue(), 1); |
231 |
1 |
assertEquals(colCons.get("small").intValue(), 1); |
232 |
1 |
assertEquals(colCons.get("tiny").intValue(), 0); |
233 |
1 |
assertEquals(colCons.get("proline").intValue(), 0); |
234 |
1 |
assertEquals(colCons.get("charged").intValue(), 0); |
235 |
1 |
assertEquals(colCons.get("negative").intValue(), 0); |
236 |
1 |
assertEquals(colCons.get("polar").intValue(), 0); |
237 |
1 |
assertEquals(colCons.get("positive").intValue(), 0); |
238 |
1 |
assertEquals(colCons.get("aromatic").intValue(), 0); |
239 |
|
|
240 |
|
|
241 |
|
|
242 |
|
|
243 |
|
|
244 |
1 |
colCons = cons.total[1]; |
245 |
1 |
assertEquals(colCons.get("hydrophobic").intValue(), 1); |
246 |
1 |
assertEquals(colCons.get("aliphatic").intValue(), 0); |
247 |
1 |
assertEquals(colCons.get("small").intValue(), 1); |
248 |
1 |
assertEquals(colCons.get("tiny").intValue(), 1); |
249 |
1 |
assertEquals(colCons.get("proline").intValue(), 0); |
250 |
1 |
assertEquals(colCons.get("charged").intValue(), 0); |
251 |
1 |
assertEquals(colCons.get("negative").intValue(), 0); |
252 |
1 |
assertEquals(colCons.get("polar").intValue(), 0); |
253 |
1 |
assertEquals(colCons.get("positive").intValue(), 0); |
254 |
1 |
assertEquals(colCons.get("aromatic").intValue(), 0); |
255 |
|
|
256 |
|
|
257 |
|
|
258 |
|
|
259 |
1 |
colCons = cons.total[2]; |
260 |
1 |
assertEquals(colCons.get("hydrophobic").intValue(), 1); |
261 |
1 |
assertEquals(colCons.get("aliphatic").intValue(), 1); |
262 |
1 |
assertEquals(colCons.get("small").intValue(), 0); |
263 |
1 |
assertEquals(colCons.get("tiny").intValue(), 0); |
264 |
1 |
assertEquals(colCons.get("proline").intValue(), 0); |
265 |
1 |
assertEquals(colCons.get("charged").intValue(), 0); |
266 |
1 |
assertEquals(colCons.get("negative").intValue(), 0); |
267 |
1 |
assertEquals(colCons.get("polar").intValue(), 0); |
268 |
1 |
assertEquals(colCons.get("positive").intValue(), 0); |
269 |
1 |
assertEquals(colCons.get("aromatic").intValue(), 0); |
270 |
|
|
271 |
|
|
272 |
|
|
273 |
|
|
274 |
1 |
colCons = cons.total[3]; |
275 |
1 |
assertTrue(colCons.isEmpty()); |
276 |
|
|
277 |
|
|
278 |
|
|
279 |
|
|
280 |
1 |
colCons = cons.total[4]; |
281 |
1 |
assertEquals(colCons.get("hydrophobic").intValue(), 1); |
282 |
1 |
assertEquals(colCons.get("aliphatic").intValue(), 1); |
283 |
1 |
assertEquals(colCons.get("small").intValue(), 1); |
284 |
1 |
assertEquals(colCons.get("tiny").intValue(), 1); |
285 |
1 |
assertEquals(colCons.get("proline").intValue(), 1); |
286 |
1 |
assertEquals(colCons.get("charged").intValue(), 1); |
287 |
1 |
assertEquals(colCons.get("negative").intValue(), 1); |
288 |
1 |
assertEquals(colCons.get("polar").intValue(), 1); |
289 |
1 |
assertEquals(colCons.get("positive").intValue(), 1); |
290 |
1 |
assertEquals(colCons.get("aromatic").intValue(), 1); |
291 |
|
} |
292 |
|
|
293 |
|
|
294 |
|
|
295 |
|
|
296 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
297 |
1 |
@Test(groups = "Functional")... |
298 |
|
public void testVerdict() |
299 |
|
{ |
300 |
1 |
List<SequenceI> seqs = new ArrayList<SequenceI>(); |
301 |
1 |
seqs.add(new Sequence("seq1", "VGIVV-H")); |
302 |
1 |
seqs.add(new Sequence("seq2", "VGILL-H")); |
303 |
1 |
seqs.add(new Sequence("seq3", "VGIW--R")); |
304 |
1 |
seqs.add(new Sequence("seq4", "VGLHH--")); |
305 |
1 |
seqs.add(new Sequence("seq5", "VGLHH-R")); |
306 |
1 |
seqs.add(new Sequence("seq6", "VGLHH--")); |
307 |
1 |
seqs.add(new Sequence("seq7", "VGLHH-R")); |
308 |
1 |
seqs.add(new Sequence("seq8", "VGLHH-R")); |
309 |
|
|
310 |
|
|
311 |
1 |
Conservation cons = new Conservation("", 0, seqs, 0, 6); |
312 |
1 |
cons.calculate(); |
313 |
|
|
314 |
1 |
cons.verdict(false, 25); |
315 |
|
|
316 |
|
|
317 |
|
|
318 |
|
|
319 |
|
|
320 |
|
|
321 |
|
|
322 |
|
|
323 |
|
|
324 |
|
|
325 |
|
|
326 |
1 |
assertEquals(cons.getConsSequence().getSequenceAsString(), "**+41--"); |
327 |
|
|
328 |
|
|
329 |
|
|
330 |
|
|
331 |
|
|
332 |
1 |
assertEquals(cons.getTooltip(0), |
333 |
|
"aliphatic hydrophobic small !aromatic !charged !negative !polar !positive !proline !tiny"); |
334 |
1 |
assertEquals(cons.getTooltip(1), |
335 |
|
"hydrophobic small tiny !aliphatic !aromatic !charged !negative !polar !positive !proline"); |
336 |
1 |
assertEquals(cons.getTooltip(2), |
337 |
|
"aliphatic hydrophobic !aromatic !charged !negative !polar !positive !proline !small !tiny"); |
338 |
1 |
assertEquals(cons.getTooltip(3), |
339 |
|
"hydrophobic !negative !proline !tiny"); |
340 |
1 |
assertEquals(cons.getTooltip(4), "hydrophobic"); |
341 |
1 |
assertEquals(cons.getTooltip(5), ""); |
342 |
1 |
assertEquals(cons.getTooltip(6), ""); |
343 |
|
} |
344 |
|
} |