From 7cd611e67a32d433b1cccf5ba61a7b67975bd79f Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Mon, 20 Oct 2014 10:57:59 +0100 Subject: [PATCH] JAL-674 test to ensure sequence and annotation on sequence reference eachother (consider refactoring to a general alignment annotation validation suite) --- test/jalview/io/AnnotatedPDBFileInputTest.java | 54 ++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 test/jalview/io/AnnotatedPDBFileInputTest.java diff --git a/test/jalview/io/AnnotatedPDBFileInputTest.java b/test/jalview/io/AnnotatedPDBFileInputTest.java new file mode 100644 index 0000000..a6d09cae --- /dev/null +++ b/test/jalview/io/AnnotatedPDBFileInputTest.java @@ -0,0 +1,54 @@ +package jalview.io; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.AlignmentI; +import jalview.gui.AlignFrame; + +import org.junit.Before; +import org.junit.Test; + +public class AnnotatedPDBFileInputTest +{ + + AlignmentI al; + + @Before + public void setup() throws Exception + { + FileLoader loader = new FileLoader(false); + AlignFrame af = loader.LoadFileWaitTillLoaded("examples/1gaq.txt", + FormatAdapter.FILE); + al = af.getViewport().getAlignment(); + } + + @Test + public void checkAnnotationWiring() + { + assertTrue(al.getAlignmentAnnotation() != null); + // verify that all sequence annotation is doubly referenced + for (AlignmentAnnotation aa : al.getAlignmentAnnotation()) + { + if (aa.sequenceRef != null) + { + assertTrue(al.getSequences().contains(aa.sequenceRef)); + assertNotNull(aa.sequenceRef.getAnnotation()); + boolean found = false; + for (AlignmentAnnotation sqan : aa.sequenceRef.getAnnotation()) + { + if (sqan == aa) + { + found = true; + break; + } + } + assertTrue( + "Couldn't find sequence associated annotation " + + aa.label + + " on the sequence it is associated with.\nSequence associated editing will fail.", + found); + } + } + } +} -- 1.7.10.2