Merge branch 'features/r2_11_2_alphafold/JAL-2349_JAL-3855' into develop
[jalview.git] / src / jalview / datamodel / Alignment.java
index a2a152a..9825bff 100755 (executable)
@@ -32,6 +32,7 @@ import java.util.Arrays;
 import java.util.BitSet;
 import java.util.Collections;
 import java.util.Enumeration;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.Iterator;
@@ -1914,12 +1915,11 @@ public class Alignment implements AlignmentI, AutoCloseable
   @Override
   public boolean setHiddenColumns(HiddenColumns cols)
   {
-    boolean changed = cols == null ? hiddenCols != null
-            : !cols.equals(hiddenCols);
-    hiddenCols = cols;
-    return changed;
+  boolean changed = cols == null ? hiddenCols != null
+          : !cols.equals(hiddenCols);
+  hiddenCols = cols;
+  return changed;
   }
-
   @Override
   public void setupJPredAlignment()
   {
@@ -2032,4 +2032,42 @@ public class Alignment implements AlignmentI, AutoCloseable
     }
   }
 
+  Map<Object, ContactMatrixI> contactmaps = new HashMap<>();
+  @Override
+  public
+  ContactListI getContactListFor(AlignmentAnnotation _aa, int column)
+  {
+    ContactMatrixI cm = contactmaps.get(_aa.annotationId);
+    if (cm == null)
+    {
+      return null;
+    }
+    return cm.getContactList(column);
+  }
+
+  @Override
+  public AlignmentAnnotation addContactList(ContactMatrixI cm)
+  {
+    Annotation _aa[] = new Annotation[getWidth()];
+    Annotation dummy = new Annotation(0.0f);
+    for (int i = 0; i < _aa.length; _aa[i++] = dummy)
+    {
+      ;
+    }
+    AlignmentAnnotation aa = new AlignmentAnnotation("Contact Matrix",
+            "Contact Matrix", _aa);
+    aa.graph = AlignmentAnnotation.CUSTOMRENDERER;
+    aa.graphMin = cm.getMin();
+    aa.graphMax = cm.getMax();
+    aa.editable = false;
+    // aa.autoCalculated = true;
+    contactmaps.put(aa.annotationId, cm);
+    // TODO: contact matrices could be intra or inter - more than one refseq possible! 
+    if (cm.hasReferenceSeq())
+    {
+      aa.setSequenceRef(cm.getReferenceSeq());
+    }
+    addAnnotation(aa);
+    return aa;
+  }
 }