MCPcopy Create free account
hub / github.com/rambaut/figtree / ReRootedTree

Method ReRootedTree

src/figtree/treeviewer/ReRootedTree.java:54–77  ·  view source on GitHub ↗

Make a copy of the given unrooted tree @param source an unrooted source tree @param ingroupNode the node on one side of the root @param outgroupNode the node on the other side of the root @param ingroupBranchLength the branch length from the root to the ingroup node @throws jebl.evolution.graphs.Gra

(RootedTree source, Node ingroupNode, Node outgroupNode, double ingroupBranchLength)

Source from the content-addressed store, hash-verified

52 * @throws jebl.evolution.graphs.Graph.NoEdgeException
53 */
54 public ReRootedTree(RootedTree source, Node ingroupNode, Node outgroupNode, double ingroupBranchLength) throws NoEdgeException {
55
56 this.source = source;
57 List<Node> children = new ArrayList<Node>();
58
59 Node node1 = createNodes(source, outgroupNode, ingroupNode);
60 setLength(node1, ingroupBranchLength);
61 children.add(node1);
62
63 Node node2 = createNodes(source, ingroupNode, outgroupNode);
64 double l = source.getEdgeLength(ingroupNode, outgroupNode);
65 if (outgroupNode == source.getRootNode()) {
66 // the tree is already rooted at the required location
67 for (Node adj : source.getAdjacencies(outgroupNode)) {
68 if (adj != ingroupNode) {
69 l += source.getEdgeLength(outgroupNode, adj);
70 }
71 }
72 }
73 setLength(node2, Math.max(l - ingroupBranchLength, 0.0));
74 children.add(node2);
75
76 createInternalNode(null, children);
77 }
78
79 /**
80 * Clones the entire tree structure from the given (unrooted) Tree.

Callers

nothing calls this directly

Calls 7

createNodesMethod · 0.95
setLengthMethod · 0.95
createInternalNodeMethod · 0.95
getEdgeLengthMethod · 0.80
getRootNodeMethod · 0.80
addMethod · 0.45
getAdjacenciesMethod · 0.45

Tested by

no test coverage detected