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