本文整理汇总了Java中beast.evolution.tree.Node.getRight方法的典型用法代码示例。如果您正苦于以下问题:Java Node.getRight方法的具体用法?Java Node.getRight怎么用?Java Node.getRight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类beast.evolution.tree.Node
的用法示例。
在下文中一共展示了Node.getRight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getConnectingNodes
import beast.evolution.tree.Node; //导入方法依赖的package包/类
private SetMultimap<Integer, Node> getConnectingNodes(Node speciesTreeNode, MinimumDouble tipwardFreedom) {
final Node leftChildNode = speciesTreeNode.getLeft();
final Node rightChildNode = speciesTreeNode.getRight();
final int leftChildNodeNumber = leftChildNode.getNr();
final int rightChildNodeNumber = rightChildNode.getNr();
final Set<String> leftChildDescendants = findDescendants(leftChildNode, leftChildNodeNumber);
final Set<String> rightChildDescendants = findDescendants(rightChildNode, rightChildNodeNumber);
final SetMultimap<Integer, Node> allConnectingNodes = HashMultimap.create();
final List<Tree> geneTrees = geneTreeInput.get();
for (int j = 0; j < nGeneTrees; j++) {
final Tree geneTree = geneTrees.get(j);
final Node geneTreeRootNode = geneTree.getRoot();
final Set<Node> jConnectingNodes = new HashSet<Node>();
findConnectingNodes(geneTreeRootNode, jConnectingNodes, leftChildDescendants, rightChildDescendants, tipwardFreedom);
allConnectingNodes.putAll(j, jConnectingNodes);
geneTree.startEditing(null); // hack to stop beast.core.State.Trie memory leak
}
return allConnectingNodes;
}
示例2: findDescendants
import beast.evolution.tree.Node; //导入方法依赖的package包/类
protected Set<String> findDescendants(Node speciesTreeNode, int speciesTreeNodeNumber) {
final Multimap<Integer, String> numberTipMap = speciesTreeInput.get().getNumberTipMap();
final Set<String> descendantNames = new HashSet<>();
if (speciesTreeNode.isLeaf()) {
descendantNames.addAll(numberTipMap.get(speciesTreeNodeNumber));
} else {
final Node leftChild = speciesTreeNode.getLeft();
final Node rightChild = speciesTreeNode.getRight();
final int leftChildNumber = leftChild.getNr();
final int rightChildNumber = rightChild.getNr();
descendantNames.addAll(findDescendants(leftChild, leftChildNumber));
descendantNames.addAll(findDescendants(rightChild, rightChildNumber));
}
return descendantNames;
}
示例3: findGraftBranches
import beast.evolution.tree.Node; //导入方法依赖的package包/类
private boolean findGraftBranches(Node geneTreeNode, Set<Node> graftNodes, Set<String> branchDescendants) {
if (geneTreeNode.isLeaf()) {
final String descendantName = geneTreeNode.getID();
return branchDescendants.contains(descendantName);
}
final Node leftChild = geneTreeNode.getLeft();
final Node rightChild = geneTreeNode.getRight();
final boolean leftOverlaps = findGraftBranches(leftChild, graftNodes, branchDescendants);
final boolean rightOverlaps = findGraftBranches(rightChild, graftNodes, branchDescendants);
// subtree defined by a child node overlaps species subtree defined by branch
if (leftOverlaps || rightOverlaps) {
if (leftOverlaps) {
graftNodes.add(leftChild);
}
if (rightOverlaps) {
graftNodes.add(rightChild);
}
return true;
}
return false;
}
示例4: getConnectingNodes
import beast.evolution.tree.Node; //导入方法依赖的package包/类
private SetMultimap<Integer, Node> getConnectingNodes(Node speciesTreeNode, MinimumDouble tipwardFreedom, MinimumDouble rootwardFreedom) {
final Node leftChildNode = speciesTreeNode.getLeft();
final Node rightChildNode = speciesTreeNode.getRight();
final int leftChildNodeNumber = leftChildNode.getNr();
final int rightChildNodeNumber = rightChildNode.getNr();
final Set<String> leftChildDescendants = findDescendants(leftChildNode, leftChildNodeNumber);
final Set<String> rightChildDescendants = findDescendants(rightChildNode, rightChildNodeNumber);
final SetMultimap<Integer, Node> allConnectingNodes = HashMultimap.create();
final List<Tree> geneTrees = geneTreeInput.get();
for (int j = 0; j < nGeneTrees; j++) {
final Tree geneTree = geneTrees.get(j);
final Node geneTreeRootNode = geneTree.getRoot();
final Set<Node> jConnectingNodes = new HashSet<Node>();
findConnectingNodes(geneTreeRootNode, jConnectingNodes, leftChildDescendants, rightChildDescendants, tipwardFreedom, rootwardFreedom);
allConnectingNodes.putAll(j, jConnectingNodes);
geneTree.startEditing(null); // hack to stop beast.core.State.Trie memory leak
}
return allConnectingNodes;
}
示例5: lengthToHeight
import beast.evolution.tree.Node; //导入方法依赖的package包/类
/** convert length to height
* and set ID of leafs
*/
private double lengthToHeight(Node node, double offSet) {
if (node.isLeaf()) {
node.setHeight(-offSet - node.getHeight());
node.setID(m_sLabels.get(node.getNr()));
return -node.getHeight();
} else {
double posY = offSet + node.getHeight();
double yMax = 0;
yMax = Math.max(yMax, lengthToHeight(node.getLeft(), posY));
if (node.getRight() != null) {
yMax = Math.max(yMax, lengthToHeight(node.getRight(), posY));
}
node.setHeight(-posY);
return yMax;
}
}
示例6: traverse
import beast.evolution.tree.Node; //导入方法依赖的package包/类
/**
* recursively walk through the tree top down, and add sequence to alignment whenever
* a leave node is reached.
*
* @param node reference to the current node, for which we visit all children
* @param parentSequence randomly generated sequence of the parent node
* @param category array of categories for each of the sites
* @param alignment
* @
*/
void traverse(Node node, int[] parentSequence, int[] category, Alignment alignment) {
for (int childIndex = 0; childIndex < 2; childIndex++) {
Node child = (childIndex == 0 ? node.getLeft() : node.getRight());
for (int i = 0; i < m_categoryCount; i++) {
getTransitionProbabilities(m_tree, child, i, m_probabilities[i]);
}
int[] seq = new int[m_sequenceLength];
double[] cProb = new double[m_stateCount];
for (int i = 0; i < m_sequenceLength; i++) {
System.arraycopy(m_probabilities[category[i]], parentSequence[i] * m_stateCount, cProb, 0, m_stateCount);
seq[i] = Randomizer.randomChoicePDF(cProb);
}
if (child.isLeaf()) {
alignment.sequenceInput.setValue(intArray2Sequence(seq, child), alignment);
} else {
traverse(child, seq, category, alignment);
}
}
}
示例7: 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
示例8: findMovedPairs
import beast.evolution.tree.Node; //导入方法依赖的package包/类
private boolean findMovedPairs(Node geneTreeNode, Map<Node, Node> movedNodes, Set<String> chosenDescendants, double lowerHeight, double upperHeight) {
if (geneTreeNode.isLeaf()) {
final String descendantName = geneTreeNode.getID();
// returns true if this leaf is a descendant of the chosen species
return chosenDescendants.contains(descendantName);
}
final Node leftChild = geneTreeNode.getLeft();
final Node rightChild = geneTreeNode.getRight();
// left child descendants are exclusively descendants of the chosen species tree node
final boolean leftExclusive = findMovedPairs(leftChild, movedNodes, chosenDescendants, lowerHeight, upperHeight);
// right child descendants are exclusively descendants of the chosen species tree node
final boolean rightExclusive = findMovedPairs(rightChild, movedNodes, chosenDescendants, lowerHeight, upperHeight);
final double nodeHeight = geneTreeNode.getHeight();
if (nodeHeight >= lowerHeight && nodeHeight < upperHeight) {
if (leftExclusive ^ rightExclusive) {
if (leftExclusive) { // leave right child attached to original parent
movedNodes.put(geneTreeNode, rightChild);
} else { // leaf left child attached to original parent
movedNodes.put(geneTreeNode, leftChild);
}
}
}
// returns true if all descendants of this gene tree node are also descendants of the chosen species tree node
return leftExclusive && rightExclusive;
}
示例9: getOtherChild
import beast.evolution.tree.Node; //导入方法依赖的package包/类
/**
* @param parent the parent
* @param child the child that you want the sister of
* @return the other child of the given parent.
*/
protected Node getOtherChild(final Node parent, final Node child) {
if (parent.getLeft().getNr() == child.getNr()) {
return parent.getRight();
} else {
return parent.getLeft();
}
}
示例10: offsetHeight
import beast.evolution.tree.Node; //导入方法依赖的package包/类
/** move y-position of a tree with offset f **/
public void offsetHeight(Node node, double f) {
if (!node.isLeaf()) {
offsetHeight(node.getLeft(), f);
if (node.getRight() != null) {
offsetHeight(node.getRight(), f);
}
}
node.setHeight(node.getHeight() + f);
}
示例11: 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]++;
}
}
}
示例12: offset
import beast.evolution.tree.Node; //导入方法依赖的package包/类
void offset(Node node, double fDelta) {
node.setHeight(node.getHeight() + fDelta);
if (node.isLeaf()) {
if (node.getHeight() < thresholdInput.get()) {
node.setHeight(0);
}
}
if (!node.isLeaf()) {
offset(node.getLeft(), fDelta);
if (node.getRight() != null) {
offset(node.getRight(), fDelta);
}
}
}
示例13: extractAllSAClades
import beast.evolution.tree.Node; //导入方法依赖的package包/类
/**
*
* @param node
* @return all sampled ancestor clades descendant from node
*/
public ArrayList<String> extractAllSAClades(Node node) {
ArrayList<String> tmp = new ArrayList<String>();
if (node.isLeaf())
tmp.add(extractSAClade(node));
if (node.getLeft() != null)
tmp.addAll(extractAllSAClades(node.getLeft()));
if (node.getRight() != null)
tmp.addAll(extractAllSAClades(node.getRight()));
return tmp;
}
示例14: 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);
}
}
示例15: listNodesUnder
import beast.evolution.tree.Node; //导入方法依赖的package包/类
private ArrayList<Integer> listNodesUnder(Node node) {
ArrayList<Integer> tmp = new ArrayList<Integer>();
if (node.getChildCount() < 2)
tmp.add(node.getNr()+1);
if (node.getLeft() != null)
tmp.addAll(listNodesUnder(node.getLeft()));
if (node.getRight() != null)
tmp.addAll(listNodesUnder(node.getRight()));
return tmp;
}