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


Java Node.getNr方法代码示例

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


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

示例1: serialize

import beast.evolution.tree.Node; //导入方法依赖的package包/类
@Override
public void serialize(Node speciesTreeNode, StringBuffer buf, DecimalFormat df) {
    final RealParameter tipPopSizes = tipPopSizesInput.get();
    final RealParameter topPopSizes = topPopSizesInput.get();
    final int speciesTreeNodeNumber = speciesTreeNode.getNr();

    double branchTipPopSize;
    if (speciesTreeNode.isLeaf()) {
        branchTipPopSize = tipPopSizes.getValue(speciesTreeNodeNumber);
    } else {
        final int leftChildTopI = speciesTreeNode.getLeft().getNr();
        final int rightChildTopI = speciesTreeNode.getRight().getNr();
        branchTipPopSize = topPopSizes.getValue(leftChildTopI) + topPopSizes.getValue(rightChildTopI);
    }

    final double branchTopPopSize = (speciesTreeNode.isRoot()) ? branchTipPopSize : topPopSizes.getValue(speciesTreeNode.getNr());

    if (df == null) buf.append("dmv={" + branchTopPopSize + "," + branchTipPopSize + "}");
    else buf.append("dmv={" + df.format(branchTopPopSize) + "," + df.format(branchTipPopSize) + "}");
}
 
开发者ID:genomescale,项目名称:starbeast2,代码行数:21,代码来源:LinearWithConstantRoot.java

示例2: getConnectingNodes

import beast.evolution.tree.Node; //导入方法依赖的package包/类
private SetMultimap<Integer, Node> getConnectingNodes(Node speciesTreeNode, MinimumDouble tipwardFreedom) {
    final Node leftChildNode = speciesTreeNode.getLeft();
    final Node rightChildNode = speciesTreeNode.getRight();
    final int leftChildNodeNumber = leftChildNode.getNr();
    final int rightChildNodeNumber = rightChildNode.getNr();
    final Set<String> leftChildDescendants = findDescendants(leftChildNode, leftChildNodeNumber);
    final Set<String> rightChildDescendants = findDescendants(rightChildNode, rightChildNodeNumber);

    final SetMultimap<Integer, Node> allConnectingNodes = HashMultimap.create();
    final List<Tree> geneTrees = geneTreeInput.get();
    for (int j = 0; j < nGeneTrees; j++) {
        final Tree geneTree = geneTrees.get(j);
        final Node geneTreeRootNode = geneTree.getRoot();
        final Set<Node> jConnectingNodes = new HashSet<Node>();
        findConnectingNodes(geneTreeRootNode, jConnectingNodes, leftChildDescendants, rightChildDescendants, tipwardFreedom);
        allConnectingNodes.putAll(j, jConnectingNodes);
        geneTree.startEditing(null); // hack to stop beast.core.State.Trie memory leak
    }

    return allConnectingNodes;
}
 
开发者ID:genomescale,项目名称:starbeast2,代码行数:22,代码来源:CoordinatedExponential.java

示例3: findDescendants

import beast.evolution.tree.Node; //导入方法依赖的package包/类
protected Set<String> findDescendants(Node speciesTreeNode, int speciesTreeNodeNumber) {
    final Multimap<Integer, String> numberTipMap = speciesTreeInput.get().getNumberTipMap();
    final Set<String> descendantNames = new HashSet<>();

    if (speciesTreeNode.isLeaf()) {
        descendantNames.addAll(numberTipMap.get(speciesTreeNodeNumber));
    } else {
        final Node leftChild = speciesTreeNode.getLeft();
        final Node rightChild = speciesTreeNode.getRight();
        final int leftChildNumber = leftChild.getNr();
        final int rightChildNumber = rightChild.getNr();

        descendantNames.addAll(findDescendants(leftChild, leftChildNumber));
        descendantNames.addAll(findDescendants(rightChild, rightChildNumber));
    }

    return descendantNames;
}
 
开发者ID:genomescale,项目名称:starbeast2,代码行数:19,代码来源:CoordinatedOperator.java

示例4: getGraftBranches

import beast.evolution.tree.Node; //导入方法依赖的package包/类
protected SetMultimap<Integer, Node> getGraftBranches(Node yNode) {
    final int yNumber = yNode.getNr();
    final Set<String> cousinDescendants = findDescendants(yNode, yNumber);

    final SetMultimap<Integer, Node> allGraftBranches = HashMultimap.create();
    final List<Tree> geneTrees = geneTreeInput.get();
    for (int j = 0; j < nGeneTrees; j++) {
        final Tree geneTree = geneTrees.get(j);
        final Node geneTreeRootNode = geneTree.getRoot();
        final Set<Node> jGraftBranches = new LinkedHashSet<>();
        findGraftBranches(geneTreeRootNode, jGraftBranches, cousinDescendants);
        allGraftBranches.putAll(j, jGraftBranches);
    }

    return allGraftBranches;
}
 
