moved Aptx creation from CalculationChooser to separate class
authorkjvdheide <kjvanderheide@dundee.ac.uk>
Thu, 12 Oct 2017 10:26:17 +0000 (11:26 +0100)
committerkjvdheide <kjvanderheide@dundee.ac.uk>
Thu, 12 Oct 2017 10:26:17 +0000 (11:26 +0100)
src/jalview/ext/archaeopteryx/ArchaeopteryxFrame.java [new file with mode: 0644]
src/jalview/ext/archaeopteryx/ArchaeopteryxTreeBuilder.java
src/jalview/gui/CalculationChooser.java

diff --git a/src/jalview/ext/archaeopteryx/ArchaeopteryxFrame.java b/src/jalview/ext/archaeopteryx/ArchaeopteryxFrame.java
new file mode 100644 (file)
index 0000000..d0728c4
--- /dev/null
@@ -0,0 +1,63 @@
+package jalview.ext.archaeopteryx;
+
+import jalview.analysis.TreeBuilder;
+import jalview.gui.Desktop;
+
+import java.awt.Dimension;
+
+import org.forester.archaeopteryx.Archaeopteryx;
+import org.forester.archaeopteryx.MainFrame;
+import org.forester.phylogeny.Phylogeny;
+
+public class ArchaeopteryxFrame
+{
+
+  public static void createInstance(Phylogeny aptxTree)
+  {
+    new ArchaeopteryxFrame(aptxTree);
+
+  }
+
+  public static void createInstance(
+          TreeBuilder calculatedTree)
+  {
+    new ArchaeopteryxFrame(calculatedTree);
+
+  }
+
+  private ArchaeopteryxFrame(Phylogeny aptxTree)
+  {
+    MainFrame aptxApp = Archaeopteryx.createApplication(aptxTree);
+    start(aptxApp);
+
+  }
+
+  private ArchaeopteryxFrame(TreeBuilder calculatedTree)
+  {
+    ArchaeopteryxTreeBuilder aptxTreeBuilder = new ArchaeopteryxTreeBuilder();
+    Phylogeny aptxTree = aptxTreeBuilder.buildAptxTree(calculatedTree);
+    MainFrame aptxApp = Archaeopteryx.createApplication(aptxTree);
+    start(aptxApp);
+  }
+
+
+
+  public void start(MainFrame aptxApp)
+  {
+    int width = 400;
+    int height = 550;
+    aptxApp.setMinimumSize(new Dimension(width - 30, height - 50)); // doesn't
+                                                                    // work
+                                                                    // as it
+                                                                    // gets
+                                                                    // overridden
+                                                                    // during
+                                                                    // addInternalFrame?
+
+    Desktop.addInternalFrame(aptxApp, "Archaeopteryx Tree View", width,
+            height, true);
+
+  }
+
+
+}
index 82f215a..1517ed3 100644 (file)
@@ -4,9 +4,6 @@ import jalview.analysis.TreeBuilder;
 import jalview.datamodel.SequenceI;
 import jalview.math.MatrixI;
 
-import org.forester.evoinference.distance.NeighborJoiningF;
-import org.forester.io.parsers.SymmetricalDistanceMatrixParser;
-import org.forester.msa.Msa;
 import org.forester.phylogeny.Phylogeny;
 import org.forester.phylogeny.PhylogenyNode;
 
@@ -24,17 +21,15 @@ public class ArchaeopteryxTreeBuilder // cannot inherit
 
   protected MatrixI distances;
 
-  protected Msa msa;
-
-  protected SymmetricalDistanceMatrixParser distanceParser = SymmetricalDistanceMatrixParser
-          .createInstance();
+  {
+    this.aptxTree = new Phylogeny();
+  }
 
 
   public ArchaeopteryxTreeBuilder()
   {
 
     this.rootNode = new PhylogenyNode();
-    this.aptxTree = new Phylogeny();
 
   }
 
@@ -42,23 +37,22 @@ public class ArchaeopteryxTreeBuilder // cannot inherit
   {
 
     this.rootNode = treeRoot;
-    this.aptxTree = new Phylogeny();
 
   }
 
   public Phylogeny buildAptxTree(TreeBuilder tree)
   {
     this.sequences = tree.getSequences();
+    this.distances = tree.getDistances();
+
     aptxTree.setName(
             "PLEASE FIX ME reheaheth35yheqhb3q5hyq3bt3q5u4jwqjwuh6");
 
-    final NeighborJoiningF nj = NeighborJoiningF.createInstance(false, 5);
-    distances = tree.getDistances();
-
-
+    // final NeighborJoiningF nj = NeighborJoiningF.createInstance(false, 5);
 
-    final Phylogeny phy = nj.execute(JalviewMatrixToForesterMatrix
-            .convertJalviewToForester(distances));
+    //
+    // final Phylogeny phy = nj.execute(JalviewMatrixToForesterMatrix
+    // .convertJalviewToForester(distances));
 
     return buildAptxTree(sequences);
 
index a3878d7..5466121 100644 (file)
@@ -28,7 +28,7 @@ import jalview.analysis.scoremodels.SimilarityParams;
 import jalview.api.analysis.ScoreModelI;
 import jalview.api.analysis.SimilarityParamsI;
 import jalview.datamodel.SequenceGroup;
-import jalview.ext.archaeopteryx.ArchaeopteryxTreeBuilder;
+import jalview.ext.archaeopteryx.ArchaeopteryxFrame;
 import jalview.util.MessageManager;
 
 import java.awt.BorderLayout;
@@ -63,10 +63,6 @@ import javax.swing.JRadioButton;
 import javax.swing.event.InternalFrameAdapter;
 import javax.swing.event.InternalFrameEvent;
 
-import org.forester.archaeopteryx.Archaeopteryx;
-import org.forester.archaeopteryx.MainFrame;
-import org.forester.phylogeny.Phylogeny;
-
 /**
  * A dialog where a user can choose and action Tree or PCA calculation options
  */
@@ -483,30 +479,20 @@ public class CalculationChooser extends JPanel
       TreeBuilder calculatedTree = treeCalculator
               .makeTree(af.getViewport());
       TreeModel tree = new TreeModel(calculatedTree);
-      openTreePanel(tree, treeAlgo, substitutionMatrix);
 
-      ArchaeopteryxTreeBuilder aptxTreeBuilder = new ArchaeopteryxTreeBuilder();
-      Phylogeny aptxTree = aptxTreeBuilder.buildAptxTree(calculatedTree);
-      MainFrame aptxFrame = Archaeopteryx.createApplication(aptxTree);
+      openTreePanel(tree, treeAlgo, substitutionMatrix);
+      ArchaeopteryxFrame.createInstance(calculatedTree);
 
-      int width = 400;
-      int height = 550;
-      aptxFrame.setMinimumSize(new Dimension(width - 30, height - 50)); // doesn't
-                                                                        // work
-                                                                        // as it
-                                                                        // gets
-                                                                        // overridden
-                                                                        // during
-                                                                        // addInternalFrame?
 
-      Desktop.addInternalFrame(aptxFrame, "Archaeopteryx Tree View",
-              width, height, true);
 
     }
 
     // closeFrame();
   }
 
+
+
+
   protected String determineTreeAlgo() // to be modified & expanded
   {
     String treeAlgorithm = neighbourJoining.isSelected()