pal.tree
Class TreeManipulator

java.lang.Object
  extended by pal.tree.TreeManipulator
All Implemented Interfaces:
RootedTreeInterface.Instructee, UnrootedTreeInterface.Instructee

public class TreeManipulator
extends java.lang.Object
implements UnrootedTreeInterface.Instructee, RootedTreeInterface.Instructee


Nested Class Summary
static interface TreeManipulator.BranchAccess
          The branch access objects allow specific operations on a particular branch (refered to as connections internally to confuse and bewilder)
static class TreeManipulator.PALBranchWrapper
           
static class TreeManipulator.PALNodeWrapper
           
 
Field Summary
static int EXPAND_CONSTRUCTION
          Construct tree, but convert general multifications to a series of bifications
static int MIMIC_CONSTRUCTION
          Construct tree with same multification as original
static int REDUCE_CONSTRUCTION
          Construct tree, but convert bificating nodes that appear as multifications (due to very short branchlengths) to multifications
 
Constructor Summary
TreeManipulator(Node base)
          Units will be Units.UNKNOWN
TreeManipulator(Node base, int units)
          Construct a TreeManipulator based around a normal tree
TreeManipulator(Node base, int units, int constructionMode)
          Construct a TreeManipulator based around a normal tree
TreeManipulator(RootedTreeInterface.Instructee base, int units, int constructionMode)
           
TreeManipulator(Tree base)
          Construct a TreeManipulator based around a normal tree
TreeManipulator(Tree base, int constructionMode)
          Construct a TreeManipulator based around a normal tree
TreeManipulator(UnrootedTreeInterface.Instructee base, int units, int constructionMode)
           
 
Method Summary
 Node[] getAllRootedBy(java.lang.String[] outgroupNames)
           
static Tree[] getAllRootingsBy(Tree base, java.lang.String[] outgroupNames)
          Roots a tree by an outgroup
 Tree[] getAllTreesRootedBy(java.lang.String[] outgroupNames)
           
 Node getAsInputRooting()
          A method for recovering the input (construction) tree (with the EXPANSION/MIMIC/REDUCED differences)
 Tree getAsInputRootingTree()
          A method for recovering the input (construction) tree (with the EXPANSION/MIMIC/REDUCED differences)
 TreeManipulator.BranchAccess[] getBranchAccess()
          Obtain access to individual branches
 Node getDefaultRoot()
           
 Tree getDefaultRootTree()
           
 Tree[] getEveryRoot()
           
static Tree[] getEveryRoot(Tree base)
          Obtains every rooting of a base tree
 TreeIterator getEveryRootIterator()
           
static TreeIterator getEveryRootIterator(Tree base)
          Obtains every rooting of a base tree
 Node getMidPointRooted()
           
static Tree getMidpointRooted(Tree base)
          Returns the mid point rooting of a tree.
 Tree getMidPointRootedTree()
           
 Node getRootedAbove(Node base)
           
 Node getRootedBy(java.lang.String[] outgroupNames)
           
 Node getRootedBy(java.lang.String[] outgroupNames, double ingroupBranchLength)
           
static Tree getRootedBy(Tree base, java.lang.String[] outgroupNames)
          Roots a tree by an outgroup
static Tree getRootedBy(Tree base, java.lang.String[] outgroupNames, double ingroupBranchLength)
          Roots a tree by an outgroup
 Tree getTreeRootedAbove(Node n)
           
 Tree getTreeRootedBy(java.lang.String[] outgroupNames)
           
 Tree getTreeRootedBy(java.lang.String[] outgroupNames, double ingroupBranchLength)
           
 Node getUnrooted()
          return unrooted node
static Tree getUnrooted(Tree base)
          Unroots a tree
 Tree getUnrootedTree()
          return unrooted node
 void instruct(RootedTreeInterface treeInterface)
           
 void instruct(UnrootedTreeInterface treeInterface)
           
 void instructRootedBy(RootedTreeInterface rootedInterface, java.lang.String[] outgroupNames)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIMIC_CONSTRUCTION

public static final int MIMIC_CONSTRUCTION
Construct tree with same multification as original

See Also:
Constant Field Values

EXPAND_CONSTRUCTION

public static final int EXPAND_CONSTRUCTION
Construct tree, but convert general multifications to a series of bifications

