|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectTrees.Tree
public class Tree
Represents a phylogenetic tree. Trees are defined as a list of Branch
.
Nodes are defined by a String
Constructor Summary | |
---|---|
Tree(java.util.List<Branch> branches)
Creates a tree from a list of branches |
|
Tree(Tree old,
Parameters p)
Duplicates a tree topology while replacing branch lengths using the appropiate parameter |
Method Summary | |
---|---|
static Tree |
fromFile(java.io.File f)
Creates a tree from a file containing a Newick string |
static Tree |
fromNewickString(java.lang.String newick)
Creates a tree from a newick string |
Branch |
getBranchByChild(java.lang.String child)
Gets the branch which has the given node as the child node |
java.util.List<Branch> |
getBranches()
Gets a list of branches. |
java.util.Set<Branch> |
getBranchesByParent(java.lang.String parent)
Gets the set of branches which have the passed node as a parent |
java.util.List<Branch> |
getBranchesReversed()
Gets the branches in the reverse order to that returned by getBranches() . |
java.util.List<java.lang.String> |
getInternal()
Gets a list of internal nodes. |
java.util.List<java.lang.String> |
getLeaves()
Gets a list of leaves |
double |
getLength()
Gets the length of the tree |
int |
getNumberBranches()
Gets the number of branches |
Parameters |
getParameters()
Returns a Parameters object containing a parameter for each branch length. |
Parameters |
getParametersForEstimation()
Returns a Parameters object containing a parameter for each branch length. |
java.lang.String |
getParent(java.lang.String child)
Gets the parent node of the given node |
java.lang.String |
getRoot()
Get the root node |
int |
getSize()
Gets the size of the tree, that is the number of taxa |
boolean |
isExternal(Branch b)
Tests whether the given branch is an external branch (i.e. |
java.util.Iterator<Branch> |
iterator()
|
Tree |
midPointRoot(java.lang.String newRootName)
Mid point roots the tree and returns a new tree |
java.lang.String |
MRCA(java.util.List<java.lang.String> leaves)
Returns the most recent common ancestor of a set of leaves |
Tree |
scaledTo(double length)
Returns a new tree where the lengths are scales so the total length is different |
void |
toFile(java.io.File f)
Writes the tree to a file in Newick format. |
void |
toFile(java.io.File f,
boolean nameInternal)
Write the tree to a file in Newick format. |
java.lang.String |
toString()
|
java.lang.String |
toString(boolean nameInternal)
Returns a textual representation of the tree in Newick format |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Tree(java.util.List<Branch> branches) throws TreeException
branches
- A list of branches
TreeException
- Thrown if the list of branches passed do not represent
a treepublic Tree(Tree old, Parameters p) throws Parameters.ParameterException
old
- The old treep
- The parameters used for the new branch lengths
Parameters.ParameterException
- Thrown if there is a problem
with the parameters, e.g. a required parameter not existing.Method Detail |
---|
public java.util.List<Branch> getBranches()
public java.util.Iterator<Branch> iterator()
iterator
in interface java.lang.Iterable<Branch>
public java.util.List<java.lang.String> getInternal()
public java.util.List<java.lang.String> getLeaves()
public java.lang.String getRoot()
public double getLength() throws TreeException
TreeException
- Thrown if the tree does not have branch lengths
associated with itpublic Parameters getParameters() throws TreeException
TreeException
- Thrown if the tree does not have branch lengthspublic Parameters getParametersForEstimation()
public int getSize()
public int getNumberBranches()
public Branch getBranchByChild(java.lang.String child) throws TreeException
child
- The child node
TreeException
- Thrown if the node does not exist or the root node
is passedpublic java.util.Set<Branch> getBranchesByParent(java.lang.String parent) throws TreeException
parent
- The parent node
TreeException
- If the node does not exist in the tree or is a leafpublic java.lang.String getParent(java.lang.String child) throws TreeException
child
- The child node
TreeException
- If the node does not exist or is the rootpublic Tree scaledTo(double length) throws TreeException
length
- The new total length
TreeException
- Thrown if the tree does not have branch lengthspublic Tree midPointRoot(java.lang.String newRootName) throws TreeException
newRootName
- The name of the new root node
TreeException
- If there is a problem with the tree, e.g. no branch
lengthspublic java.lang.String MRCA(java.util.List<java.lang.String> leaves) throws TreeException
leaves
- Set of leaves to calculate the MRCA for
TreeException
- Thrown if a leave does not existpublic boolean isExternal(Branch b)
b
- The branch to test
public java.util.List<Branch> getBranchesReversed()
getBranches()
.
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(boolean nameInternal)
nameInternal
- Whether internal branches should be named
public void toFile(java.io.File f) throws OutputException
f
- The file to write the tree to
OutputException
- Thrown if there is a problem writing the filepublic void toFile(java.io.File f, boolean nameInternal) throws OutputException
f
- The file to write the tree tonameInternal
- Whether internal branches should be named
OutputException
- Thrown if there is a problem writing the filepublic static Tree fromNewickString(java.lang.String newick) throws TreeException
newick
- The newick string
TreeException
- Thrown if the tree cannot be created (e.g. incorrectly
formatted string)public static Tree fromFile(java.io.File f) throws InputException
f
- The input file
InputException
- If there is a problem reading from the input file
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |