当前位置: 首页>>代码示例>>Java>>正文


Java Node.getChildCount方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:baezortega,项目名称:mutree,代码行数:24,代码来源:Utils.java

示例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;
}
 
开发者ID:ddarriba,项目名称:jmodeltest2,代码行数:30,代码来源:Consensus.java

示例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;
}
 
开发者ID:ddarriba,项目名称:jmodeltest2,代码行数:24,代码来源:TreeUtilities.java

示例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;
}
 
开发者ID:ddarriba,项目名称:prottest3,代码行数:24,代码来源:TreeUtils.java

示例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;
}
 
开发者ID:ddarriba,项目名称:prottest3,代码行数:30,代码来源:Consensus.java

示例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;
}
 
开发者ID:ddarriba,项目名称:jmodeltest2,代码行数:20,代码来源:TreeUtilities.java

示例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();
        }
    }
}
 
开发者ID:ddarriba,项目名称:jmodeltest2,代码行数:34,代码来源:TreeUtilities.java

示例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));
		}
	}

}
 
开发者ID:ddarriba,项目名称:jmodeltest2,代码行数:41,代码来源:TreeUtilities.java

示例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();
        }
    }
}
 
开发者ID:ddarriba,项目名称:prottest3,代码行数:36,代码来源:TreeUtils.java

示例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);
        }
    }
}
 
开发者ID:tamuri,项目名称:swmutsel,代码行数:11,代码来源:BranchLengthComparer.java

示例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);
    }
}
 
开发者ID:tamuri,项目名称:swmutsel,代码行数:8,代码来源:TreeRootSaver.java

示例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);
    }
}
 
开发者ID:tamuri,项目名称:treesub,代码行数:31,代码来源:Utils.java

示例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;
            }
        }
    }
}
 
开发者ID:ddarriba,项目名称:jmodeltest2,代码行数:51,代码来源:TreeUtilities.java

示例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;
}
 
开发者ID:ddarriba,项目名称:prottest3,代码行数:63,代码来源:TreeUtils.java

示例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);

            }

        }

    }
 
开发者ID:tamuri,项目名称:swmutsel,代码行数:24,代码来源:FastSimulator.java


注:本文中的pal.tree.Node.getChildCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。