See Also:
Constant Field Values

REDUCE_CONSTRUCTION

public static final int REDUCE_CONSTRUCTION
Construct tree, but convert bificating nodes that appear as multifications (due to very short branchlengths) to multifications

See Also:
Constant Field Values
Constructor Detail

TreeManipulator

public TreeManipulator(Tree base,
                       int constructionMode)
Construct a TreeManipulator based around a normal tree

Parameters:
base - The base tree, which can be rooted or unrooted (will be treated as unrooted either way)
constructionMode - the way in which the internal tree representation is constructed

TreeManipulator

public TreeManipulator(Tree base)
Construct a TreeManipulator based around a normal tree

Parameters:
base - The base tree, which can be rooted or unrooted (will be treated as unrooted either way)

TreeManipulator

public TreeManipulator(Node base)
Units will be Units.UNKNOWN


TreeManipulator

public TreeManipulator(Node base,
                       int units)
Construct a TreeManipulator based around a normal tree

Parameters:
base - The base tree, which can be rooted or unrooted (will be treated as unrooted either way)
units, - the units of generated trees. Not really of concern if only Node trees built

TreeManipulator

public TreeManipulator(Node base,
                       int units,
                       int constructionMode)
Construct a TreeManipulator based around a normal tree

Parameters:
base - The base tree, which can be rooted or unrooted (will be treated as unrooted either way)
units, - the units of generated trees. Not really of concern if only Node trees built

TreeManipulator

public TreeManipulator(UnrootedTreeInterface.Instructee base,
                       int units,
                       int constructionMode)

TreeManipulator

public TreeManipulator(RootedTreeInterface.Instructee base,
                       int units,
                       int constructionMode)
Method Detail

getMidPointRooted

public Node getMidPointRooted()
Returns:
the MidPoint rooted tree (as root node);

getDefaultRoot

public Node getDefaultRoot()
Returns:
a tree rooted around the node it was originally rooted around (if originally rooted),

getAsInputRooting

public Node getAsInputRooting()
A method for recovering the input (construction) tree (with the EXPANSION/MIMIC/REDUCED differences)

Returns:
An unrooted tree if the input tree was unrooted, otherwise the default rooting

getAsInputRootingTree

public Tree getAsInputRootingTree()
A method for recovering the input (construction) tree (with the EXPANSION/MIMIC/REDUCED differences)

Returns:
An unrooted tree if the input tree was unrooted, otherwise the default rooting

getDefaultRootTree

public Tree getDefaultRootTree()
Returns:
a tree rooted around the node it was originally rooted around (if originally rooted),

getMidPointRootedTree

public Tree getMidPointRootedTree()
Returns:
the MidPoint rooted tree

getUnrooted

public Node getUnrooted()
return unrooted node


getUnrootedTree

public Tree getUnrootedTree()
return unrooted node


getRootedBy

public Node getRootedBy(java.lang.String[] outgroupNames)
Parameters:
outgroupNames - the names of the members of the outgroup
Returns:
the tree rooted by an outgroup defined by the mrca of a set of nodes
Throws:
IllegalArgument - exception if outgroup names does not contain any valid node names

instructRootedBy

public void instructRootedBy(RootedTreeInterface rootedInterface,
                             java.lang.String[] outgroupNames)
Parameters:
outgroupNames - the names of the members of the outgroup
Throws:
IllegalArgument - exception if outgroup names does not contain any valid node names

getRootedBy

public Node getRootedBy(java.lang.String[] outgroupNames,
                        double ingroupBranchLength)
Parameters:
outgroupNames - the names of the members of the outgroup
ingroupBranchLength - the maximum length of the branch leading to the ingroup clade
Returns:
the tree rooted by an outgroup defined by the mrca of a set of nodes
Throws:
IllegalArgument - exception if outgroup names does not contain any valid node names

getAllRootedBy

public Node[] getAllRootedBy(java.lang.String[] outgroupNames)
Parameters:
outgroupNames - the names of the members of the outgroup
Returns:
all the trees rooted by an outgroup defined by the mrca of a set of nodes
Throws:
IllegalArgument - exception if outgroup names does not contain any valid node names

getTreeRootedBy

public Tree getTreeRootedBy(java.lang.String[] outgroupNames)
Parameters:
outgroupNames - the names of the members of the outgroup
Returns:
the tree rooted by an outgroup defined by the mrca of a set of nodes

