pal.tree
Class SimpleTree

java.lang.Object
  |
  +--pal.tree.SimpleTree
All Implemented Interfaces:
Report, java.io.Serializable, Tree, Units
Direct Known Subclasses:
NeighborJoiningTree, ReadTree, UPGMATree

public class SimpleTree
extends java.lang.Object
implements Tree, Report, Units, java.io.Serializable

data structure for a binary/non-binary rooted/unrooted trees

See Also:
Serialized Form

Fields inherited from interface pal.misc.Units
DAYS, EXPECTED_SUBSTITUTIONS, GENERATIONS, MONTHS, YEARS
 
Constructor Summary
SimpleTree()
          constructor tree consisting solely of root node
SimpleTree(Node r)
          constructor taking a root node
SimpleTree(Tree tree)
          clone constructor
SimpleTree(Tree tree, boolean keepIdentifiers)
          clone constructor
SimpleTree(Tree tree, LabelMapping lm)
          clone constructor
 
Method Summary
 void createNodeList()
          count and list external and internal nodes and compute heights of each node
 Node findNode(int num)
          return node with number num (as displayed in ASCII tree)
 java.lang.Object getAttribute(Node node, java.lang.String name)
           
 Node getExternalNode(int i)
          Returns the ith external node.
 int getExternalNodeCount()
          Returns the number of external nodes.
 Node getInternalNode(int i)
          Returns the ith internal node.
 int getInternalNodeCount()
          Returns the number of internal nodes.
 Node getRoot()
          Returns the root node of this tree.
 int getUnits()
          Return the units that this tree is expressed in.
 void report(java.io.PrintWriter out)
          print human readable report (e.g., on parameters and associated model)
 void reroot(int num)
          make node with number num to root node
 void reroot(Node node)
          make provided node the root node
 void setAttribute(Node node, java.lang.String name, java.lang.Object value)
          Sets an named attribute for a given node.
 void setRoot(Node r)
          Set a new node as root node.
 void setUnits(int units)
          Sets the units that this tree is expressed in.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleTree

public SimpleTree()
constructor tree consisting solely of root node

SimpleTree

public SimpleTree(Node r)
constructor taking a root node

SimpleTree

public SimpleTree(Tree tree)
clone constructor

SimpleTree

public SimpleTree(Tree tree,
                  boolean keepIdentifiers)
clone constructor

SimpleTree

public SimpleTree(Tree tree,
                  LabelMapping lm)
clone constructor
Parameters:
lm - - a label mapping use for translating the original label names into something else
Method Detail

getUnits

public final int getUnits()
Return the units that this tree is expressed in.
Specified by:
getUnits in interface Tree

setUnits

public final void setUnits(int units)
Sets the units that this tree is expressed in.
Specified by:
setUnits in interface Tree

getExternalNodeCount

public final int getExternalNodeCount()
Returns the number of external nodes.
Specified by:
getExternalNodeCount in interface Tree
Following copied from interface: pal.tree.Tree
Returns:
a count of the number of external nodes (tips) in this tree.

getExternalNode

public final Node getExternalNode(int i)
Returns the ith external node.
Specified by:
getExternalNode in interface Tree
Following copied from interface: pal.tree.Tree
Returns:
the ith external node in the tree.

getInternalNodeCount

public final int getInternalNodeCount()
Returns the number of internal nodes.
Specified by:
getInternalNodeCount in interface Tree
Following copied from interface: pal.tree.Tree
Returns:
a count of the number of internal nodes (and hence clades) in this tree.

getInternalNode

public final Node getInternalNode(int i)
Returns the ith internal node.
Specified by:
getInternalNode in interface Tree
Following copied from interface: pal.tree.Tree
Returns:
the ith internal node in the tree.

getRoot

public final Node getRoot()
Returns the root node of this tree.
Specified by:
getRoot in interface Tree
Following copied from interface: pal.tree.Tree
Returns:
the root node of this tree.

setRoot

public final void setRoot(Node r)
Set a new node as root node.
Specified by:
setRoot in interface Tree
Following copied from interface: pal.tree.Tree
Parameters:
root - the root node of the tree to construct.

createNodeList

public void createNodeList()
count and list external and internal nodes and compute heights of each node
Specified by:
createNodeList in interface Tree

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

findNode

public Node findNode(int num)
return node with number num (as displayed in ASCII tree)
Parameters:
num - number of node
Returns:
node

setAttribute

public void setAttribute(Node node,
                         java.lang.String name,
                         java.lang.Object value)
Sets an named attribute for a given node.
Specified by:
setAttribute in interface Tree
Parameters:
node - the node whose attribute is being set.
name - the name of the attribute.
value - the new value of the attribute.

getAttribute

public java.lang.Object getAttribute(Node node,
                                     java.lang.String name)
Specified by:
getAttribute in interface Tree
Parameters:
node - the node being interrogated.
name - the name of the attribute of interest.
Returns:
an object representing the named attributed for the numbered node.

reroot

public void reroot(int num)
make node with number num to root node
Parameters:
num - number of node

reroot

public void reroot(Node node)
make provided node the root node
Parameters:
node - the node to make the root.

report

public void report(java.io.PrintWriter out)
Description copied from interface: Report
print human readable report (e.g., on parameters and associated model)
Specified by:
report in interface Report
Following copied from interface: pal.misc.Report
Parameters:
out - output stream