本文整理汇总了Java中beast.evolution.tree.Node.removeChild方法的典型用法代码示例。如果您正苦于以下问题:Java Node.removeChild方法的具体用法?Java Node.removeChild怎么用?Java Node.removeChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类beast.evolution.tree.Node
的用法示例。
在下文中一共展示了Node.removeChild方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: pruneAndRegraft
import beast.evolution.tree.Node; //导入方法依赖的package包/类
private static void pruneAndRegraft(final Node nodeToMove, final Node newChild, final Node disownedChild) {
final Node sourceParent = nodeToMove.getParent();
final Node destinationParent = newChild.getParent();
// debug string
// System.out.println(String.format("%d-%d-%d > %d-%d", parent.getNr(), nodeToMove.getNr(), disownedChild.getNr(), destinationParent.getNr(), newChild.getNr()));
nodeToMove.removeChild(disownedChild);
sourceParent.removeChild(nodeToMove);
destinationParent.removeChild(newChild);
nodeToMove.addChild(newChild);
sourceParent.addChild(disownedChild);
destinationParent.addChild(nodeToMove);
nodeToMove.makeDirty(Tree.IS_FILTHY);
sourceParent.makeDirty(Tree.IS_FILTHY);
destinationParent.makeDirty(Tree.IS_FILTHY);
newChild.makeDirty(Tree.IS_FILTHY);
disownedChild.makeDirty(Tree.IS_FILTHY);
}
示例2: binarizeMultifurcation
import beast.evolution.tree.Node; //导入方法依赖的package包/类
/**
* Use zero-length edges to replace multifurcations with a sequence of bifurcations.
*
* @param node node representing multifurcation
*/
private void binarizeMultifurcation(Node node) {
if (node.getChildCount()>2) {
List<Node> children = new ArrayList<>(node.getChildren());
Node prevDummy = node;
for (int i=1; i<children.size()-1; i++) {
Node child = children.get(i);
Node dummyNode = newNode();
dummyNode.setNr(-1);
dummyNode.setHeight(0);
prevDummy.addChild(dummyNode);
node.removeChild(child);
dummyNode.addChild(child);
prevDummy = dummyNode;
}
node.removeChild(children.get(children.size()-1));
prevDummy.addChild(children.get(children.size()-1));
}
}
示例3: removeSingleChildNodes
import beast.evolution.tree.Node; //导入方法依赖的package包/类
/**
* Extract the sampled tree by discarding all the nodes that have -1 number simultaneously suppress single
* child nodes (nodes with only one child numbered by non-negative number)
* @param node
*/
public void removeSingleChildNodes(Node node) {
if (!node.isLeaf()) {
Node left = node.getLeft();
Node right = node.getRight();
removeSingleChildNodes(left);
removeSingleChildNodes(right);
for (Node child:node.getChildren()) {
if (child.getNr() == -1) {
node.removeChild(child);
}
}
if (node.getChildCount() == 1 && node.getParent() != null) {
Node parent = node.getParent();
Node newChild = node.getLeft();
parent.removeChild(node);
parent.addChild(newChild);
newChild.setParent(parent);
//node.setParent(null);
}
}
}
开发者ID:CompEvol,项目名称:sampled-ancestors,代码行数:28,代码来源:SABDSkylineTreeSimulatorArbitraryRateChanges.java
示例4: convertTree
import beast.evolution.tree.Node; //导入方法依赖的package包/类
private void convertTree(Node node) {
if (!node.isLeaf()) {
if (node.isFake()) {
Node directAncestor = node.getDirectAncestorChild();
node.removeChild(directAncestor);
node.setNr(directAncestor.getNr());
node.setID(directAncestor.getID());
directAncestor.setParent(null);
}
for (int i = 0; i < node.getChildCount(); i++) {
Node childNode = node.getChild(i);
convertTree(childNode);
}
}
}
示例5: convertToFakeSATree
import beast.evolution.tree.Node; //导入方法依赖的package包/类
public static void convertToFakeSATree(Node node, int[] nextNr) {
if (!node.isLeaf()) {
convertToFakeSATree(node.getLeft(), nextNr);
if (node.getRight() != null) {
convertToFakeSATree(node.getRight(), nextNr);
}
}
if (node.getChildCount() == 1) {
Node parent = new Node();
parent.setHeight(node.getHeight());
Node child = node.getLeft();
parent.setLeft(child);
child.setParent(parent);
node.removeChild(child);
parent.setRight(node);
parent.setNr(nextNr[0]);
nextNr[0]++;
if (!node.isRoot()) {
Node grandparent = node.getParent();
if (grandparent.getLeft().getNr() == node.getNr()) {
grandparent.setLeft(parent);
} else {
grandparent.setRight(parent);
}
parent.setParent(grandparent);
} else {
node.getTree().setRoot(parent);
}
node.setParent(parent);
}
}
示例6: removeFossils
import beast.evolution.tree.Node; //导入方法依赖的package包/类
public void removeFossils(Node node, Tree tree, ArrayList<Node> removedNodes) {
if (node.isLeaf()) {
if (!extantTaxa.contains(node.getID())) {
node.getParent().removeChild(node);
node.setParent(null);
removedNodes.add(node);
}
} else {
Node left = node.getLeft();
Node right = node.getRight();
removeFossils(left, tree, removedNodes);
removeFossils(right, tree, removedNodes);
if (node.isLeaf()) {
node.getParent().removeChild(node);
node.setParent(null);
removedNodes.add(node);
}
if (node.getChildCount() == 1) {
Node child = node.getChild(0);
if (node.getParent() != null) {
Node grandParent = node.getParent();
grandParent.removeChild(node);
grandParent.addChild(child);
child.setParent(grandParent);
node.setParent(null);
}
else {
child.setParent(null);
tree.setRootOnly(child);
}
removedNodes.add(node);
}
}
}
示例7: convertToFakeSATree
import beast.evolution.tree.Node; //导入方法依赖的package包/类
/**
* convert a tree with single child node to ZeroBranchSATree.
*
* @param node all the nodes that are under this node and have single child will be
* replaced with zero branches
* @throws Exception
*/
private void convertToFakeSATree(Node node, int[] lastLabel) throws Exception {
if (!node.isLeaf()) {
convertToFakeSATree(node.getLeft(), lastLabel);
if (node.getRight() != null) {
convertToFakeSATree(node.getRight(), lastLabel);
}
}
if (node.getChildCount() == 1) {
Node parent = newNode();
parent.setNr(-1);
parent.setHeight(node.getHeight());
Node child = node.getLeft();
parent.setLeft(child);
child.setParent(parent);
node.removeChild(child);
parent.setRight(node);
if (!node.isRoot()) {
Node grandparent = node.getParent();
if (grandparent.getLeft().equals(node)) {
grandparent.setLeft(parent);
} else {
grandparent.setRight(parent);
}
parent.setParent(grandparent);
}
node.setParent(parent);
if (node.getNr() == -1) {
node.setNr(lastLabel[0]+1);
lastLabel[0]++;
}
}
}
示例8: replace
import beast.evolution.tree.Node; //导入方法依赖的package包/类
/**
* replace child with another node
*
* @param node
* @param child
* @param replacement
*/
public void replace(final Node node, final Node child, final Node replacement) {
node.removeChild(child);
node.addChild(replacement);
node.makeDirty(Tree.IS_FILTHY);
replacement.makeDirty(Tree.IS_FILTHY);
}