本文整理汇总了Java中beast.evolution.tree.Node.getLeft方法的典型用法代码示例。如果您正苦于以下问题:Java Node.getLeft方法的具体用法?Java Node.getLeft怎么用?Java Node.getLeft使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类beast.evolution.tree.Node
的用法示例。
在下文中一共展示了Node.getLeft方法的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: 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) {
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()) {
sequenceInput.setValue(intArray2Sequence(seq, child), this);
} else {
traverse(child, seq, category);
}
}
}
示例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: reorder
import beast.evolution.tree.Node; //导入方法依赖的package包/类
/**
* randomly changes left and right children in every internal node *
*/
private void reorder(final Node node) {
if (!node.isLeaf()) {
if (Randomizer.nextBoolean()) {
final Node tmp = node.getLeft();
node.setLeft(node.getRight());
node.setRight(tmp);
}
reorder(node.getLeft());
reorder(node.getRight());
}
}
示例9: 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;
}
示例10: 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();
}
}
示例11: 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;
}
示例12: 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);
}
}
示例13: 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;
}
示例14: extractAllDClades
import beast.evolution.tree.Node; //导入方法依赖的package包/类
public ArrayList<String> extractAllDClades(Node node, boolean zeroBranchTrees) {
ArrayList<String> tmp = new ArrayList<String>();
if ((!zeroBranchTrees && node.getChildCount() < 2) || (zeroBranchTrees && node.isLeaf()))
tmp.add(extractDClade(node, zeroBranchTrees));
if (node.getLeft() != null)
tmp.addAll(extractAllDClades(node.getLeft(), zeroBranchTrees));
if (node.getRight() != null)
tmp.addAll(extractAllDClades(node.getRight(), zeroBranchTrees));
return tmp;
}
示例15: 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);
}
}
}