From: Jim Procter Date: Mon, 20 Oct 2014 09:57:59 +0000 (+0100) Subject: JAL-674 test to ensure sequence and annotation on sequence reference X-Git-Tag: Jalview_2_9~169^2~17 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=7cd611e67a32d433b1cccf5ba61a7b67975bd79f;p=jalview.git JAL-674 test to ensure sequence and annotation on sequence reference eachother (consider refactoring to a general alignment annotation validation suite) --- 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); + } + } + } +}