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


Java Node.isLeaf方法代码示例

本文整理汇总了Java中pal.tree.Node.isLeaf方法的典型用法代码示例。如果您正苦于以下问题:Java Node.isLeaf方法的具体用法?Java Node.isLeaf怎么用?Java Node.isLeaf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pal.tree.Node的用法示例。


在下文中一共展示了Node.isLeaf方法的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: getAttributes

import pal.tree.Node; //导入方法依赖的package包/类
private Attributes getAttributes(Node node, List<Substitution> substitutions) {

        String name;
        if (node.isLeaf() && names.size() > 0) {
            name = names.get(Integer.parseInt(getSequenceKey(node).split("_")[1]) - 1);
        } else {
            // MODIFICATION: Change REALNAME of internal nodes (branches)
            //name = getSequenceKey(node);
            name = "branch_" + Integer.toString(getBranchNumber(node));
        }

        Attributes a = new Attributes(Attributes.Key.REALNAME, name);
        a.add(Attributes.Key.NUMBER, Integer.toString(getBranchNumber(node)));

        if (substitutions.size() > 0) a.add(Attributes.Key.ALLSUBS, substitutions.toString());

        Collection<Substitution> nonsynSubs = Collections2.filter(substitutions, Predicates.not(new Substitution.isSynSubPredicate()));
        if (nonsynSubs.size() > 0) a.add(Attributes.Key.NONSYNSUBS, nonsynSubs.toString());

        a.add(Attributes.Key.FULL,
                String.format("%s - %s %s",
                        a.get(Attributes.Key.NUMBER),
                        a.get(Attributes.Key.REALNAME),
                        a.get(Attributes.Key.ALLSUBS)));

        a.add(Attributes.Key.NAME_AND_SUBS,
                String.format("%s %s",
                        a.get(Attributes.Key.REALNAME),
                        a.get(Attributes.Key.NONSYNSUBS)));

        return a;
    }
 
开发者ID:baezortega,项目名称:mutree,代码行数:33,代码来源:ParseRST.java

示例7: getSequenceKey

import pal.tree.Node; //导入方法依赖的package包/类
private String getSequenceKey(Node n) {
    // MODIFIED: now all labels can be obtained from trees[1]
    if (n.isLeaf()) {
        return trees[1].getExternalNode(n.getNumber()).getIdentifier().getName();
        //return trees[0].getExternalNode(n.getNumber()).getIdentifier().getName();
    } else {
        return trees[1].getInternalNode(n.getNumber()).getIdentifier().getName();
        //return "node#" + trees[1].getInternalNode(n.getNumber()).getIdentifier().getName();
    }
}
 
开发者ID:baezortega,项目名称:mutree,代码行数:11,代码来源:ParseRST.java

示例8: 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

示例9: printlnNodeWithNumberAndLabel

import pal.tree.Node; //导入方法依赖的package包/类
private static void printlnNodeWithNumberAndLabel(PrintWriter out, Node node, int level,
        int numExternalNodes, boolean[] umbrella, int[] position) {
    for (int i = 0; i < level - 1; i++) {
        if (umbrella[i]) {
            putCharAtLevel(out, i, '|', position);
        } else {
            putCharAtLevel(out, i, ' ', position);
        }
    }

    putCharAtLevel(out, level - 1, '+', position);

    int branchNumber;
    if (node.isLeaf()) {
        branchNumber = node.getNumber() + 1;
    } else {
        branchNumber = node.getNumber() + 1 + numExternalNodes;
    }

    String numberAsString = Integer.toString(branchNumber);

    int numDashs = position[level] - numberAsString.length();

    for (int i = 0; i < numDashs ; i++) {
        out.print('-');
    }
    out.print(numberAsString);

    if (node.isLeaf()) {
        out.println(" " + node.getIdentifier());
    } else {
        if (!node.getIdentifier().equals(Identifier.ANONYMOUS)) {
            out.print("(" + node.getIdentifier() + ")");
        }
        out.println();
    }
}
 
开发者ID:ddarriba,项目名称:jmodeltest2,代码行数:38,代码来源:TreeUtilities.java

示例10: 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

示例11: 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

示例12: 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

示例13: getAttributes

import pal.tree.Node; //导入方法依赖的package包/类
private Attributes getAttributes(Node node, List<Substitution> substitutions) {

        String name;
        if (node.isLeaf() && names.size() > 0) {
            name = names.get(Integer.parseInt(getSequenceKey(node).split("_")[1]) - 1);
        } else {
            name = getSequenceKey(node);
        }

        Attributes a = new Attributes(Attributes.Key.REALNAME, name);
        a.add(Attributes.Key.NUMBER, Integer.toString(getBranchNumber(node)));

        if (substitutions.size() > 0) a.add(Attributes.Key.ALLSUBS, substitutions.toString());

        Collection<Substitution> nonsynSubs = Collections2.filter(substitutions, Predicates.not(new Substitution.isSynSubPredicate()));
        if (nonsynSubs.size() > 0) a.add(Attributes.Key.NONSYNSUBS, nonsynSubs.toString());

        a.add(Attributes.Key.FULL,
                String.format("%s - %s %s",
                        a.get(Attributes.Key.NUMBER),
                        a.get(Attributes.Key.REALNAME),
                        a.get(Attributes.Key.ALLSUBS)));

        a.add(Attributes.Key.NAME_AND_SUBS,
                String.format("%s %s",
                        a.get(Attributes.Key.REALNAME),
                        a.get(Attributes.Key.NONSYNSUBS)));

        return a;
    }
 
开发者ID:tamuri,项目名称:treesub,代码行数:31,代码来源:ParseRST.java

示例14: getSequenceKey

import pal.tree.Node; //导入方法依赖的package包/类
private String getSequenceKey(Node n) {
    if (n.isLeaf()) {
        return trees[0].getExternalNode(n.getNumber()).getIdentifier().getName();
    } else {
        return "node#" + trees[1].getInternalNode(n.getNumber()).getIdentifier().getName();
    }
}
 
开发者ID:tamuri,项目名称:treesub,代码行数:8,代码来源:ParseRST.java

示例15: 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


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