JAL-2805 Added tree building interface
authorkjvdheide <kjvanderheide@dundee.ac.uk>
Mon, 13 Nov 2017 19:34:25 +0000 (19:34 +0000)
committerkjvdheide <kjvanderheide@dundee.ac.uk>
Mon, 13 Nov 2017 19:34:25 +0000 (19:34 +0000)
src/jalview/ext/archaeopteryx/ArchaeopteryxTreeBuilder.java
src/jalview/ext/archaeopteryx/ExternalTreeBuilderI.java [new file with mode: 0644]

index 21a4e30..02ecdf0 100644 (file)
@@ -25,7 +25,8 @@ import org.forester.phylogeny.data.Sequence;
  * @author kjvanderheide
  *
  */
-public class ArchaeopteryxTreeConverter
+public class ArchaeopteryxTreeBuilder
+        implements ExternalTreeBuilderI<Phylogeny, PhylogenyNode>
 {
   protected final SequenceI[] sequences;
 
@@ -43,7 +44,7 @@ public class ArchaeopteryxTreeConverter
 
   private final Map<PhylogenyNode, SequenceI> nodesBoundAlignment;
 
-  public ArchaeopteryxTreeConverter(final TreeBuilder calculatedTree)
+  public ArchaeopteryxTreeBuilder(final TreeBuilder calculatedTree)
   {
     jalviewTree = calculatedTree;
     sequences = jalviewTree.getSequences();
@@ -57,7 +58,8 @@ public class ArchaeopteryxTreeConverter
 
   }
 
-  public Phylogeny buildAptxTree(final PhylogenyNode treeRoot)
+  @Override
+  public Phylogeny buildTree(final PhylogenyNode treeRoot)
   {
 
     if (treeRoot != null)
@@ -65,14 +67,15 @@ public class ArchaeopteryxTreeConverter
       rootNode = treeRoot;
     }
 
-    buildAptxTree();
+    buildTree();
 
     return aptxTree;
 
   }
 
 
-  public Phylogeny buildAptxTree()
+  @Override
+  public Phylogeny buildTree()
   {
 
     for (SequenceI sequence : sequences)
@@ -98,11 +101,13 @@ public class ArchaeopteryxTreeConverter
 
   }
 
+  @Override
   public Map<SequenceI, PhylogenyNode> getAlignmentBoundNodes()
   {
     return alignmentBoundNodes;
   }
 
+  @Override
   public Map<PhylogenyNode, SequenceI> getNodesBoundAlignment()
   {
     return nodesBoundAlignment;
@@ -122,6 +127,7 @@ public class ArchaeopteryxTreeConverter
    * 
    * @return
    */
+  @Override
   public String generateTreeName() // Move this and add selection region to the
                                    // title when applicable
   {
diff --git a/src/jalview/ext/archaeopteryx/ExternalTreeBuilderI.java b/src/jalview/ext/archaeopteryx/ExternalTreeBuilderI.java
new file mode 100644 (file)
index 0000000..f27117d
--- /dev/null
@@ -0,0 +1,19 @@
+package jalview.ext.archaeopteryx;
+
+import jalview.datamodel.SequenceI;
+
+import java.util.Map;
+
+interface ExternalTreeBuilderI<T, N>
+{
+  public T buildTree(N treeRoot);
+
+  public T buildTree();
+
+  public Map<SequenceI, N> getAlignmentBoundNodes();
+
+  public Map<N, SequenceI> getNodesBoundAlignment();
+
+  public String generateTreeName();
+
+}