Custom aptx configuration 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   public Phylogeny buildAptxTree(SequenceI[] sequences)
62   {
63
64     for (SequenceI sequence : sequences)
65     {
66       PhylogenyNode treeNode = new PhylogenyNode(sequence.getName());
67       rootNode.addAsChild(treeNode);
68
69     }
70
71     aptxTree.setRoot(rootNode);
72     return aptxTree;
73
74   }
75
76
77   /**
78    * Formats a localised title for the tree panel, like
79    * <p>
80    * Neighbour Joining Using BLOSUM62
81    * <p>
82    * For a tree loaded from file, just uses the file name
83    * 
84    * @return
85    */
86   // public String getPanelTitle()
87   // {
88   // if (treeTitle != null)
89   // {
90   // return treeTitle;
91   // }
92   // else
93   // {
94   // /*
95   // * i18n description of Neighbour Joining or Average Distance method
96   // */
97   // String treecalcnm = MessageManager
98   // .getString("label.tree_calc_" + treeType.toLowerCase());
99   //
100   // /*
101   // * short score model name (long description can be too long)
102   // */
103   // String smn = substitutionMatrix;
104   //
105   // /*
106   // * put them together as <method> Using <model>
107   // */
108   // final String ttl = MessageManager
109   // .formatMessage("label.treecalc_title", treecalcnm, smn);
110   // return ttl;
111   // }
112   // }
113 }