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;
-public class ArchaeopteryxTreeBuilder // cannot inherit
- // TreeBuilder as that
- // demands the use of
- // SequenceNode (instead
- // of PhylogenyNode)
+public class ArchaeopteryxTreeConverter
{
protected SequenceI[] sequences;
private PhylogenyNode rootNode;
protected MatrixI distances;
+
+ protected TreeBuilder jalviewTree;
+
+ public String treeTitle;
- {
- this.aptxTree = new Phylogeny();
- }
- public ArchaeopteryxTreeBuilder()
+ public ArchaeopteryxTreeConverter(TreeBuilder calculatedTree)
{
-
- this.rootNode = new PhylogenyNode();
- this.rootNode.setName("root");
+ this.jalviewTree = calculatedTree;
+ this.sequences = jalviewTree.getSequences();
+ this.distances = jalviewTree.getDistances();
}
- public ArchaeopteryxTreeBuilder(PhylogenyNode treeRoot)
+ public Phylogeny buildAptxTree()
{
+ this.rootNode = new PhylogenyNode();
- this.rootNode = treeRoot;
+ return buildAptxTree(rootNode);
}
- public Phylogeny buildAptxTree(TreeBuilder tree)
+ public Phylogeny buildAptxTree(PhylogenyNode treeRoot)
{
- this.sequences = tree.getSequences();
- this.distances = tree.getDistances();
- aptxTree.setName(
- "PLEASE FIX ME reheaheth35yheqhb3q5hyq3bt3q5u4jwqjwuh6");
+ this.rootNode = treeRoot;
+
+ this.aptxTree = new Phylogeny();
+
+ this.treeTitle = generateTreeName();
+ this.aptxTree.setName(treeTitle);
// final NeighborJoiningF nj = NeighborJoiningF.createInstance(false, 5);
*
* @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;
+ }
+ }
}