1 package jalview.ext.archaeopteryx;
3 import jalview.analysis.TreeBuilder;
4 import jalview.datamodel.SequenceI;
5 import jalview.math.MatrixI;
7 import org.forester.evoinference.distance.NeighborJoiningF;
8 import org.forester.io.parsers.SymmetricalDistanceMatrixParser;
9 import org.forester.msa.Msa;
10 import org.forester.phylogeny.Phylogeny;
11 import org.forester.phylogeny.PhylogenyNode;
13 public class ArchaeopteryxTreeBuilder // cannot inherit
14 // TreeBuilder as that
16 // SequenceNode (instead
19 protected SequenceI[] sequences;
21 private Phylogeny aptxTree;
23 private PhylogenyNode rootNode;
25 protected MatrixI distances;
29 protected SymmetricalDistanceMatrixParser distanceParser = SymmetricalDistanceMatrixParser
33 public ArchaeopteryxTreeBuilder()
36 this.rootNode = new PhylogenyNode();
37 this.aptxTree = new Phylogeny();
41 public ArchaeopteryxTreeBuilder(PhylogenyNode treeRoot)
44 this.rootNode = treeRoot;
45 this.aptxTree = new Phylogeny();
49 public Phylogeny buildAptxTree(TreeBuilder tree)
51 this.sequences = tree.getSequences();
53 "PLEASE FIX ME reheaheth35yheqhb3q5hyq3bt3q5u4jwqjwuh6");
55 final NeighborJoiningF nj = NeighborJoiningF.createInstance(false, 5);
56 distances = tree.getDistances();
60 final Phylogeny phy = nj.execute(JalviewMatrixToForesterMatrix
61 .convertJalviewToForester(distances));
63 return buildAptxTree(sequences);
67 public Phylogeny buildAptxTree(SequenceI[] sequences)
70 for (SequenceI sequence : sequences)
72 PhylogenyNode treeNode = new PhylogenyNode(sequence.getName());
73 rootNode.addAsChild(treeNode);
77 aptxTree.setRoot(rootNode);
84 * Formats a localised title for the tree panel, like
86 * Neighbour Joining Using BLOSUM62
88 * For a tree loaded from file, just uses the file name
92 // public String getPanelTitle()
94 // if (treeTitle != null)
101 // * i18n description of Neighbour Joining or Average Distance method
103 // String treecalcnm = MessageManager
104 // .getString("label.tree_calc_" + treeType.toLowerCase());
107 // * short score model name (long description can be too long)
109 // String smn = substitutionMatrix;
112 // * put them together as <method> Using <model>
114 // final String ttl = MessageManager
115 // .formatMessage("label.treecalc_title", treecalcnm, smn);