JAL-674 test to ensure sequence and annotation on sequence reference
[jalview.git] / test / jalview / io / AnnotatedPDBFileInputTest.java
1 package jalview.io;
2
3 import static org.junit.Assert.assertNotNull;
4 import static org.junit.Assert.assertTrue;
5 import jalview.datamodel.AlignmentAnnotation;
6 import jalview.datamodel.AlignmentI;
7 import jalview.gui.AlignFrame;
8
9 import org.junit.Before;
10 import org.junit.Test;
11
12 public class AnnotatedPDBFileInputTest
13 {
14
15   AlignmentI al;
16
17   @Before
18   public void setup() throws Exception
19   {
20     FileLoader loader = new FileLoader(false);
21     AlignFrame af = loader.LoadFileWaitTillLoaded("examples/1gaq.txt",
22             FormatAdapter.FILE);
23     al = af.getViewport().getAlignment();
24   }
25
26   @Test
27   public void checkAnnotationWiring()
28   {
29     assertTrue(al.getAlignmentAnnotation() != null);
30     // verify that all sequence annotation is doubly referenced
31     for (AlignmentAnnotation aa : al.getAlignmentAnnotation())
32     {
33       if (aa.sequenceRef != null)
34       {
35         assertTrue(al.getSequences().contains(aa.sequenceRef));
36         assertNotNull(aa.sequenceRef.getAnnotation());
37         boolean found = false;
38         for (AlignmentAnnotation sqan : aa.sequenceRef.getAnnotation())
39         {
40           if (sqan == aa)
41           {
42             found = true;
43             break;
44           }
45         }
46         assertTrue(
47                 "Couldn't find sequence associated annotation "
48                         + aa.label
49                         + " on the sequence it is associated with.\nSequence associated editing will fail.",
50                 found);
51       }
52     }
53   }
54 }