1 package jalview.ext.archaeopteryx;
3 import jalview.analysis.TreeBuilder;
4 import jalview.datamodel.SequenceI;
5 import jalview.math.MatrixI;
6 import jalview.util.MessageManager;
8 import org.forester.phylogeny.Phylogeny;
9 import org.forester.phylogeny.PhylogenyNode;
11 public class ArchaeopteryxTreeConverter
13 protected SequenceI[] sequences;
15 private Phylogeny aptxTree;
17 private PhylogenyNode rootNode;
19 protected MatrixI distances;
21 protected TreeBuilder jalviewTree;
23 public String treeTitle;
27 public ArchaeopteryxTreeConverter(TreeBuilder calculatedTree)
29 this.jalviewTree = calculatedTree;
30 this.sequences = jalviewTree.getSequences();
31 this.distances = jalviewTree.getDistances();
35 public Phylogeny buildAptxTree()
37 this.rootNode = new PhylogenyNode();
39 return buildAptxTree(rootNode);
43 public Phylogeny buildAptxTree(PhylogenyNode treeRoot)
46 this.rootNode = treeRoot;
48 this.aptxTree = new Phylogeny();
50 this.treeTitle = generateTreeName();
51 this.aptxTree.setName(treeTitle);
53 // final NeighborJoiningF nj = NeighborJoiningF.createInstance(false, 5);
56 // final Phylogeny phy = nj.execute(JalviewMatrixToForesterMatrix
57 // .convertJalviewToForester(distances));
59 return buildAptxTree(sequences);
63 // testing method to be removed
64 public Phylogeny buildAptxTree(SequenceI[] sequences)
67 for (SequenceI sequence : sequences)
69 PhylogenyNode treeNode = new PhylogenyNode(sequence.getName());
70 rootNode.addAsChild(treeNode);
74 aptxTree.setRoot(rootNode);
81 * Formats a localised title for the tree panel, like
83 * Neighbour Joining Using BLOSUM62
85 * For a tree loaded from file, just uses the file name
89 public String generateTreeName()
91 if (treeTitle != null) // will currently never happen, loaded tree file will
92 // take a different path
99 * i18n description of Neighbour Joining or Average Distance method
101 String treecalcnm = MessageManager
102 .getString("label.tree_calc_" + jalviewTree.getClass()
103 .getSimpleName().substring(0, 2).toLowerCase());
105 * short score model name (long description can be too long)
107 String smn = jalviewTree.getScoreModel().getName();
110 * put them together as <method> Using <model>
112 final String ttl = MessageManager
113 .formatMessage("label.treecalc_title", treecalcnm, smn);