JAL-2349 JAL-3855 Integrate pAE retrieval in StructureFile so it can be transferred...
[jalview.git] / src / jalview / datamodel / Alignment.java
index e1c87a9..3ae6831 100755 (executable)
@@ -1653,8 +1653,10 @@ public class Alignment implements AlignmentI, AutoCloseable
   public Iterable<AlignmentAnnotation> findAnnotations(SequenceI seq,
           String calcId, String label)
   {
-    return AlignmentAnnotation.findAnnotations(
-            Arrays.asList(getAlignmentAnnotation()), seq, calcId, label);
+    return annotations == null ? null
+            : AlignmentAnnotation.findAnnotations(
+                    Arrays.asList(getAlignmentAnnotation()), seq, calcId,
+                    label);
   }
 
   @Override
@@ -2045,9 +2047,28 @@ public class Alignment implements AlignmentI, AutoCloseable
   }
 
   @Override
+  public ContactMatrixI getContactMatrixFor(AlignmentAnnotation ann)
+  {
+    return cmholder.getContactMatrixFor(ann);
+  }
+
+  @Override
   public ContactListI getContactListFor(AlignmentAnnotation _aa, int column)
   {
-    return cmholder.getContactListFor(_aa, column);
+    ContactListI cl = cmholder.getContactListFor(_aa, column);
+    if (cl == null && _aa.groupRef != null)
+    {
+      cl = _aa.groupRef.getContactListFor(_aa, column);
+    }
+    if (cl == null && _aa.sequenceRef != null)
+    {
+      cl = _aa.sequenceRef.getContactListFor(_aa, column);
+      if (cl == null && _aa.sequenceRef.getDatasetSequence() != null)
+      {
+        _aa.sequenceRef.getDatasetSequence().getContactListFor(_aa, column);
+      }
+    }
+    return cl;
   }
 
   @Override
@@ -2065,4 +2086,12 @@ public class Alignment implements AlignmentI, AutoCloseable
     addAnnotation(aa);
     return aa;
   }
+
+  @Override
+  public void addContactListFor(AlignmentAnnotation annotation,
+          ContactMatrixI cm)
+  {
+    cmholder.addContactListFor(annotation, cm);
+
+  }
 }