JAL-674 test to ensure sequence and annotation on sequence reference
authorJim Procter <j.procter@dundee.ac.uk>
Mon, 20 Oct 2014 09:57:59 +0000 (10:57 +0100)
committerJim Procter <j.procter@dundee.ac.uk>
Tue, 21 Oct 2014 10:33:18 +0000 (11:33 +0100)
eachother (consider refactoring to a general alignment annotation
validation suite)

test/jalview/io/AnnotatedPDBFileInputTest.java [new file with mode: 0644]

diff --git a/test/jalview/io/AnnotatedPDBFileInputTest.java b/test/jalview/io/AnnotatedPDBFileInputTest.java
new file mode 100644 (file)
index 0000000..a6d09ca
--- /dev/null
@@ -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);
+      }
+    }
+  }
+}