Merge branch 'develop' into features/JAL-518_justify_seqs_in_region
[jalview.git] / src / jalview / datamodel / SequenceGroup.java
index 5e33229..7e53c46 100755 (executable)
  */
 package jalview.datamodel;
 
-import jalview.analysis.AAFrequency;
-import jalview.analysis.Conservation;
-import jalview.renderer.ResidueShader;
-import jalview.renderer.ResidueShaderI;
-import jalview.schemes.ColourSchemeI;
-
 import java.awt.Color;
 import java.beans.PropertyChangeListener;
 import java.beans.PropertyChangeSupport;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 
+import jalview.analysis.AAFrequency;
+import jalview.analysis.Conservation;
+import jalview.renderer.ResidueShader;
+import jalview.renderer.ResidueShaderI;
+import jalview.schemes.ColourSchemeI;
+
 /**
  * Collects a set contiguous ranges on a set of sequences
  * 
@@ -273,14 +274,6 @@ public class SequenceGroup implements AnnotatedCollectionI
               endRes + 1);
       if (seqipos != null)
       {
-        seqipos.setDescription(seq.getDescription());
-        seqipos.setDBRefs(seq.getDBRefs());
-        seqipos.setSequenceFeatures(seq.getSequenceFeatures());
-        if (seq.getDatasetSequence() != null)
-        {
-          seqipos.setDatasetSequence(seq.getDatasetSequence());
-        }
-
         if (seq.getAnnotation() != null)
         {
           AlignmentAnnotation[] alann = align.getAlignmentAnnotation();
@@ -310,6 +303,12 @@ public class SequenceGroup implements AnnotatedCollectionI
             newannot.restrict(startRes, endRes);
             newannot.setSequenceRef(seqs[ipos]);
             newannot.adjustForAlignment();
+            ContactMatrixI cm = seq
+                    .getContactMatrixFor(seq.getAnnotation()[a]);
+            if (cm != null)
+            {
+              seqs[ipos].addContactListFor(newannot, cm);
+            }
             seqipos.addAlignmentAnnotation(newannot);
           }
         }
@@ -646,7 +645,8 @@ public class SequenceGroup implements AnnotatedCollectionI
     } catch (java.lang.OutOfMemoryError err)
     {
       // TODO: catch OOM
-      System.out.println("Out of memory loading groups: " + err);
+      jalview.bin.Console
+              .outPrintln("Out of memory loading groups: " + err);
     }
     return upd;
   }
@@ -1485,4 +1485,51 @@ public class SequenceGroup implements AnnotatedCollectionI
   {
     return (startRes <= apos && endRes >= apos) && sequences.contains(seq);
   }
+
+  ////
+  //// Contact Matrix Holder Boilerplate
+  ////
+  ContactMapHolder cmholder = new ContactMapHolder();
+
+  @Override
+  public Collection<ContactMatrixI> getContactMaps()
+  {
+    return cmholder.getContactMaps();
+  }
+
+  @Override
+  public ContactMatrixI getContactMatrixFor(AlignmentAnnotation ann)
+  {
+    return cmholder.getContactMatrixFor(ann);
+  }
+
+  @Override
+  public ContactListI getContactListFor(AlignmentAnnotation _aa, int column)
+  {
+    return cmholder.getContactListFor(_aa, column);
+  }
+
+  @Override
+  public AlignmentAnnotation addContactList(ContactMatrixI cm)
+  {
+    AlignmentAnnotation aa = cmholder.addContactList(cm);
+
+    Annotation _aa[] = new Annotation[getWidth()];
+    Annotation dummy = new Annotation(0.0f);
+    for (int i = 0; i < _aa.length; _aa[i++] = dummy)
+    {
+      ;
+    }
+    aa.annotations = _aa;
+    // TODO passing annotations back to context to be added
+    return aa;
+  }
+
+  @Override
+  public void addContactListFor(AlignmentAnnotation annotation,
+          ContactMatrixI cm)
+  {
+    cmholder.addContactListFor(annotation, cm);
+  }
+
 }