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