public class TreeUtils
various utility functions on trees.
public static double getRobinsonFouldsDistance(Tree t1, Tree t2)
computes Robinson-Foulds (1981) distance between two trees
t1 - tree 1t2 - tree 2 Definition: Assuming that t1 is the reference tree, let fn be the false negatives, i.e. the number of edges in t1 missing in t2, and fp the number of false positives, i.e. the number of edges in t2 missing in t1. The RF distance is then (fn + fp)/2public static double getRobinsonFouldsDistance(SplitSystem s1, Tree t2)
computes Robinson-Foulds (1981) distance between two trees
s1 - tree 1 (as represented by a SplitSystem)t2 - tree 2public static double getRobinsonFouldsRescaledDistance(Tree t1, Tree t2)
computes Robinson-Foulds (1981) distance between two trees rescaled to a number between 0 and 1
t1 - tree 1t2 - tree 2public static double getRobinsonFouldsRescaledDistance(SplitSystem s1, Tree t2)
computes Robinson-Foulds (1981) distance between two trees rescaled to a number between 0 and 1
s1 - tree 1 (as represented by a SplitSystem)t2 - tree 2public static Node getRandomNode(Tree tree)
Returns a uniformly distributed random node from the tree, including both internal and external nodes.
public static Node getNodeByName(Tree tree, java.lang.String name)
tree - The Tree supposidly containing such a named nodename - The name of the node to find.public static Node getNodeByName(Node root, java.lang.String name)
root - The root node of a treename - The name of the node to find.public static void rotateByLeafCount(Tree tree)
Rotates branches by leaf count. WARNING: assumes binary tree!
public static TaxaList getLeafIdGroup(Tree tree)
get list of the identifiers of the external nodes
public static void printNH(Tree tree, java.io.PrintWriter out)
print a this tree in New Hampshire format (including distances and internal labels)
out - output streampublic static void printNH(Tree tree, java.io.PrintWriter out, boolean printLengths, boolean printInternalLabels)
print this tree in New Hampshire format
out - output streamprintLengths - boolean variable determining whether branch lengths should be included in outputprintInternalLabels - boolean variable determining whether internal labels should be included in outputpublic static void reroot(Tree tree, Node node)
a tree that has been re-rooted at the given internal node. The original root of the tree must have had at least 3 children.
public static Node findMidpointNode(Tree tree)
Return node with the highest average minimum and maximum distance. Ed thinks this is roughly the midpoint - need to look this up
tree - public static void computeAllDistances(Tree tree, int a, kotlin.Array[] dist, kotlin.Array[] idist, boolean countEdges, double epsilon)
public static double computeDistance(Tree tree, int a, int b)
compute distance between two external nodes
tree - treea - external node 1b - external node 2public static void report(Tree tree, java.io.Writer out)