|
PhyloSort | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectphylosort.TreeNode
public class TreeNode
A generic tree node that can be root, internal or leaf (operational taxonomic unit "OTU") node.
| Field Summary | |
|---|---|
static float |
DEFAULT_BRANCH_LENGTH
Default branch length |
static int |
DEFAULT_ROOT_ID
Default root node id |
static int |
DEFAULT_ROOT_LEVEL
Default root node level |
static int |
INVALID_NODE_ID
Invalid node id (for example, node not found) |
| Constructor Summary | |
|---|---|
TreeNode()
Default constructor |
|
| Method Summary | |
|---|---|
void |
addChild(TreeNode child)
Adds a child to the tree |
java.lang.String |
depthFirstSearch()
Performs a depth-first search (DFS) starting at the current node |
static TreeNode |
find(TreeNode tree,
java.lang.String label)
Finds a node with a specific label |
java.lang.Iterable<TreeNode> |
getChildren()
Returns an iterator to the children |
int |
getChildrenCount()
Returns the number of children |
int |
getId()
Returns the node id |
java.lang.String |
getLabel()
Returns the label of the node |
java.util.List<TreeNode> |
getLeaves()
Returns all leaves under this node |
float |
getLength()
Returns the length of the node branch |
int |
getLevel()
Returns the node level |
int |
getMaximumId()
Returns the maximum node id under this node |
TreeNode |
getNode(int id)
Retrieve a node using its id |
TreeNode |
getParent()
Returns the parent of the node |
Path |
getPathFromRoot()
Returns an ordered list representing the path from the root to this node. |
TreeNode |
getRoot()
Returns the root of the tree of a node |
java.lang.Iterable<TreeNode> |
getSortedChildren()
Returns an iterorator to the sorted children |
java.lang.String |
getTaxon()
Extracts a taxon string from the node label |
java.lang.String |
getTaxon(boolean labelOnNoMatch)
Extracts a taxon string from the node label |
boolean |
isLeaf()
Returns true if the nodes does not have any children |
boolean |
isRoot()
Returns true if this the root node of the tree (i.e. |
java.lang.Iterable<TreeNode> |
iterator()
Returns depth first search Iterable |
void |
preprocess()
Processes the tree and sets the id and level for each in the tree |
int |
preprocess(int id,
int level)
Processes the tree and sets the id and level for each in the tree |
void |
removeChild(int child)
Removes a child |
void |
removeChild(TreeNode child)
Removes a child |
void |
setId(int id)
Sets the node id |
void |
setLabel(java.lang.String label)
Sets the label of the node |
void |
setLength(float length)
Sets the length of the node branch |
void |
setLevel(int level)
Sets the node level |
void |
setParent(TreeNode parent)
Sets the parent of the node |
int |
size()
Returns the number of terminal nodes in a tree |
java.lang.String |
toString()
Returns a string representation of the tree |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int DEFAULT_ROOT_ID
public static final int DEFAULT_ROOT_LEVEL
public static final float DEFAULT_BRANCH_LENGTH
public static final int INVALID_NODE_ID
| Constructor Detail |
|---|
public TreeNode()
| Method Detail |
|---|
public void addChild(TreeNode child)
child - A child to be addedpublic java.lang.Iterable<TreeNode> getChildren()
public java.lang.Iterable<TreeNode> getSortedChildren()
public int getChildrenCount()
public java.lang.String getLabel()
public void setLabel(java.lang.String label)
label - The label to setpublic float getLength()
public void setLength(float length)
length - The length to setpublic int getId()
public void setId(int id)
id - The node id to setpublic int getLevel()
public void setLevel(int level)
level - The node level to setpublic boolean isLeaf()
true if the nodes does not have any children
otherwise falsepublic TreeNode getParent()
TreeNode The parent of the nodepublic void setParent(TreeNode parent)
parent - The parent to setpublic boolean isRoot()
public java.lang.String depthFirstSearch()
String A string representation of the treepublic java.lang.String toString()
toString in class java.lang.ObjectString A string representation of the treepublic void preprocess()
public int preprocess(int id,
int level)
id - The node id to setlevel - The node level to set
public TreeNode getNode(int id)
id - The node id
TreeNode that has the specified idpublic int getMaximumId()
public Path getPathFromRoot()
public void removeChild(TreeNode child)
child - Child to be removedpublic void removeChild(int child)
child - Child to be removedpublic int size()
public java.util.List<TreeNode> getLeaves()
public java.lang.String getTaxon()
String taxonpublic java.lang.String getTaxon(boolean labelOnNoMatch)
labelOnNoMatch - Flag to return the node label if no match
String taxon
public static TreeNode find(TreeNode tree,
java.lang.String label)
tree - TreeNode root of treelabel - String query label
TreeNode with query labelpublic TreeNode getRoot()
TreeNodepublic java.lang.Iterable<TreeNode> iterator()
Iterable
Iterable
|
PhyloSort | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||