JAL-2381 copy and paste sequence also copies contact matrix annotation
[jalview.git] / src / jalview / gui / AlignFrame.java
index 71905c1..48927bb 100644 (file)
@@ -112,6 +112,7 @@ import jalview.datamodel.AlignmentI;
 import jalview.datamodel.AlignmentOrder;
 import jalview.datamodel.AlignmentView;
 import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.ContactMatrixI;
 import jalview.datamodel.HiddenColumns;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.SeqCigar;
@@ -2303,10 +2304,15 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
                         .intValue();
               }
             }
-            alignment.addAnnotation(sequences[i].getAnnotation()[a]); // annotation
-            // was
-            // duplicated
-            // earlier
+            // annotation was duplicated earlier
+            alignment.addAnnotation(sequences[i].getAnnotation()[a]);
+            // take care of contact matrix too
+            ContactMatrixI cm=sequences[i].getContactMatrixFor(sequences[i].getAnnotation()[a]);
+            if (cm!=null)
+            {
+              alignment.addContactListFor(sequences[i].getAnnotation()[a], cm);
+            }
+            
             alignment.setAnnotationIndex(sequences[i].getAnnotation()[a],
                     a);
           }
@@ -4202,7 +4208,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   }
 
   public void showContactMapTree(AlignmentAnnotation aa,
-          PAEContactMatrix cm)
+          ContactMatrixI cm)
   {
     int x = 4, y = 5;
     int w = 400, h = 500;
@@ -4211,8 +4217,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     {
       NewickFile fin = new NewickFile(
               new FileParse(cm.getNewick(), DataSourceType.PASTE));
-      String title = "PAE Matrix Tree for "
-              + cm.getReferenceSeq().getDisplayId(false);
+      String title = cm.getAnnotLabel() + " " + cm.getTreeMethod() + " tree"
+              + aa.sequenceRef != null
+                      ? (" for " + aa.sequenceRef.getDisplayId(false))
+                      : "";
 
       showColumnWiseTree(fin, aa, title, w, h, x, y);
     } catch (Throwable xx)