getTreeRootedBy

public Tree getTreeRootedBy(java.lang.String[] outgroupNames,
                            double ingroupBranchLength)
Parameters:
outgroupNames - the names of the members of the outgroup
ingroupBranchLength - the maximum length of the branch leading to the ingroup clade
Returns:
the tree rooted by an outgroup defined by the mrca of a set of nodes

getAllTreesRootedBy

public Tree[] getAllTreesRootedBy(java.lang.String[] outgroupNames)
Parameters:
outgroupNames - the names of the members of the outgroup
Returns:
all the possible rootings defined by the outgroup

getEveryRootIterator

public TreeIterator getEveryRootIterator()
Returns:
a tree iterator that returns each and every possible root of the base tree (as a new tree object each time)

instruct

public void instruct(UnrootedTreeInterface treeInterface)
Specified by:
instruct in interface UnrootedTreeInterface.Instructee

instruct

public void instruct(RootedTreeInterface treeInterface)
Specified by:
instruct in interface RootedTreeInterface.Instructee

getBranchAccess

public TreeManipulator.BranchAccess[] getBranchAccess()
Obtain access to individual branches

Returns:
an array of branch access objects

getEveryRoot

public Tree[] getEveryRoot()
Returns:
each and every possible root of the base tree

getRootedAbove

public Node getRootedAbove(Node base)
Parameters:
Node - n, a node from the original base tree that this TreeManipulator was constructed on
Throws:
Illegal - argument exception if input node was not in original base tree

getTreeRootedAbove

public Tree getTreeRootedAbove(Node n)
Parameters:
Node - n, a node from the original base tree that this TreeManipulator was constructed on
Throws:
Illegal - argument exception if input node was not in original base tree

getUnrooted

public static final Tree getUnrooted(Tree base)
Unroots a tree

Parameters:
base - The input tree that may or may not be unrooted
Returns:
an unrooted tree (has a trification at base)

getMidpointRooted

public static final Tree getMidpointRooted(Tree base)
Returns the mid point rooting of a tree. This is the rooting that divides the data between the two most distinct taxa

Parameters:
base - The input tree that may or may not be unrooted
Returns:
an unrooted tree (has a trification at base)
See Also:
http://www.mun.ca/biology/scarr/Panda_midpoint_rooting.htm

getEveryRoot

public static final Tree[] getEveryRoot(Tree base)
Obtains every rooting of a base tree

Parameters:
base - The input tree that may or may not be unrooted

getEveryRootIterator

public static final TreeIterator getEveryRootIterator(Tree base)
Obtains every rooting of a base tree

Parameters:
base - The input tree that may or may not be unrooted

getRootedBy

public static final Tree getRootedBy(Tree base,
                                     java.lang.String[] outgroupNames)
Roots a tree by an outgroup

Parameters:
base - The input tree that may or may not be unrooted
outgroupNames - The names of the members of the outgroup. Names not matching taxa in the tree are ignored. The node that is the MCRA of members of the outgroup will influence the rooting.
Throws:
java.lang.IllegalArgumentException - if no members of the tree appear in the outgroup

getRootedBy

public static final Tree getRootedBy(Tree base,
                                     java.lang.String[] outgroupNames,
                                     double ingroupBranchLength)
Roots a tree by an outgroup

Parameters:
base - The input tree that may or may not be unrooted
outgroupNames - The names of the members of the outgroup. Names not matching taxa in the tree are ignored. The node that is the MCRA of members of the outgroup will influence the rooting.
Throws:
java.lang.IllegalArgumentException - if no members of the tree appear in the outgroup

getAllRootingsBy

public static final Tree[] getAllRootingsBy(Tree base,
                                            java.lang.String[] outgroupNames)
Roots a tree by an outgroup

Parameters:
base - The input tree that may or may not be unrooted
ingroupBranchLength - the maximum length of the branch leading to the ingroup clade
outgroupNames - The names of the members of the outgroup. Names not matching taxa in the tree are ignored. The node that is the MCRA of members of the outgroup will influence the rooting.
Returns:
every possible interpretation of rooting a tree by the given outgroup. If the outgroup is well defined there will be only one tree.
Throws:
java.lang.IllegalArgumentException - if no members of the tree appear in the outgroup