本文整理汇总了Java中pal.tree.Node.getChild方法的典型用法代码示例。如果您正苦于以下问题:Java Node.getChild方法的具体用法?Java Node.getChild怎么用?Java Node.getChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pal.tree.Node
的用法示例。
在下文中一共展示了Node.getChild方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: rootedSupport
import pal.tree.Node; //导入方法依赖的package包/类
/**
* Calculates rooted support.
*
* @param wTree the weighted tree instance
* @param node the node
* @param support the support
*
* @return the fixed bit set
*/
private FixedBitSet rootedSupport(WeightedTree wTree, Node node, Map<FixedBitSet, Support> support) {
FixedBitSet clade = new FixedBitSet(numTaxa);
if (node.isLeaf()) {
clade.set(idGroup.whichIdNumber(node.getIdentifier().getName()));
} else {
for (int i = 0; i < node.getChildCount(); i++) {
Node n = node.getChild(i);
FixedBitSet childClade = rootedSupport(wTree, n, support);
clade.union(childClade);
}
}
Support s = support.get(clade);
if (s == null) {
s = new Support();
support.put(clade, s);
}
s.add(wTree.getWeight(), TreeUtilities.safeNodeHeight(wTree.getTree(), node), node.getBranchLength());
return clade;
}
示例2: insureConsistency
import pal.tree.Node; //导入方法依赖的package包/类
/**
* Make sure subtree below node has consistent heights, i.e. node height is higher than it's descendants
*
* @param tree the tree
* @param node the node
*
* @return height of node
*/
public static double insureConsistency(Tree tree, Node node) {
double height = TreeUtilities.safeNodeHeight(tree, node);
if (node.isLeaf()) {
return height;
} else {
for (int i = 0; i < node.getChildCount(); i++) {
Node n = node.getChild(i);
final double childHeight = insureConsistency(tree, n);
height = Math.max(height, childHeight);
}
}
node.setNodeHeight(height);
return height;
}
示例3: insureConsistency
import pal.tree.Node; //导入方法依赖的package包/类
/**
* Make sure subtree below node has consistent heights, i.e. node height is higher than it's descendants
*
* @param tree the tree
* @param node the node
*
* @return height of node
*/
public static double insureConsistency(Tree tree, Node node) {
double height = TreeUtils.safeNodeHeight(tree, node);
if (node.isLeaf()) {
return height;
} else {
for (int i = 0; i < node.getChildCount(); i++) {
Node n = node.getChild(i);
final double childHeight = insureConsistency(tree, n);
height = Math.max(height, childHeight);
}
}
node.setNodeHeight(height);
return height;
}
示例4: rootedSupport
import pal.tree.Node; //导入方法依赖的package包/类
/**
* Calculates rooted support.
*
* @param wTree the weighted tree instance
* @param node the node
* @param support the support
*
* @return the fixed bit set
*/
private FixedBitSet rootedSupport(WeightedTree wTree, Node node, Map<FixedBitSet, Support> support) {
FixedBitSet clade = new FixedBitSet(numTaxa);
if (node.isLeaf()) {
clade.set(idGroup.whichIdNumber(node.getIdentifier().getName()));
} else {
for (int i = 0; i < node.getChildCount(); i++) {
Node n = node.getChild(i);
FixedBitSet childClade = rootedSupport(wTree, n, support);
clade.union(childClade);
}
}
Support s = support.get(clade);
if (s == null) {
s = new Support();
support.put(clade, s);
}
s.add(wTree.getWeight(), TreeUtils.safeNodeHeight(wTree.getTree(), node), node.getBranchLength());
return clade;
}
示例5: nodeDistance
import pal.tree.Node; //导入方法依赖的package包/类
/**
* Calculates the number of branches from node to most remote tip.
*
* @param node the starting node
*
* @return the node distance
*/
public static int nodeDistance(final Node node) {
if (node.isLeaf()) {
return 0;
}
int d = 0;
for (int i = 0; i < node.getChildCount(); i++) {
Node n = node.getChild(i);
d = Math.max(d, nodeDistance(n));
}
return d + 1;
}
示例6: getLeavesFromNode
import pal.tree.Node; //导入方法依赖的package包/类
private void getLeavesFromNode(Node node, Set<String> leaves) {
if (node.isLeaf()) {
leaves.add(node.getIdentifier().getName());
} else {
for (int i = 0; i < node.getChildCount(); i++) {
Node child = node.getChild(i);
getLeavesFromNode(child, leaves);
}
}
}
示例7: simulate
import pal.tree.Node; //导入方法依赖的package包/类
private void simulate(SwMutSel model, Node node, byte state, int site) {
for (int i = 0; i < node.getChildCount(); i++) {
Node child = node.getChild(i);
model.getPtCalculator().getTransitionProbabilities(Pt, child.getBranchLength());
double[] Pij = Pt[state];
byte newState = randomState(Pij);
if (child.isLeaf()) {
child.getSequence()[site] = newState;
} else {
simulate(model, child, newState, site);
}
}
}
示例8: downTree
import pal.tree.Node; //导入方法依赖的package包/类
private double[] downTree() {
//long start = CodeTimer.start();
for (Node node : nodeTraversalOrder) {
double[] conditional = new double[GeneticCode.CODON_STATES];
for (int j : senseCodons) conditional[j] = 1.0;
for (int j = 0; j < node.getChildCount(); j++) {
Node child = node.getChild(j);
double[] lowerConditional;
if (child.isLeaf()) {
if (GeneticCode.getInstance().isUnknownCodonState(states.get(getNodeLabel(child)))) {
lowerConditional = gapConditional;
} else {
Arrays.fill(tipConditional, 0.0);
tipConditional[states.get(getNodeLabel(child))] = 1.0;
lowerConditional = tipConditional;
}
} else {
lowerConditional = conditionals[child.getNumber()];
}
if (node.isRoot()) {
conditionalAtRoot.add(new Partial(child, PhyloUtils.getNodeNumber(tree, child), Arrays.copyOf(lowerConditional, GeneticCode.CODON_STATES), child.getBranchLength()));
}
if (cladeModels.size() == 1) { // homogeneous model
// TODO: A probability matrix (of sorts) already exists in TdGCodonModel...do we need to create it again?
// cladeCalculators.get(ROOT_MODEL_NAME).getTransitionProbabilities(probMatrix, child.getBranchLength());
// updateIntraCladeConditionals(lowerConditional, conditional, probMatrix);
cladeCalculators.get(ROOT_MODEL_NAME).calculatePartialLikelihood(lowerConditional, conditional, child.getBranchLength());
} else { // non-homogeneous model
if (getNodeLabel(node).length() == 0 // the root of the tree is a parent without a label
|| getNodeLabel(child).substring(0, 2).equals(getNodeLabel(node).substring(0, 2))) { // or we're not switching to a different model
cladeCalculators.get(getNodeLabel(child).substring(0, 2)).getTransitionProbabilities(probMatrix, child.getBranchLength());
updateIntraCladeConditionals(lowerConditional, conditional, probMatrix);
} else { // this is a hostshift!
final double[][] probMatrix1 = new double[GeneticCode.CODON_STATES][GeneticCode.CODON_STATES];
cladeCalculators.get(getNodeLabel(node).substring(0, 2)).getTransitionProbabilities(probMatrix, child.getBranchLength() * Constants.CLADE_BRANCH_SPLIT);
cladeCalculators.get(getNodeLabel(child).substring(0, 2)).getTransitionProbabilities(probMatrix1, child.getBranchLength() * (1 - Constants.CLADE_BRANCH_SPLIT));
updateInterCladeConditionals(lowerConditional, conditional, probMatrix, probMatrix1);
}
}
}
// don't scale the root node
if (!node.isRoot()) {
scaleConditionals(node, conditional);
}
conditionals[node.getNumber()] = conditional;
}
return conditionals[tree.getRoot().getNumber()];
}
示例9: orderNodesInTree
import pal.tree.Node; //导入方法依赖的package包/类
private void orderNodesInTree(Tree t) {
for (Node n : PhyloUtils.internalNodes(t)) {
Node n0 = n.getChild(CHILD_0);
Set<String> child0 = Sets.newHashSet();
getDescendants(n0, child0);
Node n1 = n.getChild(CHILD_1);
Set<String> child1 = Sets.newHashSet();
getDescendants(n1, child1);
Set<String> nodeKey = Sets.newHashSet();
nodeKey.addAll(child0);
nodeKey.addAll(child1);
if (n.getChildCount() == UNROOTED_DEGREE) {
Set<String> child2 = Sets.newHashSet();
getDescendants(n.getChild(CHILD_2), child2);
nodeKey.addAll(child2);
}
for (Set<String> s : descendantsOfNodes.keySet()) {
if (s.equals(nodeKey)) {
if (n.getChildCount() == UNROOTED_DEGREE) {
if (!n.isRoot())
throw new RuntimeException("ERROR: Trifurcating node isn't root. I don't know what to do!");
Node n2 = n.getChild(CHILD_2);
n.removeChild(0);
n.removeChild(0);
n.removeChild(0);
Set<String> originalChild0 = orderAtRoot.first;
Set<String> originalChild1 = orderAtRoot.second;
Set<String> originalChild2 = orderAtRoot.third;
if (originalChild0.equals(child0)) {
n.insertChild(n0, CHILD_0);
} else if (originalChild0.equals(child1)) {
n.insertChild(n1, CHILD_0);
} else {
n.insertChild(n2, CHILD_0);
}
if (originalChild1.equals(child0)) {
n.insertChild(n0, CHILD_1);
} else if (originalChild1.equals(child1)) {
n.insertChild(n1, CHILD_1);
} else {
n.insertChild(n2, CHILD_1);
}
if (originalChild2.equals(child0)) {
n.insertChild(n0, CHILD_2);
} else if (originalChild2.equals(child1)) {
n.insertChild(n1, CHILD_2);
} else {
n.insertChild(n2, CHILD_2);
}
} else {
if (!child0.equals(descendantsOfNodes.get(s).first)) {
n.removeChild(0);
n.removeChild(0);
n.insertChild(n1, CHILD_0);
n.insertChild(n0, CHILD_1);
}
}
}
}
}
}