Slight Aptx colour change
[jalview.git] / src / jalview / ext / archaeopteryx / ArchaeopteryxTreeBuilder.java
index 18ac083..1517ed3 100644 (file)
@@ -1,8 +1,113 @@
 package jalview.ext.archaeopteryx;
 
+import jalview.analysis.TreeBuilder;
+import jalview.datamodel.SequenceI;
+import jalview.math.MatrixI;
+
 import org.forester.phylogeny.Phylogeny;
+import org.forester.phylogeny.PhylogenyNode;
 
-public class ArchaeopteryxTreeBuilder extends Phylogeny
+public class ArchaeopteryxTreeBuilder // cannot inherit
+                                                        // TreeBuilder as that
+                                                        // demands the use of
+                                                        // SequenceNode (instead
+                                                        // of PhylogenyNode)
 {
-  
+  protected SequenceI[] sequences;
+
+  private Phylogeny aptxTree;
+
+  private PhylogenyNode rootNode;
+
+  protected MatrixI distances;
+
+  {
+    this.aptxTree = new Phylogeny();
+  }
+
+
+  public ArchaeopteryxTreeBuilder()
+  {
+
+    this.rootNode = new PhylogenyNode();
+
+  }
+
+  public ArchaeopteryxTreeBuilder(PhylogenyNode treeRoot)
+  {
+
+    this.rootNode = treeRoot;
+
+  }
+
+  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);
+
+    //
+    // final Phylogeny phy = nj.execute(JalviewMatrixToForesterMatrix
+    // .convertJalviewToForester(distances));
+
+    return buildAptxTree(sequences);
+
+  }
+
+  public Phylogeny buildAptxTree(SequenceI[] sequences)
+  {
+
+    for (SequenceI sequence : sequences)
+    {
+      PhylogenyNode treeNode = new PhylogenyNode(sequence.getName());
+      rootNode.addAsChild(treeNode);
+
+    }
+
+    aptxTree.setRoot(rootNode);
+    return aptxTree;
+
+  }
+
+
+  /**
+   * Formats a localised title for the tree panel, like
+   * <p>
+   * Neighbour Joining Using BLOSUM62
+   * <p>
+   * For a tree loaded from file, just uses the file name
+   * 
+   * @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;
+  // }
+  // }
 }