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)
| 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. |
nothing calls this directly
no test coverage detected