1 package jalview.ext.archaeopteryx;
3 import jalview.analysis.TreeBuilder;
4 import jalview.datamodel.SequenceI;
5 import jalview.util.MessageManager;
7 import org.forester.evoinference.matrix.distance.DistanceMatrix;
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 DistanceMatrix 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 = MatrixConverter.convertJalviewToForester(
32 jalviewTree.getDistances(), jalviewTree.getSequences());
36 public Phylogeny buildAptxTree()
38 this.rootNode = new PhylogenyNode();
40 return buildAptxTree(rootNode);
44 public Phylogeny buildAptxTree(PhylogenyNode treeRoot)
47 this.rootNode = treeRoot;
49 this.aptxTree = new Phylogeny();
51 this.treeTitle = generateTreeName();
52 this.aptxTree.setName(treeTitle);
54 // final NeighborJoiningF nj = NeighborJoiningF.createInstance(false, 5);
57 // final Phylogeny phy = nj.execute(JalviewMatrixToForesterMatrix
58 // .convertJalviewToForester(distances));
60 return buildAptxTree(sequences);
64 // testing method to be removed
65 public Phylogeny buildAptxTree(SequenceI[] sequences)
68 for (SequenceI sequence : sequences)
70 PhylogenyNode treeNode = new PhylogenyNode(sequence.getName());
71 rootNode.addAsChild(treeNode);
75 aptxTree.setRoot(rootNode);
82 * Formats a localised title for the tree panel, like
84 * Neighbour Joining Using BLOSUM62
86 * For a tree loaded from file, just uses the file name
90 public String generateTreeName()
92 if (treeTitle != null) // will currently never happen, loaded tree file will
93 // take a different path
100 * i18n description of Neighbour Joining or Average Distance method
102 String treecalcnm = MessageManager
103 .getString("label.tree_calc_" + jalviewTree.getClass()
104 .getSimpleName().substring(0, 2).toLowerCase());
106 * short score model name (long description can be too long)
108 String smn = jalviewTree.getScoreModel().getName();
111 * put them together as <method> Using <model>
113 final String ttl = MessageManager
114 .formatMessage("label.treecalc_title", treecalcnm, smn);