From d25d9de2559ae1908228f7555aeb4de7f3939cf2 Mon Sep 17 00:00:00 2001 From: kjvdheide Date: Tue, 9 Jan 2018 10:21:01 +0000 Subject: [PATCH] JAL-2805 added getter in trees for retrieving all node sequences --- src/jalview/ext/archaeopteryx/Tree.java | 28 ++++++++++++++++++++++++++++ src/jalview/ext/treeviewer/TreeI.java | 6 ++++++ 2 files changed, 34 insertions(+) diff --git a/src/jalview/ext/archaeopteryx/Tree.java b/src/jalview/ext/archaeopteryx/Tree.java index 345820d..76808e8 100644 --- a/src/jalview/ext/archaeopteryx/Tree.java +++ b/src/jalview/ext/archaeopteryx/Tree.java @@ -1,5 +1,6 @@ package jalview.ext.archaeopteryx; +import jalview.datamodel.SequenceI; import jalview.ext.treeviewer.TreeFrameI; import jalview.ext.treeviewer.TreeI; import jalview.ext.treeviewer.TreeNodeI; @@ -23,6 +24,7 @@ public class Tree implements TreeI { tree = new Phylogeny(); } + public Tree(Phylogeny aptxTree) { tree = aptxTree; @@ -150,5 +152,31 @@ public class Tree implements TreeI instanceTitle)); } + @Override + public SequenceI[] getNodeSequences() + { + SequenceI[] treeSeqs = new SequenceI[tree.getNodeCount()]; + Iterator iter = iterateInPreOrder(); + int i = 0; + while (iter.hasNext()) + { + SequenceI nodeSeq = iter.next().getSequence(); + treeSeqs[i++] = nodeSeq; + } + return treeSeqs; + } + + @Override + public TreeNodeI[] getAllNodes() + { + TreeNodeI[] treeNodes = new TreeNodeI[tree.getNodeCount()]; + Iterator iter = iterateInPreOrder(); + int i = 0; + while (iter.hasNext()) + { + treeNodes[i++] = iter.next(); + } + return treeNodes; + } } diff --git a/src/jalview/ext/treeviewer/TreeI.java b/src/jalview/ext/treeviewer/TreeI.java index 0ebf991..9bc20da 100644 --- a/src/jalview/ext/treeviewer/TreeI.java +++ b/src/jalview/ext/treeviewer/TreeI.java @@ -1,5 +1,7 @@ package jalview.ext.treeviewer; +import jalview.datamodel.SequenceI; + import java.util.Iterator; public interface TreeI @@ -10,8 +12,12 @@ public interface TreeI public TreeNodeI getFurthestNode(); + public TreeNodeI[] getAllNodes(); + public String[] getAllLeafNames(); + public SequenceI[] getNodeSequences(); + public void setTreeName(String treeTitle); public void setRerootable(boolean b); -- 1.7.10.2