Package pal.tree
Class TreeManipulator
- java.lang.Object
-
- 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
Nested Classes Modifier and Type Class Description 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
Fields Modifier and Type Field Description static int
EXPAND_CONSTRUCTION
Construct tree, but convert general multifications to a series of bificationsstatic int
MIMIC_CONSTRUCTION
Construct tree with same multification as originalstatic int
REDUCE_CONSTRUCTION
Construct tree, but convert bificating nodes that appear as multifications (due to very short branchlengths) to multifications
-
Constructor Summary
Constructors Constructor Description TreeManipulator(Node base)
Units will be Units.UNKNOWNTreeManipulator(Node base, int units)
Construct a TreeManipulator based around a normal treeTreeManipulator(Node base, int units, int constructionMode)
Construct a TreeManipulator based around a normal treeTreeManipulator(RootedTreeInterface.Instructee base, int units, int constructionMode)
TreeManipulator(Tree base)
Construct a TreeManipulator based around a normal treeTreeManipulator(Tree base, int constructionMode)
Construct a TreeManipulator based around a normal treeTreeManipulator(UnrootedTreeInterface.Instructee base, int units, int constructionMode)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Node[]
getAllRootedBy(java.lang.String[] outgroupNames)
static Tree[]
getAllRootingsBy(Tree base, java.lang.String[] outgroupNames)
Roots a tree by an outgroupTree[]
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 branchesNode
getDefaultRoot()
Tree
getDefaultRootTree()
Tree[]
getEveryRoot()
static Tree[]
getEveryRoot(Tree base)
Obtains every rooting of a base treeTreeIterator
getEveryRootIterator()
static TreeIterator
getEveryRootIterator(Tree base)
Obtains every rooting of a base treestatic Tree
getMidpointRooted(Tree base)
Returns the mid point rooting of a tree.Node
getMidPointRooted()
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 outgroupstatic Tree
getRootedBy(Tree base, java.lang.String[] outgroupNames, double ingroupBranchLength)
Roots a tree by an outgroupTree
getTreeRootedAbove(Node n)
Tree
getTreeRootedBy(java.lang.String[] outgroupNames)
Tree
getTreeRootedBy(java.lang.String[] outgroupNames, double ingroupBranchLength)
Node
getUnrooted()
return unrooted nodestatic Tree
getUnrooted(Tree base)
Unroots a treeTree
getUnrootedTree()
return unrooted nodevoid
instruct(RootedTreeInterface treeInterface)
void
instruct(UnrootedTreeInterface treeInterface)
void
instructRootedBy(RootedTreeInterface rootedInterface, java.lang.String[] outgroupNames)
-
-
-
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 outgroupingroupBranchLength
- 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 outgroupingroupBranchLength
- 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 interfaceUnrootedTreeInterface.Instructee
-
instruct
public void instruct(RootedTreeInterface treeInterface)
- Specified by:
instruct
in interfaceRootedTreeInterface.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)
-
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 unrootedoutgroupNames
- 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 unrootedoutgroupNames
- 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 unrootedingroupBranchLength
- the maximum length of the branch leading to the ingroup cladeoutgroupNames
- 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
-
-