From d8965731a376fef5d414c64ec9865f643665119e Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Fri, 19 Aug 2016 16:26:07 +0100 Subject: [PATCH] JAL-2154 major rejigging of test looping again probably not 100% correct, but now fails when: Recovered view for 'UNIPROT P01731 -> EMBL{1} -> ENSEMBL{0}' from '/var/folders/km/m8_86nbd4bbcpd5s2h8xqtk4_kj190/T/crossRefTest9144214145355720129.jvp' Cause is: Parsing as Jalview Version 2 file failed. java.lang.ArrayIndexOutOfBoundsException: 73 at jalview.gui.Jalview2XML.loadFromObject(Jalview2XML.java:2827) at jalview.gui.Jalview2XML.loadJalviewAlign(Jalview2XML.java:2390) at jalview.gui.Jalview2XML.loadJalviewAlign(Jalview2XML.java:2277) at jalview.io.FileLoader.run(FileLoader.java:308) at java.lang.Thread.run(Thread.java:745) --- test/jalview/io/CrossRef2xmlTests.java | 115 +++++++++++++++++++++----------- 1 file changed, 76 insertions(+), 39 deletions(-) diff --git a/test/jalview/io/CrossRef2xmlTests.java b/test/jalview/io/CrossRef2xmlTests.java index cc26d7e..64c800b 100644 --- a/test/jalview/io/CrossRef2xmlTests.java +++ b/test/jalview/io/CrossRef2xmlTests.java @@ -87,6 +87,11 @@ public class CrossRef2xmlTests extends Jalview2xmlBase { String first = did[0] + " " + did[1]; AlignFrame af = null; + boolean dna; + AlignmentI retral; + AlignmentI dataset; + SequenceI[] seqs; + List ptypes = null; if (pass1 == 0) { // retrieve dbref @@ -101,9 +106,11 @@ public class CrossRef2xmlTests extends Jalview2xmlBase AlignmentTest.assertAlignmentDatasetRefs(af.getViewport() .getAlignment(), "Pass (" + pass1 + "," + pass2 + "," + pass3 + "): Fetch " + first + ":"); + dna = af.getViewport().getAlignment().isNucleotide(); + retral = af.getViewport().getAlignment(); + dataset = retral.getDataset(); + seqs = retral.getSequencesArray(); - // store project to recover on next pass - stringify(dbtoviewBit, savedProjects, first, af.alignPanel); } else { @@ -111,6 +118,12 @@ public class CrossRef2xmlTests extends Jalview2xmlBase // recover stored project af = new FileLoader(false).LoadFileWaitTillLoaded(savedProjects .get(first).toString(), FormatAdapter.FILE); + System.out.println("Recovered view for '" + first + "' from '" + + savedProjects.get(first).toString() + "'"); + dna = af.getViewport().getAlignment().isNucleotide(); + retral = af.getViewport().getAlignment(); + dataset = retral.getDataset(); + seqs = retral.getSequencesArray(); // verify references for recovered data AlignmentTest.assertAlignmentDatasetRefs(af.getViewport() @@ -119,23 +132,24 @@ public class CrossRef2xmlTests extends Jalview2xmlBase } - boolean dna = af.getViewport().getAlignment().isNucleotide(); - AlignmentI retral = af.getViewport().getAlignment(); - AlignmentI dataset = retral.getDataset(); - SequenceI[] seqs = retral.getSequencesArray(); - List ptypes = (seqs == null || seqs.length == 0) ? null - : new CrossRef(seqs, dataset) - .findXrefSourcesForSequences(dna); + // store project on first pass, compare next pass + stringify(dbtoviewBit, savedProjects, first, af.alignPanel); + ptypes = (seqs == null || seqs.length == 0) ? null : new CrossRef( + seqs, dataset).findXrefSourcesForSequences(dna); + + // start of pass2: retrieve each cross-ref for fetched or restored + // project. pass2 = 0; do // second cross ref and recover crossref loop { - for (String db : ptypes) - { + + for (String db : ptypes) + { // counter for splitframe views retrieved via crossref - int p = 0; + int firstcr_ap = 0; // build next key so we an retrieve all views - String nextxref = first + " -> " + db + "{" + p + "}"; + String nextxref = first + " -> " + db + "{" + firstcr_ap + "}"; // perform crossref action, or retrieve stored project List cra_views = new ArrayList(); CrossRefAction cra = null; @@ -154,6 +168,9 @@ public class CrossRef2xmlTests extends Jalview2xmlBase AlignFrame af2 = new FileLoader(false) .LoadFileWaitTillLoaded(savedProjects.get(nextxref) .toString(), FormatAdapter.FILE); + System.out.println("Recovered view for '" + nextxref + + "' from '" + savedProjects.get(nextxref).toString() + + "'"); // gymnastics to recover the alignPanel/Complementary alignPanel if (af2.getViewport().isNucleotide()) { @@ -174,47 +191,61 @@ public class CrossRef2xmlTests extends Jalview2xmlBase } } + HashMap> xrptypes = new HashMap>(); + // first save/verify views. for (AlignmentViewPanel avp : cra_views) { - nextxref = first + " -> " + db + "{" + p++ + "}"; - + nextxref = first + " -> " + db + "{" + firstcr_ap++ + "}"; // verify references for this panel AlignmentTest.assertAlignmentDatasetRefs(avp.getAlignment(), - "" + "Pass (" + pass1 + "," + pass2 + "): For " - + nextxref + ":"); + "Pass (" + pass1 + "," + pass2 + "," + pass3 + + "): before start of pass3: " + nextxref + + ":"); SequenceI[] xrseqs = avp.getAlignment().getSequencesArray(); - stringify(dbtoviewBit, savedProjects, nextxref, avp); - keyseq.add(nextxref); - - List xrptypes = (seqs == null || seqs.length == 0) ? null + List _xrptypes = (seqs == null || seqs.length == 0) ? null : new CrossRef(xrseqs, dataset) .findXrefSourcesForSequences(avp .getAlignViewport().isNucleotide()); - pass3 = 0; - do // 3rd cross ref and recover crossref loop + + stringify(dbtoviewBit, savedProjects, nextxref, avp); + xrptypes.put(nextxref, _xrptypes); + + } + // now do the next xref pass starting from either saved or just + // recovered split pane, in sequence + pass3 = 0; + do // 3rd cross ref and recover crossref loop, for each view from + // second xref view set or recover viewset + { + firstcr_ap = 0; + for (AlignmentViewPanel avp : cra_views) { - for (String xrefdb : xrptypes) + nextxref = first + " -> " + db + "{" + firstcr_ap++ + "}"; + for (String xrefdb : xrptypes.get(nextxref)) { List cra_views2 = new ArrayList(); int q = 0; - String nextnextxref = "{" + p + "}" + nextxref + " -> " - + xrefdb + "{" + q + "}"; + String nextnextxref = nextxref + + " -> " + xrefdb + "{" + q + "}"; if (pass3 == 0) { + SequenceI[] xrseqs = avp.getAlignment() + .getSequencesArray(); AlignFrame nextaf = Desktop.getAlignFrameFor(avp .getAlignViewport()); cra = new CrossRefAction(nextaf, xrseqs, avp .getAlignViewport().isNucleotide(), xrefdb); cra.run(); - Assert.assertTrue(cra.getXrefViews().size() > 0, - "No crossrefs found for '" + nextxref + "' to " - + xrefdb + " via '" + nextaf.getTitle() - + "'"); + Assert.assertTrue( + cra.getXrefViews().size() > 0, + "No crossrefs found for '" + nextnextxref + + "' to " + xrefdb + " via '" + + nextaf.getTitle() + "'"); cra_views2 = cra.getXrefViews(); } else @@ -225,6 +256,10 @@ public class CrossRef2xmlTests extends Jalview2xmlBase .LoadFileWaitTillLoaded( savedProjects.get(nextnextxref) .toString(), FormatAdapter.FILE); + System.out.println("Recovered view for '" + + nextnextxref + "' from '" + + savedProjects.get(nextnextxref).toString() + + "'"); // gymnastics to recover the alignPanel/Complementary // alignPanel if (af2.getViewport().isNucleotide()) @@ -251,8 +286,8 @@ public class CrossRef2xmlTests extends Jalview2xmlBase for (AlignmentViewPanel nextavp : cra_views2) { - nextnextxref = "{" + p + "}" + nextxref + " -> " - + xrefdb + "{" + q++ + "}"; + nextnextxref = nextxref + + " -> " + xrefdb + "{" + q++ + "}"; // verify references for this panel AlignmentTest.assertAlignmentDatasetRefs( @@ -265,12 +300,14 @@ public class CrossRef2xmlTests extends Jalview2xmlBase keyseq.add(nextnextxref); } } // end of loop around showing all xrefdb for crossrf2 - // fetchdb->crossref1->crossref-2->verify for xrefs we - // either loop twice when pass2=0, or just once when pass2=1 - // (recovered project from previous crossref) - } while (pass3++ < 2 && pass2 < 1); - } - } + + } // end of loop around all viewpanels from crossrf1 + } while (pass3++ < 2 && pass2 < 1); + // fetchdb->crossref1->crossref-2->verify for xrefs we + // either loop twice when pass2=0, or just once when pass2=1 + // (recovered project from previous crossref) + + } // fetchdb-->crossref1 // for each xref we try to retrieve xref, store and verify when // pass1=0, or just retrieve and verify when pass1=1 @@ -278,7 +315,7 @@ public class CrossRef2xmlTests extends Jalview2xmlBase // fetchdb // for each ref we // loop twice: first, do the retrieve, second recover from saved project - } while (++pass1 < 2); + } while (pass1++ < 2); } } -- 1.7.10.2