Added proper title to aptx trees
authorkjvdheide <kjvanderheide@dundee.ac.uk>
Thu, 26 Oct 2017 20:57:16 +0000 (21:57 +0100)
committerkjvdheide <kjvanderheide@dundee.ac.uk>
Thu, 26 Oct 2017 20:57:16 +0000 (21:57 +0100)
src/jalview/ext/archaeopteryx/ArchaeopteryxTreeConverter.java

index 780acee..689d5cd 100644 (file)
@@ -3,6 +3,7 @@ package jalview.ext.archaeopteryx;
 import jalview.analysis.TreeBuilder;
 import jalview.datamodel.SequenceI;
 import jalview.math.MatrixI;
+import jalview.util.MessageManager;
 
 import org.forester.phylogeny.Phylogeny;
 import org.forester.phylogeny.PhylogenyNode;
@@ -16,36 +17,38 @@ public class ArchaeopteryxTreeConverter
   private PhylogenyNode rootNode;
 
   protected MatrixI distances;
+  
+  protected TreeBuilder jalviewTree;
+  
+  public String treeTitle;
 
-  {
-    this.aptxTree = new Phylogeny();
-  }
 
 
   public ArchaeopteryxTreeConverter(TreeBuilder calculatedTree)
   {
-    this.sequences = calculatedTree.getSequences();
-    this.distances = calculatedTree.getDistances();
-
-    this.rootNode = new PhylogenyNode();
-    this.rootNode.setName("root");
+    this.jalviewTree = calculatedTree;
+    this.sequences = jalviewTree.getSequences();
+    this.distances = jalviewTree.getDistances();
 
   }
 
-  public ArchaeopteryxTreeConverter(PhylogenyNode treeRoot,
-          TreeBuilder calculatedTree)
+  public Phylogeny buildAptxTree()
   {
-    this(calculatedTree);
-    this.rootNode = treeRoot;
+    this.rootNode = new PhylogenyNode();
+
+    return buildAptxTree(rootNode);
 
   }
 
-  public Phylogeny buildAptxTree()
+  public Phylogeny buildAptxTree(PhylogenyNode treeRoot)
   {
 
+    this.rootNode = treeRoot;
+
+    this.aptxTree = new Phylogeny();
 
-    this.aptxTree.setName(
-            "PLEASE FIX ME reheaheth35yheqhb3q5hyq3bt3q5u4jwqjwuh6");
+    this.treeTitle = generateTreeName();
+    this.aptxTree.setName(treeTitle);
 
     // final NeighborJoiningF nj = NeighborJoiningF.createInstance(false, 5);
 
@@ -83,31 +86,32 @@ public class ArchaeopteryxTreeConverter
    * 
    * @return
    */
-  // public String getPanelTitle()
-  // {
-  // if (treeTitle != null)
-  // {
-  // return treeTitle;
-  // }
-  // else
-  // {
-  // /*
-  // * i18n description of Neighbour Joining or Average Distance method
-  // */
-  // String treecalcnm = MessageManager
-  // .getString("label.tree_calc_" + treeType.toLowerCase());
-  //
-  // /*
-  // * short score model name (long description can be too long)
-  // */
-  // String smn = substitutionMatrix;
-  //
-  // /*
-  // * put them together as <method> Using <model>
-  // */
-  // final String ttl = MessageManager
-  // .formatMessage("label.treecalc_title", treecalcnm, smn);
-  // return ttl;
-  // }
-  // }
+  public String generateTreeName()
+  {
+    if (treeTitle != null) // will currently never happen, loaded tree file will
+                           // take a different path
+    {
+      return treeTitle;
+    }
+    else
+    {
+      /*
+      * i18n description of Neighbour Joining or Average Distance method
+      */
+      String treecalcnm = MessageManager
+              .getString("label.tree_calc_" + jalviewTree.getClass()
+                      .getSimpleName().substring(0, 2).toLowerCase());
+      /*
+      * short score model name (long description can be too long)
+      */
+      String smn = jalviewTree.getScoreModel().getName();
+
+      /*
+      * put them together as <method> Using <model>
+      */
+      final String ttl = MessageManager
+              .formatMessage("label.treecalc_title", treecalcnm, smn);
+      return ttl;
+    }
+  }
 }