开发者ID:genomescale,项目名称:starbeast2,代码行数:17,代码来源:CoordinatedExchange.java

示例5: compare

import beast.evolution.tree.Node; //导入方法依赖的package包/类
@Override
public int compare(Node nodeA, Node nodeB) {
    final double heightA = nodeA.getHeight();
    final double heightB = nodeB.getHeight();
    if (heightA == heightB) {
        final int depthA = calculateNodeDepth(nodeA);
        final int depthB = calculateNodeDepth(nodeB);
        if (depthA == depthB) {
            final int nodeNumberA = nodeA.getNr();
            final int nodeNumberB = nodeB.getNr();
            if (nodeNumberA == nodeNumberB) {
                return 0;
            }
            return nodeNumberA > nodeNumberB ? greaterThan : lessThan;
        }
        return depthA > depthB ? greaterThan : lessThan;
    }
    return heightA > heightB ? greaterThan : lessThan;
}
 
开发者ID:genomescale,项目名称:starbeast2,代码行数:20,代码来源:NodeHeightComparator.java

示例6: recurseBranchRates

import beast.evolution.tree.Node; //导入方法依赖的package包/类
/**
 * This is a recursive function that does the work of
 * calculating the unscaled branch rates across the tree
 * taking into account the indicator variables.
 *
 * @param node the node
 * @param rate the rate of the parent node
 */
private void recurseBranchRates(Node node, double parentHeight, double rate, Boolean[] indicators, Double[] branchRates) {
    final int nodeNumber = node.getNr();
    final double nodeHeight = node.getHeight();

    // not the root, and indicator is "on"
    if (nodeNumber < rootNodeNumber && indicators[nodeNumber]) {
        rate = branchRates[nodeNumber];
    }

    double branchLength = parentHeight - nodeHeight;
    strictRatesTotal += branchLength;
    relaxedRatesTotal += branchLength * rate;

    ratesArray[nodeNumber] = rate;

    if (!node.isLeaf()) {
        recurseBranchRates(node.getLeft(), nodeHeight, rate, indicators, branchRates);
        recurseBranchRates(node.getRight(), nodeHeight, rate, indicators, branchRates);
    }
}
 
开发者ID:genomescale,项目名称:starbeast2,代码行数:29,代码来源:RandomLocalRates.java

示例7: getConnectingNodes

import beast.evolution.tree.Node; //导入方法依赖的package包/类
private SetMultimap<Integer, Node> getConnectingNodes(Node speciesTreeNode, MinimumDouble tipwardFreedom, MinimumDouble rootwardFreedom) {
    final Node leftChildNode = speciesTreeNode.getLeft();
    final Node rightChildNode = speciesTreeNode.getRight();
    final int leftChildNodeNumber = leftChildNode.getNr();
    final int rightChildNodeNumber = rightChildNode.getNr();
    final Set<String> leftChildDescendants = findDescendants(leftChildNode, leftChildNodeNumber);
    final Set<String> rightChildDescendants = findDescendants(rightChildNode, rightChildNodeNumber);

    final SetMultimap<Integer, Node> allConnectingNodes = HashMultimap.create();
    final List<Tree> geneTrees = geneTreeInput.get();
    for (int j = 0; j < nGeneTrees; j++) {
        final Tree geneTree = geneTrees.get(j);
        final Node geneTreeRootNode = geneTree.getRoot();
        final Set<Node> jConnectingNodes = new HashSet<Node>();
        findConnectingNodes(geneTreeRootNode, jConnectingNodes, leftChildDescendants, rightChildDescendants, tipwardFreedom, rootwardFreedom);
        allConnectingNodes.putAll(j, jConnectingNodes);
        geneTree.startEditing(null); // hack to stop beast.core.State.Trie memory leak
    }

    return allConnectingNodes;
}
 
开发者ID:genomescale,项目名称:starbeast2,代码行数:22,代码来源:CoordinatedUniform.java

示例8: removeSingleChildNodes

import beast.evolution.tree.Node; //导入方法依赖的package包/类
/**
 * Extract the sampled tree by discarding all the nodes that have -1 number simultaneously suppress single
 * child nodes (nodes with only one child numbered by non-negative number)
 * @param node
 */
public void removeSingleChildNodes(Node node) {
    if (!node.isLeaf()) {
        Node left = node.getLeft();
        Node right = node.getRight();

        removeSingleChildNodes(left);
        removeSingleChildNodes(right);
        for (Node child:node.getChildren()) {
            if (child.getNr() == -1) {
                node.removeChild(child);
            }
        }
        if (node.getChildCount() == 1 && node.getParent() != null) {
            Node parent = node.getParent();
            Node newChild =  node.getLeft();
            parent.removeChild(node);
            parent.addChild(newChild);
            newChild.setParent(parent);
            //node.setParent(null);
        }
    }
}
 
开发者ID:CompEvol,项目名称:sampled-ancestors,代码行数:28,代码来源:SABDSkylineTreeSimulator.java

示例9: getRawRateForCategory

