jebl.evolution.trees
Class Utils
java.lang.Object
jebl.evolution.trees.Utils
public final class Utils
- extends Object
A collection of utility functions for trees.
- Author:
- rambaut, Alexei Drummond
Constructor Summary |
Utils()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Utils
public Utils()
toNewick
public static String toNewick(RootedTree tree)
- Parameters:
tree
-
- Returns:
- the rooted tree as a newick format string
safeNodeHeight
public static double safeNodeHeight(RootedTree tree,
Node node)
maxLevels
public static int maxLevels(RootedTree tree)
asText
public static String[] asText(Tree tree,
int widthGuide)
rootTheTree
public static RootedTree rootTheTree(Tree tree)
- Return a rooted tree from any tree.
If tree already rooted, return it. Otherwise if there is a "natuarl root" (i.e. a node of
degree 2) use it as root. Otherwise use an internal node close to the center of the tree as a root.
- Parameters:
tree
- to root
- Returns:
- rooted representation
rootTreeAtCenter
public static RootedTree rootTreeAtCenter(Tree tree)
getPathLength
public static double getPathLength(Tree tree,
Node node1,
Node node2)
- Parameters:
tree
- the treenode1
- node2
-
- Returns:
- the path length between the two nodes
isBinary
public static boolean isBinary(RootedTree rootedTree)
- Parameters:
rootedTree
- the rooted tree
- Returns:
- true if all internal nodes in the given tree are of degree 3, except the root
which must have a degree of 2.
isUltrametric
public static boolean isUltrametric(RootedTree rootedTree)
- Parameters:
rootedTree
- the rooted tree
- Returns:
- true if all the external nodes in the tree have a height of 0.0
getExternalNodeCount
public static int getExternalNodeCount(RootedTree tree,
Node node)
- Return the number of external nodes under this node.
- Parameters:
tree
- node
-
- Returns:
- the number of external nodes under this node.
getMinNodeHeight
public static double getMinNodeHeight(RootedTree tree,
Node node)
- Parameters:
tree
- node
-
- Returns:
- the minimum node height
createNodeDensityComparator
public static Comparator<Node> createNodeDensityComparator(RootedTree tree)
createNodeDensityMinNodeHeightComparator
public static Comparator<Node> createNodeDensityMinNodeHeightComparator(RootedTree tree)
DEBUGsubTreeRep
public static String DEBUGsubTreeRep(RootedTree t,
Node n)