1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.io; |
22 |
|
|
23 |
|
import static org.testng.Assert.assertEquals; |
24 |
|
import static org.testng.Assert.assertNotNull; |
25 |
|
import static org.testng.Assert.assertTrue; |
26 |
|
|
27 |
|
import jalview.analysis.CrossRef; |
28 |
|
import jalview.api.AlignmentViewPanel; |
29 |
|
import jalview.datamodel.AlignedCodonFrame; |
30 |
|
import jalview.datamodel.AlignmentI; |
31 |
|
import jalview.datamodel.AlignmentTest; |
32 |
|
import jalview.datamodel.SequenceI; |
33 |
|
import jalview.gui.AlignFrame; |
34 |
|
import jalview.gui.CrossRefAction; |
35 |
|
import jalview.gui.Desktop; |
36 |
|
import jalview.gui.JvOptionPane; |
37 |
|
import jalview.gui.SequenceFetcher; |
38 |
|
import jalview.project.Jalview2XML; |
39 |
|
import jalview.util.DBRefUtils; |
40 |
|
|
41 |
|
import java.io.File; |
42 |
|
import java.io.IOException; |
43 |
|
import java.util.ArrayList; |
44 |
|
import java.util.Arrays; |
45 |
|
import java.util.HashMap; |
46 |
|
import java.util.List; |
47 |
|
import java.util.Map; |
48 |
|
|
49 |
|
import org.testng.Assert; |
50 |
|
import org.testng.annotations.BeforeClass; |
51 |
|
import org.testng.annotations.DataProvider; |
52 |
|
import org.testng.annotations.Test; |
53 |
|
|
54 |
|
import junit.extensions.PA; |
55 |
|
|
56 |
|
@Test(singleThreaded = true) |
|
|
| 7.6% |
Uncovered Elements: 257 (278) |
Complexity: 48 |
Complexity Density: 0.23 |
|
57 |
|
public class CrossRef2xmlTests extends Jalview2xmlBase |
58 |
|
{ |
59 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
60 |
1 |
@Override... |
61 |
|
@BeforeClass(alwaysRun = true) |
62 |
|
public void setUpJvOptionPane() |
63 |
|
{ |
64 |
1 |
JvOptionPane.setInteractiveMode(false); |
65 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
66 |
|
} |
67 |
|
|
|
|
| 89.5% |
Uncovered Elements: 2 (19) |
Complexity: 3 |
Complexity Density: 0.16 |
1PASS
|
|
68 |
1 |
@Test(groups = { "Functional" }, enabled = true)... |
69 |
|
public void openCrossrefsForEnsemblTwice() |
70 |
|
{ |
71 |
1 |
AlignFrame af = new FileLoader(false).LoadFileWaitTillLoaded( |
72 |
|
"examples/testdata/CantShowEnsemblCrossrefsTwice.jvp", |
73 |
|
DataSourceType.FILE); |
74 |
1 |
assertNotNull(af, "Couldn't load test's project."); |
75 |
1 |
AlignmentI origAlig = af.getViewport().getAlignment(); |
76 |
1 |
List<String> source = new CrossRef(origAlig.getSequencesArray(), |
77 |
|
origAlig.getDataset()).findXrefSourcesForSequences(true); |
78 |
1 |
assertEquals(source.size(), 1, "Expected just one crossref to show."); |
79 |
1 |
List<AlignmentViewPanel> views; |
80 |
|
{ |
81 |
|
|
82 |
1 |
CrossRefAction xref1 = CrossRefAction.getHandlerFor( |
83 |
|
origAlig.getSequencesArray(), true, source.get(0), af); |
84 |
1 |
try |
85 |
|
{ |
86 |
1 |
xref1.run(); |
87 |
1 |
views = (List<AlignmentViewPanel>) PA.getValue(xref1, "xrefViews"); |
88 |
1 |
assertTrue(views.size() > 0, |
89 |
|
"Couldn't get cross ref on first attempt (SERIOUS FAIL)."); |
90 |
|
} catch (Exception ex) |
91 |
|
{ |
92 |
0 |
Assert.fail("Unexpected Exception for first xref action", ex); |
93 |
|
} |
94 |
|
} |
95 |
|
|
96 |
1 |
views = null; |
97 |
|
|
98 |
1 |
CrossRefAction xref2 = CrossRefAction.getHandlerFor( |
99 |
|
origAlig.getSequencesArray(), true, source.get(0), af); |
100 |
1 |
try |
101 |
|
{ |
102 |
1 |
xref2.run(); |
103 |
1 |
views = (List<AlignmentViewPanel>) PA.getValue(xref2, "xrefViews"); |
104 |
1 |
assertTrue(views.size() > 0, |
105 |
|
"Couldn't get cross ref on second attempt (SERIOUS FAIL)."); |
106 |
|
} catch (Exception ex) |
107 |
|
{ |
108 |
0 |
Assert.fail("Unexpected Exception for second xref action", ex); |
109 |
|
} |
110 |
|
|
111 |
|
} |
112 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
113 |
0 |
@DataProvider(name = "initialAccessions")... |
114 |
|
static Object[][] getAccessions() |
115 |
|
{ |
116 |
0 |
return new String[][] { { "UNIPROT", "P00338" }, |
117 |
|
{ "UNIPROT", "Q8Z9G6" }, |
118 |
|
{ "ENSEMBLGENOMES", "CAD01290" } }; |
119 |
|
} |
120 |
|
|
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
@throws |
127 |
|
|
|
|
| 0% |
Uncovered Elements: 175 (175) |
Complexity: 24 |
Complexity Density: 0.18 |
1PASS
|
|
128 |
0 |
@Test(... |
129 |
|
groups = |
130 |
|
{ "Operational" }, |
131 |
|
dataProvider = "initialAccessions", |
132 |
|
enabled = true) |
133 |
|
public void testRetrieveAndShowCrossref(String forSource, |
134 |
|
String forAccession) throws Exception |
135 |
|
{ |
136 |
|
|
137 |
0 |
List<String> failedDBRetr = new ArrayList<>(); |
138 |
0 |
List<String> failedXrefMenuItems = new ArrayList<>(); |
139 |
0 |
List<String> failedProjectRecoveries = new ArrayList<>(); |
140 |
|
|
141 |
0 |
List<String> limit = Arrays |
142 |
|
.asList(new String[] |
143 |
|
{ DBRefUtils.getCanonicalName("ENSEMBL"), |
144 |
|
DBRefUtils.getCanonicalName("Uniprot") }); |
145 |
|
|
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
|
150 |
|
|
151 |
|
|
152 |
|
|
153 |
|
|
154 |
|
|
155 |
|
|
156 |
|
|
157 |
|
|
158 |
|
|
159 |
|
|
160 |
|
|
161 |
0 |
Map<String, String> dbtoviewBit = new HashMap<>(); |
162 |
0 |
List<String> keyseq = new ArrayList<>(); |
163 |
0 |
Map<String, File> savedProjects = new HashMap<>(); |
164 |
|
|
165 |
|
|
166 |
|
|
167 |
|
|
168 |
|
|
169 |
0 |
int pass1 = 0, pass2 = 0, pass3 = 0; |
170 |
|
|
171 |
|
|
172 |
|
|
173 |
|
|
174 |
0 |
do |
175 |
|
{ |
176 |
0 |
String first = forSource + " " + forAccession; |
177 |
0 |
AlignFrame af = null; |
178 |
0 |
boolean dna; |
179 |
0 |
AlignmentI retral; |
180 |
0 |
AlignmentI dataset; |
181 |
0 |
SequenceI[] seqs; |
182 |
0 |
List<String> ptypes = null; |
183 |
0 |
if (pass1 == 0) |
184 |
|
{ |
185 |
|
|
186 |
|
|
187 |
0 |
SequenceFetcher sf = new SequenceFetcher(Desktop.instance, |
188 |
|
forSource, forAccession); |
189 |
0 |
sf.run(); |
190 |
0 |
AlignFrame[] afs = Desktop.getAlignFrames(); |
191 |
0 |
if (afs.length == 0) |
192 |
|
{ |
193 |
0 |
failedDBRetr.add("Didn't retrieve " + first); |
194 |
0 |
break; |
195 |
|
} |
196 |
0 |
keyseq.add(first); |
197 |
0 |
af = afs[0]; |
198 |
|
|
199 |
|
|
200 |
0 |
AlignmentTest.assertAlignmentDatasetRefs( |
201 |
|
af.getViewport().getAlignment(), "Pass (" + pass1 + "," |
202 |
|
+ pass2 + "," + pass3 + "): Fetch " + first + ":"); |
203 |
0 |
assertDatasetIsNormalisedKnownDefect( |
204 |
|
af.getViewport().getAlignment(), "Pass (" + pass1 + "," |
205 |
|
+ pass2 + "," + pass3 + "): Fetch " + first + ":"); |
206 |
0 |
dna = af.getViewport().getAlignment().isNucleotide(); |
207 |
0 |
retral = af.getViewport().getAlignment(); |
208 |
0 |
dataset = retral.getDataset(); |
209 |
0 |
seqs = retral.getSequencesArray(); |
210 |
|
|
211 |
|
} |
212 |
|
else |
213 |
|
{ |
214 |
0 |
Desktop.instance.closeAll_actionPerformed(null); |
215 |
|
|
216 |
0 |
af = new FileLoader(false).LoadFileWaitTillLoaded( |
217 |
|
savedProjects.get(first).toString(), DataSourceType.FILE); |
218 |
0 |
System.out.println("Recovered view for '" + first + "' from '" |
219 |
|
+ savedProjects.get(first).toString() + "'"); |
220 |
0 |
dna = af.getViewport().getAlignment().isNucleotide(); |
221 |
0 |
retral = af.getViewport().getAlignment(); |
222 |
0 |
dataset = retral.getDataset(); |
223 |
0 |
seqs = retral.getSequencesArray(); |
224 |
|
|
225 |
|
|
226 |
0 |
AlignmentTest.assertAlignmentDatasetRefs( |
227 |
|
af.getViewport().getAlignment(), |
228 |
|
"Pass (" + pass1 + "," + pass2 + "," + pass3 + "): Recover " |
229 |
|
+ first + ":"); |
230 |
0 |
assertDatasetIsNormalisedKnownDefect( |
231 |
|
af.getViewport().getAlignment(), |
232 |
|
"Pass (" + pass1 + "," + pass2 + "," + pass3 + "): Recover " |
233 |
|
+ first + ":"); |
234 |
|
|
235 |
|
} |
236 |
|
|
237 |
|
|
238 |
0 |
stringify(dbtoviewBit, savedProjects, first, af.alignPanel); |
239 |
|
|
240 |
0 |
ptypes = (seqs == null || seqs.length == 0) ? null |
241 |
|
: new CrossRef(seqs, dataset) |
242 |
|
.findXrefSourcesForSequences(dna); |
243 |
0 |
filterDbRefs(ptypes, limit); |
244 |
|
|
245 |
|
|
246 |
|
|
247 |
0 |
do |
248 |
|
{ |
249 |
|
|
250 |
0 |
for (String db : ptypes) |
251 |
|
{ |
252 |
|
|
253 |
0 |
int firstcr_ap = 0; |
254 |
|
|
255 |
0 |
String nextxref = first + " -> " + db + "{" + firstcr_ap + "}"; |
256 |
|
|
257 |
0 |
List<AlignmentViewPanel> cra_views = new ArrayList<>(); |
258 |
0 |
CrossRefAction cra = null; |
259 |
|
|
260 |
0 |
if (pass2 == 0) |
261 |
|
{ |
262 |
0 |
cra = CrossRefAction.getHandlerFor(seqs, dna, db, af); |
263 |
0 |
cra.run(); |
264 |
0 |
cra_views = (List<AlignmentViewPanel>) PA.getValue(cra, |
265 |
|
"xrefViews"); |
266 |
0 |
if (cra_views.size() == 0) |
267 |
|
{ |
268 |
0 |
failedXrefMenuItems.add( |
269 |
|
"No crossrefs retrieved for " + first + " -> " + db); |
270 |
0 |
continue; |
271 |
|
} |
272 |
0 |
assertNucleotide(cra_views.get(0), |
273 |
|
"Nucleotide panel included proteins for " + first |
274 |
|
+ " -> " + db); |
275 |
0 |
assertProtein(cra_views.get(1), |
276 |
|
"Protein panel included nucleotides for " + first |
277 |
|
+ " -> " + db); |
278 |
|
} |
279 |
|
else |
280 |
|
{ |
281 |
0 |
Desktop.instance.closeAll_actionPerformed(null); |
282 |
0 |
pass3 = 0; |
283 |
|
|
284 |
0 |
File storedProject = savedProjects.get(nextxref); |
285 |
0 |
if (storedProject == null) |
286 |
|
{ |
287 |
0 |
failedProjectRecoveries |
288 |
|
.add("Failed to store a view for '" + nextxref + "'"); |
289 |
0 |
continue; |
290 |
|
} |
291 |
|
|
292 |
|
|
293 |
0 |
AlignFrame af2 = new FileLoader(false).LoadFileWaitTillLoaded( |
294 |
|
savedProjects.get(nextxref).toString(), |
295 |
|
DataSourceType.FILE); |
296 |
0 |
System.out |
297 |
|
.println("Recovered view for '" + nextxref + "' from '" |
298 |
|
+ savedProjects.get(nextxref).toString() + "'"); |
299 |
|
|
300 |
0 |
if (af2.getViewport().isNucleotide()) |
301 |
|
{ |
302 |
|
|
303 |
0 |
cra_views.add(af2.getViewport().getAlignPanel()); |
304 |
0 |
cra_views.add(((jalview.gui.AlignViewport) af2.getViewport() |
305 |
|
.getCodingComplement()).getAlignPanel()); |
306 |
|
|
307 |
|
} |
308 |
|
else |
309 |
|
{ |
310 |
|
|
311 |
0 |
cra_views.add(((jalview.gui.AlignViewport) af2.getViewport() |
312 |
|
.getCodingComplement()).getAlignPanel()); |
313 |
0 |
cra_views.add(af2.getViewport().getAlignPanel()); |
314 |
|
|
315 |
|
} |
316 |
|
} |
317 |
0 |
HashMap<String, List<String>> xrptypes = new HashMap<>(); |
318 |
|
|
319 |
0 |
for (AlignmentViewPanel avp : cra_views) |
320 |
|
{ |
321 |
0 |
nextxref = first + " -> " + db + "{" + firstcr_ap++ + "}"; |
322 |
|
|
323 |
0 |
AlignmentTest.assertAlignmentDatasetRefs(avp.getAlignment(), |
324 |
|
"Pass (" + pass1 + "," + pass2 + "," + pass3 |
325 |
|
+ "): before start of pass3: " + nextxref |
326 |
|
+ ":"); |
327 |
0 |
assertDatasetIsNormalisedKnownDefect(avp.getAlignment(), |
328 |
|
"Pass (" + pass1 + "," + pass2 + "," + pass3 |
329 |
|
+ "): before start of pass3: " + nextxref |
330 |
|
+ ":"); |
331 |
|
|
332 |
0 |
SequenceI[] xrseqs = avp.getAlignment().getSequencesArray(); |
333 |
|
|
334 |
0 |
List<String> _xrptypes = (seqs == null || seqs.length == 0) |
335 |
|
? null |
336 |
|
: new CrossRef(xrseqs, dataset) |
337 |
|
.findXrefSourcesForSequences( |
338 |
|
avp.getAlignViewport().isNucleotide()); |
339 |
|
|
340 |
0 |
stringify(dbtoviewBit, savedProjects, nextxref, avp); |
341 |
0 |
xrptypes.put(nextxref, _xrptypes); |
342 |
|
|
343 |
|
} |
344 |
|
|
345 |
|
|
346 |
|
|
347 |
0 |
do |
348 |
|
{ |
349 |
0 |
firstcr_ap = 0; |
350 |
0 |
for (AlignmentViewPanel avp : cra_views) |
351 |
|
{ |
352 |
0 |
nextxref = first + " -> " + db + "{" + firstcr_ap++ + "}"; |
353 |
0 |
for (String xrefdb : xrptypes.get(nextxref)) |
354 |
|
{ |
355 |
0 |
List<AlignmentViewPanel> cra_views2 = new ArrayList<>(); |
356 |
0 |
int q = 0; |
357 |
0 |
String nextnextxref = nextxref + " -> " + xrefdb + "{" + q |
358 |
|
+ "}"; |
359 |
|
|
360 |
0 |
if (pass3 == 0) |
361 |
|
{ |
362 |
0 |
SequenceI[] xrseqs = avp.getAlignment() |
363 |
|
.getSequencesArray(); |
364 |
0 |
AlignFrame nextaf = Desktop |
365 |
|
.getAlignFrameFor(avp.getAlignViewport()); |
366 |
|
|
367 |
0 |
cra = CrossRefAction.getHandlerFor(xrseqs, |
368 |
|
avp.getAlignViewport().isNucleotide(), xrefdb, |
369 |
|
nextaf); |
370 |
0 |
cra.run(); |
371 |
0 |
cra_views2 = (List<AlignmentViewPanel>) PA.getValue(cra, |
372 |
|
"xrefViews"); |
373 |
0 |
if (cra_views2.size() == 0) |
374 |
|
{ |
375 |
0 |
failedXrefMenuItems.add("No crossrefs retrieved for '" |
376 |
|
+ nextxref + "' to " + xrefdb + " via '" |
377 |
|
+ nextaf.getTitle() + "'"); |
378 |
0 |
continue; |
379 |
|
} |
380 |
0 |
assertNucleotide(cra_views2.get(0), |
381 |
|
"Nucleotide panel included proteins for '" |
382 |
|
+ nextxref + "' to " + xrefdb + " via '" |
383 |
|
+ nextaf.getTitle() + "'"); |
384 |
0 |
assertProtein(cra_views2.get(1), |
385 |
|
"Protein panel included nucleotides for '" |
386 |
|
+ nextxref + "' to " + xrefdb + " via '" |
387 |
|
+ nextaf.getTitle() + "'"); |
388 |
|
|
389 |
|
} |
390 |
|
else |
391 |
|
{ |
392 |
0 |
Desktop.instance.closeAll_actionPerformed(null); |
393 |
|
|
394 |
0 |
File storedProject = savedProjects.get(nextnextxref); |
395 |
0 |
if (storedProject == null) |
396 |
|
{ |
397 |
0 |
failedProjectRecoveries |
398 |
|
.add("Failed to store a view for '" |
399 |
|
+ nextnextxref + "'"); |
400 |
0 |
continue; |
401 |
|
} |
402 |
0 |
AlignFrame af2 = new FileLoader(false) |
403 |
|
.LoadFileWaitTillLoaded(savedProjects |
404 |
|
.get(nextnextxref).toString(), |
405 |
|
DataSourceType.FILE); |
406 |
0 |
System.out |
407 |
|
.println("Recovered view for '" + nextnextxref |
408 |
|
+ "' from '" + savedProjects |
409 |
|
.get(nextnextxref).toString() |
410 |
|
+ "'"); |
411 |
|
|
412 |
|
|
413 |
0 |
if (af2.getViewport().isNucleotide()) |
414 |
|
{ |
415 |
|
|
416 |
0 |
cra_views2.add(af2.getViewport().getAlignPanel()); |
417 |
0 |
cra_views2.add(((jalview.gui.AlignViewport) af2 |
418 |
|
.getViewport().getCodingComplement()) |
419 |
|
.getAlignPanel()); |
420 |
|
|
421 |
|
} |
422 |
|
else |
423 |
|
{ |
424 |
|
|
425 |
0 |
cra_views2.add(((jalview.gui.AlignViewport) af2 |
426 |
|
.getViewport().getCodingComplement()) |
427 |
|
.getAlignPanel()); |
428 |
0 |
cra_views2.add(af2.getViewport().getAlignPanel()); |
429 |
|
} |
430 |
0 |
Assert.assertEquals(cra_views2.size(), 2); |
431 |
0 |
Assert.assertNotNull(cra_views2.get(0)); |
432 |
0 |
Assert.assertNotNull(cra_views2.get(1)); |
433 |
|
} |
434 |
|
|
435 |
0 |
for (AlignmentViewPanel nextavp : cra_views2) |
436 |
|
{ |
437 |
0 |
nextnextxref = nextxref + " -> " + xrefdb + "{" + q++ |
438 |
|
+ "}"; |
439 |
|
|
440 |
|
|
441 |
0 |
AlignmentTest.assertAlignmentDatasetRefs( |
442 |
|
nextavp.getAlignment(), |
443 |
|
"" + "Pass (" + pass1 + "," + pass2 + "): For " |
444 |
|
+ nextnextxref + ":"); |
445 |
0 |
assertDatasetIsNormalisedKnownDefect( |
446 |
|
nextavp.getAlignment(), |
447 |
|
"" + "Pass (" + pass1 + "," + pass2 + "): For " |
448 |
|
+ nextnextxref + ":"); |
449 |
|
|
450 |
0 |
stringify(dbtoviewBit, savedProjects, nextnextxref, |
451 |
|
nextavp); |
452 |
0 |
keyseq.add(nextnextxref); |
453 |
|
} |
454 |
|
} |
455 |
|
|
456 |
|
} |
457 |
0 |
} while (pass2 == 2 && pass3++ < 2); |
458 |
|
|
459 |
|
|
460 |
|
|
461 |
|
|
462 |
|
} |
463 |
|
|
464 |
|
|
465 |
|
|
466 |
|
|
467 |
0 |
} while (pass1 == 1 && pass2++ < 2); |
468 |
|
|
469 |
|
|
470 |
|
|
471 |
|
|
472 |
|
|
473 |
|
|
474 |
0 |
if (pass1 == 0) |
475 |
|
{ |
476 |
|
|
477 |
0 |
pass1 = 1; |
478 |
|
|
479 |
0 |
pass2 = 0; |
480 |
0 |
pass3 = 0; |
481 |
|
} |
482 |
|
else |
483 |
|
{ |
484 |
0 |
pass1++; |
485 |
|
} |
486 |
0 |
} while (pass1 < 3); |
487 |
|
|
488 |
0 |
if (failedXrefMenuItems.size() > 0) |
489 |
|
{ |
490 |
0 |
for (String s : failedXrefMenuItems) |
491 |
|
{ |
492 |
0 |
System.err.println(s); |
493 |
|
} |
494 |
0 |
Assert.fail("Faulty xref menu (" + failedXrefMenuItems.size() |
495 |
|
+ " counts)"); |
496 |
|
} |
497 |
0 |
if (failedProjectRecoveries.size() > 0) |
498 |
|
{ |
499 |
|
|
500 |
0 |
for (String s : failedProjectRecoveries) |
501 |
|
{ |
502 |
0 |
System.err.println(s); |
503 |
|
} |
504 |
0 |
Assert.fail( |
505 |
|
"Didn't recover projects for some retrievals (did they retrieve ?) (" |
506 |
|
+ failedProjectRecoveries.size() + " counts)"); |
507 |
|
} |
508 |
0 |
if (failedDBRetr.size() > 0) |
509 |
|
{ |
510 |
0 |
for (String s : failedProjectRecoveries) |
511 |
|
{ |
512 |
0 |
System.err.println(s); |
513 |
|
} |
514 |
0 |
Assert.fail("Didn't retrieve some db refs for checking cross-refs (" |
515 |
|
+ failedDBRetr.size() + " counts)"); |
516 |
|
} |
517 |
|
} |
518 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 4 |
Complexity Density: 0.67 |
|
519 |
0 |
private void filterDbRefs(List<String> ptypes, List<String> limit)... |
520 |
|
{ |
521 |
0 |
if (limit != null) |
522 |
|
{ |
523 |
0 |
int p = 0; |
524 |
0 |
while (ptypes.size() > p) |
525 |
|
{ |
526 |
0 |
if (!limit.contains(ptypes.get(p))) |
527 |
|
{ |
528 |
0 |
ptypes.remove(p); |
529 |
|
} |
530 |
|
else |
531 |
|
{ |
532 |
0 |
p++; |
533 |
|
} |
534 |
|
} |
535 |
|
} |
536 |
|
} |
537 |
|
|
538 |
|
|
539 |
|
|
540 |
|
|
541 |
|
@param |
542 |
|
@param |
543 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 3 |
Complexity Density: 0.6 |
|
544 |
0 |
private void assertDatasetIsNormalisedKnownDefect(AlignmentI al,... |
545 |
|
String message) |
546 |
|
{ |
547 |
0 |
try |
548 |
|
{ |
549 |
0 |
AlignmentTest.assertDatasetIsNormalised(al, message); |
550 |
|
} catch (AssertionError ae) |
551 |
|
{ |
552 |
0 |
if (!ae.getMessage().endsWith("EMBL|AH002001")) |
553 |
|
{ |
554 |
0 |
throw ae; |
555 |
|
} |
556 |
|
else |
557 |
|
{ |
558 |
0 |
System.out.println("Ignored exception for known defect: JAL-2179 : " |
559 |
|
+ message); |
560 |
|
} |
561 |
|
|
562 |
|
} |
563 |
|
} |
564 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
565 |
0 |
private void assertProtein(AlignmentViewPanel alignmentViewPanel,... |
566 |
|
String message) |
567 |
|
{ |
568 |
0 |
assertType(true, alignmentViewPanel, message); |
569 |
|
} |
570 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
571 |
0 |
private void assertNucleotide(AlignmentViewPanel alignmentViewPanel,... |
572 |
|
String message) |
573 |
|
{ |
574 |
0 |
assertType(false, alignmentViewPanel, message); |
575 |
|
} |
576 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 4 |
Complexity Density: 0.67 |
|
577 |
0 |
private void assertType(boolean expectProtein,... |
578 |
|
AlignmentViewPanel alignmentViewPanel, String message) |
579 |
|
{ |
580 |
0 |
List<SequenceI> nonType = new ArrayList<>(); |
581 |
0 |
for (SequenceI sq : alignmentViewPanel.getAlignViewport().getAlignment() |
582 |
|
.getSequences()) |
583 |
|
{ |
584 |
0 |
if (sq.isProtein() != expectProtein) |
585 |
|
{ |
586 |
0 |
nonType.add(sq); |
587 |
|
} |
588 |
|
} |
589 |
0 |
if (nonType.size() > 0) |
590 |
|
{ |
591 |
0 |
Assert.fail(message + " [ " |
592 |
0 |
+ (expectProtein ? "nucleotides were " : "proteins were ") |
593 |
|
+ nonType.toString() + " ]"); |
594 |
|
} |
595 |
|
} |
596 |
|
|
597 |
|
|
598 |
|
|
599 |
|
|
600 |
|
|
601 |
|
|
602 |
|
|
603 |
|
@param |
604 |
|
|
605 |
|
@param |
606 |
|
|
607 |
|
@param |
608 |
|
|
609 |
|
|
610 |
|
@param |
611 |
|
|
612 |
|
|
613 |
|
|
614 |
|
|
615 |
|
|
616 |
|
|
|
|
| 0% |
Uncovered Elements: 38 (38) |
Complexity: 6 |
Complexity Density: 0.2 |
|
617 |
0 |
private void stringify(Map<String, String> dbtoviewBit,... |
618 |
|
Map<String, File> savedProjects, String xrefpath, |
619 |
|
AlignmentViewPanel avp) |
620 |
|
{ |
621 |
0 |
if (savedProjects != null) |
622 |
|
{ |
623 |
0 |
if (savedProjects.get(xrefpath) == null) |
624 |
|
{ |
625 |
|
|
626 |
|
|
627 |
0 |
try |
628 |
|
{ |
629 |
0 |
File prfile = File.createTempFile("crossRefTest", ".jvp"); |
630 |
0 |
AlignFrame af = Desktop.getAlignFrameFor(avp.getAlignViewport()); |
631 |
0 |
new Jalview2XML(false).saveAlignment(af, prfile.toString(), |
632 |
|
af.getTitle()); |
633 |
0 |
System.out.println("Written view from '" + xrefpath + "' as '" |
634 |
|
+ prfile.getAbsolutePath() + "'"); |
635 |
0 |
savedProjects.put(xrefpath, prfile); |
636 |
|
} catch (IOException q) |
637 |
|
{ |
638 |
0 |
Assert.fail("Unexpected IO Exception", q); |
639 |
|
} |
640 |
|
} |
641 |
|
else |
642 |
|
{ |
643 |
0 |
System.out.println("Stringify check on view from '" + xrefpath |
644 |
|
+ "' [ possibly retrieved from '" |
645 |
|
+ savedProjects.get(xrefpath).getAbsolutePath() + "' ]"); |
646 |
|
|
647 |
|
} |
648 |
|
} |
649 |
|
|
650 |
0 |
StringBuilder sbr = new StringBuilder(); |
651 |
0 |
sbr.append(avp.getAlignment().toString()); |
652 |
0 |
sbr.append("\n"); |
653 |
0 |
sbr.append("<End of alignment>"); |
654 |
0 |
sbr.append("\n"); |
655 |
0 |
sbr.append(avp.getAlignment().getDataset()); |
656 |
0 |
sbr.append("\n"); |
657 |
0 |
sbr.append("<End of dataset>"); |
658 |
0 |
sbr.append("\n"); |
659 |
0 |
int p = 0; |
660 |
0 |
if (avp.getAlignment().getCodonFrames() != null) |
661 |
|
{ |
662 |
0 |
for (AlignedCodonFrame ac : avp.getAlignment().getCodonFrames()) |
663 |
|
{ |
664 |
0 |
sbr.append("<AlignedCodonFrame " + p++ + ">"); |
665 |
0 |
sbr.append("\n"); |
666 |
0 |
sbr.append(ac.toString()); |
667 |
0 |
sbr.append("\n"); |
668 |
|
} |
669 |
|
} |
670 |
0 |
String dbt = dbtoviewBit.get(xrefpath); |
671 |
0 |
if (dbt == null) |
672 |
|
{ |
673 |
0 |
dbtoviewBit.put(xrefpath, sbr.toString()); |
674 |
|
} |
675 |
|
else |
676 |
|
{ |
677 |
0 |
Assert.assertEquals(sbr.toString(), dbt, |
678 |
|
"stringify mismatch for " + xrefpath); |
679 |
|
} |
680 |
|
} |
681 |
|
} |