JAL-4134 store/restore Newick tree for PAE annotation row
[jalview.git] / src / jalview / gui / AlignFrame.java
index 7b310b1..92a18ec 100644 (file)
@@ -155,6 +155,7 @@ import jalview.viewmodel.AlignmentViewport;
 import jalview.viewmodel.ViewportRanges;
 import jalview.ws.DBRefFetcher;
 import jalview.ws.DBRefFetcher.FetchFinishedListenerI;
+import jalview.ws.datamodel.alphafold.PAEContactMatrix;
 import jalview.ws.jws1.Discoverer;
 import jalview.ws.jws2.Jws2Discoverer;
 import jalview.ws.jws2.jabaws2.Jws2Instance;
@@ -4131,6 +4132,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     return showNewickTree(nf, treeTitle, null, w, h, x, y);
   }
 
+
   /**
    * Add a treeviewer for the tree extracted from a Newick file object to the
    * current alignment view
@@ -4181,6 +4183,56 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     return tp;
   }
 
+
+  public void showContactMapTree(AlignmentAnnotation aa,
+          PAEContactMatrix cm)
+  {
+    int x = 4, y = 5;
+    int w = 400, h = 500;
+    
+    try
+    {
+      NewickFile fin = new NewickFile(
+              new FileParse(cm.getNewick(), DataSourceType.PASTE));
+      String title = "PAE Matrix Tree for "
+              + cm.getReferenceSeq().getDisplayId(false);
+
+      showColumnWiseTree(fin, aa, title, w,h, x,y);
+    } catch (Throwable xx)
+    {
+      Console.error("Unexpected exception showing tree for contact matrix",
+              xx);
+    }
+  }
+  public TreePanel showColumnWiseTree(NewickFile nf, AlignmentAnnotation aa, String treeTitle,
+           int w, int h, int x, int y)
+  {
+      try
+      {
+        nf.parse();
+        if (nf.getTree() == null)
+        {
+          return null;
+        }
+        TreePanel tp = new TreePanel(alignPanel, nf, aa, title);
+
+        tp.setSize(w, h);
+
+        if (x > 0 && y > 0)
+        {
+          tp.setLocation(x, y);
+        }
+
+        Desktop.addInternalFrame(tp, title, w, h);
+        return tp;
+      } catch (Throwable xx)
+      {
+        Console.error("Unexpected exception showing tree for contact matrix",
+                xx);
+      }
+      return null;
+  }
+  
   private boolean buildingMenu = false;
 
   /**
@@ -5930,6 +5982,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   {
     return lastFeatureSettingsBounds;
   }
+
 }
 
 class PrintThread extends Thread