import beast.evolution.tree.Node; //导入方法依赖的package包/类
/**
 * @param node the node to get the rate of
 * @return the rate of the branch
 */
private double getRawRateForCategory(Node node) {

    int nodeNumber = node.getNr();
    if (nodeNumber == branchCount) {
        // root node has nr less than #categories, so use that nr
        nodeNumber = node.getTree().getRoot().getNr();
    }

    int category = categories.getValue(nodeNumber);

    if (rates[category] == 0.0) {
        try {
            rates[category] = distribution.inverseCumulativeProbability((category + 0.5) / rates.length);
        } catch (MathException e) {
            throw new RuntimeException("Failed to compute inverse cumulative probability!");
        }
    }
    return rates[category];
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:24,代码来源:UCRelaxedClockModel.java

示例10: getTreeCladeCodes

import beast.evolution.tree.Node; //导入方法依赖的package包/类
int getTreeCladeCodes(Node node, BitSet[] codes) {
    final int inode = node.getNr();
    codes[inode].clear();
    if (node.isLeaf()) {
        int index = getTaxonIndex(node);//getTaxonIndex(node);
        codes[inode].set(index);
    } else {
        for (int i = 0; i < node.getChildCount(); i++) {
            final Node child = node.getChild(i);
            final int childIndex = getTreeCladeCodes(child, codes);

            codes[inode].or(codes[childIndex]);
        }
    }
    return inode;
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:17,代码来源:CladeSystem.java

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

示例12: processSampleEvent

import beast.evolution.tree.Node; //导入方法依赖的package包/类
protected void processSampleEvent(int interval) {
  	int sampleState;
List<Node> incomingLines = intervals.getLineagesAdded(interval);
for (Node l : incomingLines) {			
	/* uses pre-computed nodeNrToState */
	sampleState = nodeNrToState[l.getNr()];	/* suceeds if node is a leaf, otherwise state=-1 */	
	DoubleMatrix sVec = DoubleMatrix.zeros(1,numStates); // row-vector
	sVec.put(sampleState, 1.0);
	stateProbabilities.addLineage(l.getNr(),sVec);
}	
  }
 
开发者ID:mrc-ide,项目名称:PhyDyn,代码行数:12,代码来源:STreeLikelihood.java

示例13: isDirtyBranch

import beast.evolution.tree.Node; //导入方法依赖的package包/类
@Override
public boolean isDirtyBranch(Node speciesNode) {
    if (needsUpdate) {
        final RealParameter tipPopSizes = tipPopSizesInput.get();
        final RealParameter topPopSizes = topPopSizesInput.get();

        Arrays.fill(speciesBranchStatus, false);
        Node[] speciesNodes = speciesTree.getNodesAsArray();

        // non-root nodes (linear population sizes)
        for (int nodeI = 0; nodeI < speciesNodes.length; nodeI++) {
            // if the "top" population is dirty, no need to check the tip
            if (nodeI < rootNodeNumber && topPopSizes.isDirty(nodeI)) { // not the root node
                speciesBranchStatus[nodeI] = true;
                continue;
            }

            if (nodeI < leafNodeCount) { // is a leaf node
                speciesBranchStatus[nodeI] = tipPopSizes.isDirty(nodeI);
            } else { // is an internal node
                final Node leftChild = speciesNodes[nodeI].getLeft();
                final Node rightChild = speciesNodes[nodeI].getRight();
                final int leftChildTopI = leftChild.getNr();
                final int rightChildTopI = rightChild.getNr();
                speciesBranchStatus[nodeI] = topPopSizes.isDirty(leftChildTopI) ||
                        topPopSizes.isDirty(rightChildTopI) ||
                        leftChild.isDirty() != Tree.IS_CLEAN ||
                        rightChild.isDirty() != Tree.IS_CLEAN;
            }
        }

        //Arrays.fill(speciesBranchStatus, true);
        needsUpdate = false;
    }

    return speciesBranchStatus[speciesNode.getNr()];
}
 
开发者ID:genomescale,项目名称:starbeast2,代码行数:38,代码来源:LinearWithConstantRoot.java

示例14: getRateForBranch

import beast.evolution.tree.Node; //导入方法依赖的package包/类
@Override
public double getRateForBranch(Node node) {
    if (needsUpdate) {
        update();
    }

    return branchRates[node.getNr()];
}
 
开发者ID:genomescale,项目名称:starbeast2,代码行数:9,代码来源:StarBeastClock.java

示例15: checkConsistency

import beast.evolution.tree.Node; //导入方法依赖的package包/类
private boolean checkConsistency(final Node node, final boolean[] used) {
    if (used[node.getNr()]) {
        // used twice? tha's bad
        return false;
    }
    used[node.getNr()] = true;
    if ( node.isLeaf() ) {
        return true;
    }
    return checkConsistency(node.getLeft(), used) && checkConsistency(node.getRight(), used);
}
 
开发者ID:genomescale,项目名称:starbeast2,代码行数:12,代码来源:NodeReheight2.java


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