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


Java Node.setID方法代码示例

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


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

示例1: lengthToHeight

import beast.evolution.tree.Node; //导入方法依赖的package包/类
/** convert length to height
 *  and set ID of leafs
 */
private double lengthToHeight(Node node, double offSet) {
	if (node.isLeaf()) {
		node.setHeight(-offSet - node.getHeight());
		node.setID(m_sLabels.get(node.getNr()));
		return -node.getHeight();
	} else {
		double posY = offSet + node.getHeight();
		double yMax = 0;
		yMax = Math.max(yMax, lengthToHeight(node.getLeft(), posY));
		if (node.getRight() != null) {
			yMax = Math.max(yMax, lengthToHeight(node.getRight(), posY));
		}
		node.setHeight(-posY);
		return yMax;
	}
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:20,代码来源:TreeSetParser.java

示例2: translateLeafIds

import beast.evolution.tree.Node; //导入方法依赖的package包/类
/**
 * Given a map of name translations (string to string),
 * rewrites all leaf ids that match a key in the map
 * to the respective value in the matching key/value pair.
 * If current leaf id is null, then interpret translation keys as node numbers (origin 1)
 * and set leaf id of node n to map.get(n-1).
 *
 * @param translationMap map of name translations
 */
public void translateLeafIds(final Map<String, String> translationMap) {

    for (final Node leaf : getExternalNodes()) {
        String id = leaf.getID();

        if (id == null || !integerLeafLabels) {
            id = Integer.toString(leaf.getNr() + 1);
        }

        final String newId = translationMap.get(id);
        if (newId != null) {
            leaf.setID(newId);
        }
    }
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:25,代码来源:TreeParser.java

示例3: convertTree

import beast.evolution.tree.Node; //导入方法依赖的package包/类
private void convertTree(Node node) {

        if (!node.isLeaf()) {
            if (node.isFake()) {
                Node directAncestor = node.getDirectAncestorChild();
                node.removeChild(directAncestor);
                node.setNr(directAncestor.getNr());
                node.setID(directAncestor.getID());
                directAncestor.setParent(null);
            }
            for (int i = 0; i < node.getChildCount(); i++) {
                Node childNode = node.getChild(i);
                convertTree(childNode);
            }
        }



    }
 
开发者ID:CompEvol,项目名称:sampled-ancestors,代码行数:20,代码来源:ConvertZBTreeToSATree.java

示例4: translateLeafIds

import beast.evolution.tree.Node; //导入方法依赖的package包/类
/**
 * Given a map of name translations (string to string),
 * rewrites all leaf ids that match a key in the map
 * to the respective value in the matching key/value pair.
 * If current leaf id is null, then interpret translation keys as node numbers (origin 1)
 * and set leaf id of node n to map.get(n-1).
 *
 * @param translationMap
 */
public void translateLeafIds(Map<String, String> translationMap) {

    for (Node leaf : getExternalNodes()) {
        String id = leaf.getID();

        if (id == null) {
            id = (leaf.getNr() + 1) + "";
        }

        String newId = translationMap.get(id);
        if (newId != null) {
            leaf.setID(newId);
        }
    }
}
 
开发者ID:CompEvol,项目名称:sampled-ancestors,代码行数:25,代码来源:ZeroBranchSATreeParser.java

示例5: labelNonLabeledNodes

import beast.evolution.tree.Node; //导入方法依赖的package包/类
private void labelNonLabeledNodes(Node node, int[] lastLabel) {

        for (Node child : node.getChildren()) {
            labelNonLabeledNodes(child, lastLabel);
        }
        if (node.getNr() == -1) {
            node.setNr(lastLabel[0] + 1);
            lastLabel[0] += 1;
        } else if (labels != null && node.getNr() < labels.size()) {
            node.setID(labels.get(node.getNr()));
        }
    }
 
开发者ID:CompEvol,项目名称:sampled-ancestors,代码行数:13,代码来源:ZeroBranchSATreeParser.java

示例6: visitNode

import beast.evolution.tree.Node; //导入方法依赖的package包/类
@Override
public Node visitNode(NewickParser.NodeContext ctx) {
    Node node = newNode();

    for (NewickParser.NodeContext ctxChild : ctx.node()) {
        node.addChild(visit(ctxChild));
    }

    NewickParser.PostContext postCtx = ctx.post();

    // Process metadata

    if (postCtx.nodeMeta != null)
        processMetadata(node, postCtx.nodeMeta, false);

    if (postCtx.lengthMeta != null)
        processMetadata(node, postCtx.lengthMeta, true);

    // Process edge length

    if (postCtx.length != null)
        node.setHeight(Double.parseDouble(postCtx.length.getText()));
    else
        node.setHeight(DEFAULT_LENGTH);

    // Process label

    node.setNr(-1);
    if (postCtx.label() != null) {
        node.setID(postCtx.label().getText());

        if (postCtx.label().number() == null
                || postCtx.label().number().INT() == null)
            integerLeafLabels = false;

        // Treat labels as node numbers in certain situations
        if (!isLabelledNewickInput.get()
                && postCtx.label().number() != null
                && postCtx.label().number().INT() != null) {

            int nodeNr = Integer.parseInt(postCtx.label().getText()) - offsetInput.get();
            if (nodeNr<0)
                throw new TreeParsingException("Node number given " +
                        "is smaller than current offset (" +
                        offsetInput.get() + ").  Perhaps offset is " +
                        "too high?");

            node.setNr(nodeNr);
            numberedNodeCount += 1;
        } else {
            if (node.isLeaf()) {
                node.setNr(getLabelIndex(postCtx.label().getText()));
                numberedNodeCount += 1;
            }
        }
    }

    if (node.getChildCount()==1 && !allowSingleChildInput.get())
        throw new TreeParsingException("Node with single child found.");

    // Use length-zero edges to binarize multifurcations.
    if (binarizeMultifurcationsInput.get())
        binarizeMultifurcation(node);


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


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