public class NodeUtils extends Object
Constructor and Description |
---|
NodeUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
convertNegativeBranchLengthsToZeroLength(Node node)
If the given node or the sub tree defined by that node have negative branch lengths, they'll have
zeron branch lengths after a call to this function!
|
static void |
exchangeInfo(Node node1,
Node node2)
Exchange field info between two nodes.
|
static Node |
findByIdentifier(Node node,
String identifierName)
Returns the first node in this tree that has the
required identifier.
|
static Node[] |
findByIdentifier(Node node,
String[] identifierNames)
Returns the first nodes in this tree that has the
required identifiers.
|
static Node |
findByIdentifier(Node node,
Taxon identifier)
Returns the first node in this tree that has the
required identifier.
|
static Node[] |
findByIdentifier(Node node,
Taxon[] identifiers)
Returns the first nodes in this tree that has the
required identifiers.
|
static double |
findLargestChild(Node node)
Finds the largest child (in terms of node height).
|
static double |
getDistanceToRoot(Node node)
determine distance to root
|
static Node[] |
getExternalNodes(Node root)
Obtains all external nodes from tree defined by root and returns as an array
|
static void |
getExternalNodes(Node root,
Vector store)
Appends all external nodes from tree defined by root to Vector store
|
static Node |
getFirstCommonAncestor(Node[] nodes)
For a set of nodes in the tree returns the common ancestor closest to all nodes (most recent common ancestor)
|
static Node |
getFirstCommonAncestor(Node nodeOne,
Node nodeTwo)
For two nodes in the tree returns the common ancestor closest to both nodes (most recent common ancestor)
|
static int |
getInternalNodeCount(Node root) |
static Node[] |
getInternalNodes(Node root,
boolean includeRoot)
Obtains all internal nodes from tree defined by root and returns as an array
|
static void |
getInternalNodes(Node root,
Vector store)
Appends all internal nodes from tree defined by root to Vector store
|
static int |
getLeafCount(Node node)
Return the number of terminal leaves below this node or 1 if this is
a terminal leaf.
|
static double |
getMaximumPathLengthLengthToLeaf(Node root) |
static int |
getMaxNodeDepth(Node root) |
static double |
getMinimumPathLengthLengthToLeaf(Node root) |
static double[] |
getPathLengthInfo(Node root)
Calculates max/min lengths of paths from root to leaf, taking into account branch lengths
|
static int |
getUnrootedBranchCount(Node center)
returns number of branches centered around an internal node in an unrooted tree
|
static void |
heights2Lengths(Node node)
determines branch lengths of this and all descendent nodes
from heights
|
static void |
heights2Lengths(Node node,
boolean respectMinimum)
determines branch lengths of this and all descendent nodes
from heights
|
static boolean |
isAncestor(Node possibleAncestor,
Node node)
For two nodes in the tree true if the first node is the ancestor of the second
|
static void |
joinChilds(Node node,
int n1,
int n2)
join two childs, introducing a new node/branch in the tree
that replaces the first child
|
static void |
lengths2Heights(Node root)
Converts lengths to heights, *without* assuming contemporaneous
tips.
|
static void |
lengths2HeightsKeepTips(Node node,
boolean useMax)
Converts lengths to heights, but maintains tip heights.
|
static void |
localHeights2Lengths(Node node,
boolean respectMinimum)
determines branch lengths of this node and its immediate descendent nodes
from heights.
|
static Node |
postorderSuccessor(Node node)
determine postorder successor of a node
|
static Node |
preorderSuccessor(Node node)
determine preorder successor of this node
|
static void |
printNH(PrintWriter out,
Node node,
boolean printLengths,
boolean printInternalLabels)
prints node in New Hamshire format.
|
static int |
printNH(PrintWriter out,
Node node,
boolean printLengths,
boolean printInternalLabels,
int column,
boolean breakLines) |
static void |
removeBranch(Node node)
remove internal branch (collapse node with its parent)
|
static void |
removeChild(Node parent,
Node child)
remove child
|
static void |
restoreBranch(Node node)
restore internal branch
|
public static void getExternalNodes(Node root, Vector store)
root
- The root node defining treestore
- Where leaf nodes are stored (original contents is not touched)public static Node[] getExternalNodes(Node root)
root
- The root node defining treepublic static void getInternalNodes(Node root, Vector store)
root
- The root node defining treestore
- Where internal nodes are stored (original contents is not touched)public static Node[] getInternalNodes(Node root, boolean includeRoot)
root
- The root node defining treepublic static int getMaxNodeDepth(Node root)
public static final double[] getPathLengthInfo(Node root)
getMaxNodeDepth()
public static final double getMaximumPathLengthLengthToLeaf(Node root)
public static final double getMinimumPathLengthLengthToLeaf(Node root)
public static void lengths2Heights(Node root)
public static int getInternalNodeCount(Node root)
public static void lengths2HeightsKeepTips(Node node, boolean useMax)
public static void exchangeInfo(Node node1, Node node2)
public static void heights2Lengths(Node node)
public static void heights2Lengths(Node node, boolean respectMinimum)
public static void localHeights2Lengths(Node node, boolean respectMinimum)
public static double findLargestChild(Node node)
public static void removeChild(Node parent, Node child)
node
- child node to be removedpublic static void removeBranch(Node node)
node
- node associated with internal branchpublic static void restoreBranch(Node node)
node
- node associated with internal branchpublic static void joinChilds(Node node, int n1, int n2)
n1
- number of first childn2
- number of second childpublic static Node preorderSuccessor(Node node)
public static Node postorderSuccessor(Node node)
public static void printNH(PrintWriter out, Node node, boolean printLengths, boolean printInternalLabels) throws IOException
IOException
public static int printNH(PrintWriter out, Node node, boolean printLengths, boolean printInternalLabels, int column, boolean breakLines) throws IOException
IOException
public static final Node[] findByIdentifier(Node node, String[] identifierNames)
public static final Node[] findByIdentifier(Node node, Taxon[] identifiers)
public static final Node findByIdentifier(Node node, Taxon identifier)
public static final Node findByIdentifier(Node node, String identifierName)
public static double getDistanceToRoot(Node node)
public static int getLeafCount(Node node)
public static boolean isAncestor(Node possibleAncestor, Node node)
possibleAncestor
- the node that may be the ancestor of the other nodenode
- the node that may have the other node as it's ancestorpublic static Node getFirstCommonAncestor(Node[] nodes)
nodes
- the nodes to check, is okay if array elements are null!public static Node getFirstCommonAncestor(Node nodeOne, Node nodeTwo)
nodeOne
- nodeTwo
- public static final int getUnrootedBranchCount(Node center)
public static final void convertNegativeBranchLengthsToZeroLength(Node node)
Copyright © 2018. All rights reserved.