本文整理汇总了Java中pal.tree.Node.getChildCount方法的典型用法代码示例。如果您正苦于以下问题:Java Node.getChildCount方法的具体用法?Java Node.getChildCount怎么用?Java Node.getChildCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pal.tree.Node
的用法示例。
在下文中一共展示了Node.getChildCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: printNH2
import pal.tree.Node; //导入方法依赖的package包/类
public static void printNH2(PrintWriter out, Node node, Map<Node, Attributes> nodeAttributes) {
if (!node.isLeaf()) {
out.print("(");
for (int i = 0; i < node.getChildCount(); i++) {
if (i != 0) {
out.print(",");
}
printNH2(out, node.getChild(i), nodeAttributes);
}
out.print(")");
}
if (!node.isRoot()) {
String id = nodeAttributes.get(node).get(Attributes.Key.REALNAME);
out.print(id);
out.print(":");
FormattedOutput.getInstance().displayDecimal(out, node.getBranchLength(), 7);
}
}
示例2: 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;
}
示例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 = 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: 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;
}
示例7: printASCII
import pal.tree.Node; //导入方法依赖的package包/类
public static void printASCII(Tree tree, PrintWriter out) {
tree.createNodeList();
int numExternalNodes = tree.getExternalNodeCount();
int numInternalNodes = tree.getInternalNodeCount();
int numBranches = numInternalNodes + numExternalNodes - 1;
boolean[] umbrella = new boolean[numExternalNodes];
int[] position = new int[numExternalNodes];
int minLength = (Integer.toString(numBranches)).length() + 1;
int MAXCOLUMN = 40;
Node root = tree.getRoot();
if (root.getNodeHeight() == 0.0) {
NodeUtils.lengths2Heights(root);
}
double proportion = (double) MAXCOLUMN / root.getNodeHeight();
for (int n = 0; n < numExternalNodes; n++) {
umbrella[n] = false;
}
position[0] = 1;
for (int i = root.getChildCount() - 1; i > -1; i--) {
printNodeInASCII(out, root.getChild(i), 1, i, root.getChildCount(),
numExternalNodes, umbrella, position, proportion, minLength);
if (i != 0) {
putCharAtLevel(out, 0, '|', position);
out.println();
}
}
}
示例8: printNH
import pal.tree.Node; //导入方法依赖的package包/类
public static void printNH(PrintWriter out, Tree tree, Node node,
boolean printLengths, boolean printInternalLabels,
boolean printCladeSupport) {
if (!node.isLeaf()) {
out.print("(");
for (int i = 0; i < node.getChildCount(); i++) {
if (i != 0) {
out.print(",");
}
printNH(out, tree, node.getChild(i), printLengths,
printInternalLabels, printCladeSupport);
}
out.print(")");
}
if (!node.isRoot()) {
if (node.isLeaf() || printInternalLabels) {
String id = node.getIdentifier().toString();
out.print(id);
}
if (printCladeSupport) {
if (tree.getAttribute(node, TREE_CLADE_SUPPORT_ATTRIBUTE) != null) {
double support = (Double) tree.getAttribute(node,
TREE_CLADE_SUPPORT_ATTRIBUTE);
out.printf(":" + FormattedOutput.getInstance().getDecimalString(support, 4));
}
}
if (printLengths) {
out.printf(":" + FormattedOutput.getInstance().getDecimalString(node.getBranchLength(), 10));
}
}
}
示例9: printASCII
import pal.tree.Node; //导入方法依赖的package包/类
public static void printASCII(Tree tree, PrintWriter out) {
FormattedOutput format = FormattedOutput.getInstance();
tree.createNodeList();
int numExternalNodes = tree.getExternalNodeCount();
int numInternalNodes = tree.getInternalNodeCount();
int numBranches = numInternalNodes + numExternalNodes - 1;
boolean[] umbrella = new boolean[numExternalNodes];
int[] position = new int[numExternalNodes];
int minLength = (Integer.toString(numBranches)).length() + 1;
int MAXCOLUMN = 40;
Node root = tree.getRoot();
if (root.getNodeHeight() == 0.0) {
NodeUtils.lengths2Heights(root);
}
double proportion = (double) MAXCOLUMN / root.getNodeHeight();
for (int n = 0; n < numExternalNodes; n++) {
umbrella[n] = false;
}
position[0] = 1;
for (int i = root.getChildCount() - 1; i > -1; i--) {
printNodeInASCII(out, root.getChild(i), 1, i, root.getChildCount(),
numExternalNodes, umbrella, position, proportion, minLength);
if (i != 0) {
putCharAtLevel(out, 0, '|', position);
out.println();
}
}
}
示例10: 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);
}
}
}
示例11: getDescendants
import pal.tree.Node; //导入方法依赖的package包/类
public void getDescendants(Node node, Collection<String> names) {
if (node.isLeaf()) names.add(node.getIdentifier().getName());
for (int i = 0; i < node.getChildCount(); i++) {
getDescendants(node.getChild(i), names);
}
}
示例12: printNH
import pal.tree.Node; //导入方法依赖的package包/类
public static void printNH(PrintWriter out, Node node, Map<Node, Attributes> nodeAttributes) {
if (!node.isLeaf()) {
out.print("(");
for (int i = 0; i < node.getChildCount(); i++) {
if (i != 0) {
out.print(",");
}
printNH(out, node.getChild(i), nodeAttributes);
}
out.print(")");
}
if (!node.isRoot()) {
if (node.isLeaf()) {
// String id = node.getIdentifier().toString();
String id = nodeAttributes.get(node).get(Attributes.Key.REALNAME);
out.print("'" + id + "'");
} else {
if (nodeAttributes.get(node).size() > 0) {
out.print(nodeAttributes.get(node).toString());
}
}
out.print(":");
FormattedOutput.getInstance().displayDecimal(out, node.getBranchLength(), 7);
}
}
示例13: printNodeInASCII
import pal.tree.Node; //导入方法依赖的package包/类
private static void printNodeInASCII(PrintWriter out, Node node, int level, int m, int maxm,
int numExternalNodes, boolean[] umbrella, int[] position, double proportion, int minLength) {
position[level] = (int) (node.getBranchLength() * proportion);
if (position[level] < minLength) {
position[level] = minLength;
}
if (node.isLeaf()) // external branch
{
if (m == maxm - 1) {
umbrella[level - 1] = true;
}
printlnNodeWithNumberAndLabel(out, node, level, numExternalNodes, umbrella, position);
if (m == 0) {
umbrella[level - 1] = false;
}
} else // internal branch
{
for (int n = node.getChildCount() - 1; n > -1; n--) {
printNodeInASCII(out, node.getChild(n), level + 1, n, node.getChildCount(),
numExternalNodes, umbrella, position, proportion, minLength);
if (m == maxm - 1 && n == node.getChildCount() / 2) {
umbrella[level - 1] = true;
}
if (n != 0) {
if (n == node.getChildCount() / 2) {
printlnNodeWithNumberAndLabel(out, node, level, numExternalNodes, umbrella, position);
} else {
for (int i = 0; i < level + 1; i++) {
if (umbrella[i]) {
putCharAtLevel(out, i, '|', position);
} else {
putCharAtLevel(out, i, ' ', position);
}
}
out.println();
}
}
if (m == 0 && n == node.getChildCount() / 2) {
umbrella[level - 1] = false;
}
}
}
}
示例14: printNH
import pal.tree.Node; //导入方法依赖的package包/类
@Deprecated
public static int printNH(PrintWriter out, Tree tree, Node node,
boolean printLengths, boolean printInternalLabels,
boolean printCladeSupport,
int column, boolean breakLines, int colWidth) {
if (breakLines) {
column = breakLine(out, column, colWidth);
}
if (!node.isLeaf()) {
out.print("(");
column++;
for (int i = 0; i < node.getChildCount(); i++) {
if (i != 0) {
out.print(",");
column++;
}
column = printNH(out, tree, node.getChild(i),
printLengths, printInternalLabels,
printCladeSupport,
column, breakLines, colWidth);
}
out.print(")");
column++;
}
if (!node.isRoot()) {
if (node.isLeaf() || printInternalLabels) {
if (breakLines) {
column = breakLine(out, column, colWidth);
}
String id = node.getIdentifier().toString();
out.print(id);
column += id.length();
}
if (printCladeSupport) {
if (tree.getAttribute(node, TREE_CLADE_SUPPORT_ATTRIBUTE) != null) {
double support = (Double) tree.getAttribute(node, TREE_CLADE_SUPPORT_ATTRIBUTE);
column += ProtTestFormattedOutput.displayDecimal(out, support, 2);
}
}
if (printLengths) {
out.print(":");
column++;
if (breakLines) {
column = breakLine(out, column, colWidth);
}
column += ProtTestFormattedOutput.displayDecimal(out, node.getBranchLength(), 6);
}
}
return column;
}
示例15: 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);
}
}
}