From bcdd444ed0efcf2d3f0112402a7c780994e6305b Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Fri, 26 Aug 2016 10:50:35 +0100 Subject: [PATCH] JAL-2154 check that CDS panel is only nucleotide, and protein panel is only Protein for retrieved cross-refs --- test/jalview/io/CrossRef2xmlTests.java | 49 ++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/test/jalview/io/CrossRef2xmlTests.java b/test/jalview/io/CrossRef2xmlTests.java index 20a95d0..24074d0 100644 --- a/test/jalview/io/CrossRef2xmlTests.java +++ b/test/jalview/io/CrossRef2xmlTests.java @@ -158,6 +158,12 @@ public class CrossRef2xmlTests extends Jalview2xmlBase Assert.assertTrue(cra.getXrefViews().size() > 0, "No crossrefs retrieved for " + db); cra_views = cra.getXrefViews(); + assertNucleotide(cra_views.get(0), + "Nucleotide panel included proteins for " + first + + " -> " + db); + assertProtein(cra_views.get(1), + "Protein panel included nucleotides for " + first + + " -> " + db); } else { @@ -245,6 +251,15 @@ public class CrossRef2xmlTests extends Jalview2xmlBase + "' to " + xrefdb + " via '" + nextaf.getTitle() + "'"); cra_views2 = cra.getXrefViews(); + assertNucleotide(cra_views2.get(0), + "Nucleotide panel included proteins for '" + + nextxref + "' to " + xrefdb + + " via '" + nextaf.getTitle() + "'"); + assertProtein(cra_views2.get(1), + "Protein panel included nucleotides for '" + + nextxref + "' to " + xrefdb + + " via '" + nextaf.getTitle() + "'"); + } else { @@ -336,6 +351,40 @@ public class CrossRef2xmlTests extends Jalview2xmlBase } } + private void assertProtein(AlignmentViewPanel alignmentViewPanel, + String message) + { + assertType(true, alignmentViewPanel, message); + } + + private void assertNucleotide(AlignmentViewPanel alignmentViewPanel, + String message) + { + assertType(false, alignmentViewPanel, message); + } + + private void assertType(boolean expectProtein, + AlignmentViewPanel alignmentViewPanel, String message) + { + List nonType = new ArrayList(); + for (SequenceI sq : alignmentViewPanel.getAlignViewport() + .getAlignment() + .getSequences()) + { + if (sq.isProtein() != expectProtein) + { + nonType.add(sq); + } + } + if (nonType.size() > 0) + { + Assert.fail(message + " [ " + + (expectProtein ? "nucleotides were " : "proteins were ") + + nonType.toString() + + " ]"); + } + } + /** * first time called, record strings derived from alignment and * alignedcodonframes, and save view to a project file. Second time called, -- 1.7.10.2