forester as submodule with InternalFrame + start of distance conversion
[jalview.git] / src / jalview / ext / archaeopteryx / ArchaeopteryxTreeBuilder.java
1 package jalview.ext.archaeopteryx;
2
3 import jalview.analysis.TreeBuilder;
4 import jalview.datamodel.SequenceI;
5 import jalview.math.MatrixI;
6
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;
12
13 public class ArchaeopteryxTreeBuilder // cannot inherit
14                                                         // TreeBuilder as that
15                                                         // demands the use of
16                                                         // SequenceNode (instead
17                                                         // of PhylogenyNode)
18 {
19   protected SequenceI[] sequences;
20
21   private Phylogeny aptxTree;
22
23   private PhylogenyNode rootNode;
24
25   protected MatrixI distances;
26
27   protected Msa msa;
28
29   protected SymmetricalDistanceMatrixParser distanceParser = SymmetricalDistanceMatrixParser
30           .createInstance();
31
32
33   public ArchaeopteryxTreeBuilder()
34   {
35
36     this.rootNode = new PhylogenyNode();
37     this.aptxTree = new Phylogeny();
38
39   }
40
41   public ArchaeopteryxTreeBuilder(PhylogenyNode treeRoot)
42   {
43
44     this.rootNode = treeRoot;
45     this.aptxTree = new Phylogeny();
46
47   }
48
49   public Phylogeny buildAptxTree(TreeBuilder tree)
50   {
51     this.sequences = tree.getSequences();
52     aptxTree.setName(
53             "PLEASE FIX ME reheaheth35yheqhb3q5hyq3bt3q5u4jwqjwuh6");
54
55     final NeighborJoiningF nj = NeighborJoiningF.createInstance(false, 5);
56     distances = tree.getDistances();
57
58
59
60     // final Phylogeny phy = nj.execute(JalviewMatrixToForesterMatrix
61     // .convertJalviewToForester(distances));
62
63     return buildAptxTree(sequences);
64
65   }
66
67   public Phylogeny buildAptxTree(SequenceI[] sequences)
68   {
69
70     for (SequenceI sequence : sequences)
71     {
72       PhylogenyNode treeNode = new PhylogenyNode(sequence.getName());
73       rootNode.addAsChild(treeNode);
74
75     }
76
77     aptxTree.setRoot(rootNode);
78     return aptxTree;
79
80   }
81
82
83   /**
84    * Formats a localised title for the tree panel, like
85    * <p>
86    * Neighbour Joining Using BLOSUM62
87    * <p>
88    * For a tree loaded from file, just uses the file name
89    * 
90    * @return
91    */
92   // public String getPanelTitle()
93   // {
94   // if (treeTitle != null)
95   // {
96   // return treeTitle;
97   // }
98   // else
99   // {
100   // /*
101   // * i18n description of Neighbour Joining or Average Distance method
102   // */
103   // String treecalcnm = MessageManager
104   // .getString("label.tree_calc_" + treeType.toLowerCase());
105   //
106   // /*
107   // * short score model name (long description can be too long)
108   // */
109   // String smn = substitutionMatrix;
110   //
111   // /*
112   // * put them together as <method> Using <model>
113   // */
114   // final String ttl = MessageManager
115   // .formatMessage("label.treecalc_title", treecalcnm, smn);
116   // return ttl;
117   // }
118   // }
119 }