Tests for Aptx tree created from a Phylogeny object added
[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
34   }
35
36   public ArchaeopteryxTreeBuilder(PhylogenyNode treeRoot)
37   {
38
39     this.rootNode = treeRoot;
40
41   }
42
43   public Phylogeny buildAptxTree(TreeBuilder tree)
44   {
45     this.sequences = tree.getSequences();
46     this.distances = tree.getDistances();
47
48     aptxTree.setName(
49             "PLEASE FIX ME reheaheth35yheqhb3q5hyq3bt3q5u4jwqjwuh6");
50
51     // final NeighborJoiningF nj = NeighborJoiningF.createInstance(false, 5);
52
53     //
54     // final Phylogeny phy = nj.execute(JalviewMatrixToForesterMatrix
55     // .convertJalviewToForester(distances));
56
57     return buildAptxTree(sequences);
58
59   }
60
61   // testing method to be removed
62   public Phylogeny buildAptxTree(SequenceI[] sequences)
63   {
64
65     for (SequenceI sequence : sequences)
66     {
67       PhylogenyNode treeNode = new PhylogenyNode(sequence.getName());
68       rootNode.addAsChild(treeNode);
69
70     }
71
72     aptxTree.setRoot(rootNode);
73     return aptxTree;
74
75   }
76
77
78   /**
79    * Formats a localised title for the tree panel, like
80    * <p>
81    * Neighbour Joining Using BLOSUM62
82    * <p>
83    * For a tree loaded from file, just uses the file name
84    * 
85    * @return
86    */
87   // public String getPanelTitle()
88   // {
89   // if (treeTitle != null)
90   // {
91   // return treeTitle;
92   // }
93   // else
94   // {
95   // /*
96   // * i18n description of Neighbour Joining or Average Distance method
97   // */
98   // String treecalcnm = MessageManager
99   // .getString("label.tree_calc_" + treeType.toLowerCase());
100   //
101   // /*
102   // * short score model name (long description can be too long)
103   // */
104   // String smn = substitutionMatrix;
105   //
106   // /*
107   // * put them together as <method> Using <model>
108   // */
109   // final String ttl = MessageManager
110   // .formatMessage("label.treecalc_title", treecalcnm, smn);
111   // return ttl;
112   // }
113   // }
114 }