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


Java Node.getAllLeafNodes方法代码示例

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


在下文中一共展示了Node.getAllLeafNodes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findNode

import beast.evolution.tree.Node; //导入方法依赖的package包/类
private Node findNode(final TreeParser tree, final String[] targetArray) {
    final Node[] treeNodes = tree.getNodesAsArray();
    final Set<String> targetSet = new HashSet<>();
    for (int i = 0; i < targetArray.length; i++) {
        targetSet.add(targetArray[i]);
    }

    for (Node node: treeNodes) {
        Set<String> nodeSet = new HashSet<>();

        if (node.isLeaf()) {
            nodeSet.add(node.getID());
        } else {
            final List<Node> leafNodes = node.getAllLeafNodes();
            for (Node leaf: leafNodes) {
                nodeSet.add(leaf.getID());
            }
        }

        if (targetSet.equals(nodeSet)) {
            return node;
        }
    }

    return null;
}
 
开发者ID:genomescale,项目名称:starbeast2,代码行数:27,代码来源:StarbeastClockTest.java

示例2: visitTree

import beast.evolution.tree.Node; //导入方法依赖的package包/类
@Override
public Node visitTree(@NotNull NewickParser.TreeContext ctx) {
    Node root = visit(ctx.node());

    // Ensure tree is properly sorted in terms of node numbers.
    root.sort();

    // Replace lengths read from Newick with heights.
    convertLengthToHeight(root);

    // Make sure internal nodes are numbered correctly
    numberUnnumberedNodes(root);

    // Check for duplicate taxa
    BitSet nodeNrSeen = new BitSet();
    for (Node leaf : root.getAllLeafNodes()) {
        if (leaf.getNr()<0)
           continue;  // Skip unnumbered leaves

        if (nodeNrSeen.get(leaf.getNr()))
            throw new TreeParsingException("Duplicate taxon found: " + labels.get(leaf.getNr()));
        else
            nodeNrSeen.set(leaf.getNr());
    }

    return root;
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:28,代码来源:TreeParser.java

示例3: generateConstraints

import beast.evolution.tree.Node; //导入方法依赖的package包/类
private static Document generateConstraints (Tree tree, double minConstraintHeight) throws Exception {
	DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
	DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
	Document doc = dBuilder.newDocument();
	List<Node> constraintNodes = getConstraintNodes(tree, minConstraintHeight);
	Element rootElem = doc.createElement("root");
	doc.appendChild(rootElem);
	for (int i = 0; i < constraintNodes.size(); i++) {
		Node n = constraintNodes.get(i);
		List<Node> children = n.getAllLeafNodes();

		Element distElem = doc.createElement("distribution");
		distElem.setAttribute("id", "Constraint_"+(i+1)+".prior");
		distElem.setAttribute("spec", "beast.math.distributions.MRCAPrior");
		distElem.setAttribute("tree", "@Tree.t:GTR1");
		rootElem.appendChild(distElem);

		Element taxonSetElem = doc.createElement("taxonset");
		taxonSetElem.setAttribute("id", "Constraint_"+(i+1));
		taxonSetElem.setAttribute("spec", "TaxonSet");
		distElem.appendChild(taxonSetElem);

		for (Node c : children) {
			Element taxonElem = doc.createElement("taxon");
			taxonElem.setAttribute("id", c.getID());
			taxonElem.setAttribute("spec", "Taxon");
			taxonSetElem.appendChild(taxonElem);
		}

		Element uniformElem = doc.createElement("Uniform");
		uniformElem.setAttribute("id", "Uniform.0"+(i+1));
		uniformElem.setAttribute("name", "distr");
		double height = n.getHeight();
		String upper = Math.ceil(height * 1.1) + "";
		String lower = Math.floor(height * 0.9) + "";
		uniformElem.setAttribute("lower", lower);
		uniformElem.setAttribute("upper", upper);
		distElem.appendChild(uniformElem);
	}
	return doc;
}
 
开发者ID:lutrasdebtra,项目名称:Beast-Borrowing-Plugin,代码行数:42,代码来源:BorrowingComparisonTests.java


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