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