Added tree building (without distances yet)
[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.io.parsers.SymmetricalDistanceMatrixParser;
8 import org.forester.msa.Msa;
9 import org.forester.phylogeny.Phylogeny;
10 import org.forester.phylogeny.PhylogenyNode;
11
12 public class ArchaeopteryxTreeBuilder // cannot inherit
13                                                         // TreeBuilder as that
14                                                         // demands the use of
15                                                         // SequenceNode (instead
16                                                         // of PhylogenyNode)
17 {
18   protected SequenceI[] sequences;
19
20   private Phylogeny aptxTree;
21
22   private PhylogenyNode rootNode;
23
24   protected MatrixI distances;
25
26   protected Msa msa;
27
28   protected SymmetricalDistanceMatrixParser distanceParser = SymmetricalDistanceMatrixParser
29           .createInstance();
30
31
32   public ArchaeopteryxTreeBuilder()
33   {
34
35     this.rootNode = new PhylogenyNode();
36     this.aptxTree = new Phylogeny();
37
38   }
39
40   public ArchaeopteryxTreeBuilder(PhylogenyNode treeRoot)
41   {
42
43     this.rootNode = treeRoot;
44     this.aptxTree = new Phylogeny();
45
46   }
47
48   public Phylogeny buildAptxTree(TreeBuilder tree)
49   {
50   this.sequences= tree.getSequences();
51     return buildAptxTree(sequences);
52
53   }
54
55   public Phylogeny buildAptxTree(SequenceI[] sequences)
56   {
57
58     for (SequenceI sequence : sequences)
59     {
60       PhylogenyNode treeNode = new PhylogenyNode();
61       treeNode.setName(sequence.getName());
62       rootNode.addAsChild(treeNode);
63
64     }
65     aptxTree.setRoot(rootNode);
66     return aptxTree;
67
68   }
69 }