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


Java Tree.getLeafNodeCount方法代码示例

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


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

示例1: calculateTreeLogLikelihood

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
protected double calculateTreeLogLikelihood(final Tree tree, final double rho, final double a) {
    final int taxonCount = tree.getLeafNodeCount();
    final double r = birthDiffRateParameterInput.get().getValue();

    double logL = logTreeProbability(taxonCount, r, rho, a);
    double scaleFactor;
    if(scalerParameter == null){
        scaleFactor = scaler.getScaleFactor();
    }else{
        scaleFactor = scalerParameter.getValue();
    }
    final Node [] nodes = tree.getNodesAsArray();
    for (int i = taxonCount; i < nodes.length; i++) {
        assert ( ! nodes[i].isLeaf() );
        logL += calcLogNodeProbability(nodes[i], r, rho, a, taxonCount,scaleFactor);
    }

    return logL;
}
 
开发者ID:jessiewu,项目名称:substBMA,代码行数:20,代码来源:YuleModelWithScaling.java

示例2: proposal

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
/**
 * change the parameter and return the hastings ratio.
 *
 * @return log of Hastings Ratio, or Double.NEGATIVE_INFINITY if proposal should not be accepted *
 */
@Override
public double proposal() {
    final Tree tree = treeInput.get(this);
    final int nNodeCount = tree.getNodeCount();
    int leafNodeCount = tree.getLeafNodeCount();

    //make sure that there is at least one non-fake and non-root internal node
    int fakeNodeCount = ((ZeroBranchSATree)tree).getDirectAncestorNodeCount();
    if (fakeNodeCount == leafNodeCount-1 || (fakeNodeCount == leafNodeCount-2 && !((ZeroBranchSANode)tree.getRoot()).isFake())) {
        return Double.NEGATIVE_INFINITY;
    }

    // randomly select internal node
    Node node;
    do {
        node = tree.getNode(leafNodeCount + Randomizer.nextInt(nNodeCount / 2));
    } while (node.isRoot() || ((ZeroBranchSANode)node).isFake());
    final double fUpper = node.getParent().getHeight();
    final double fLower = Math.max(node.getLeft().getHeight(), node.getRight().getHeight());
    final double newValue = (Randomizer.nextDouble() * (fUpper - fLower)) + fLower;
    node.setHeight(newValue);

    return 0.0;
}
 
开发者ID:CompEvol,项目名称:sampled-ancestors,代码行数:30,代码来源:UniformForZeroBranchSATrees.java

示例3: proposal

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
/**
 * change the parameter and return the hastings ratio.
 *
 * @return log of Hastings Ratio, or Double.NEGATIVE_INFINITY if proposal should not be accepted *
 */
@Override
public double proposal() {
    final Tree tree = treeInput.get(this);
    final int nNodeCount = tree.getNodeCount();
    int leafNodeCount = tree.getLeafNodeCount();

    //make sure that there is at least one non-fake and non-root internal node
    int fakeNodeCount = tree.getDirectAncestorNodeCount();
    if (fakeNodeCount == leafNodeCount-1 || (fakeNodeCount == leafNodeCount-2 && !tree.getRoot().isFake())) {
        return Double.NEGATIVE_INFINITY;
    }

    // randomly select internal node
    Node node;
    do {
        node = tree.getNode(leafNodeCount + Randomizer.nextInt(nNodeCount / 2));
    } while (node.isRoot() || node.isFake());
    final double fUpper = node.getParent().getHeight();
    final double fLower = Math.max(node.getLeft().getHeight(), node.getRight().getHeight());
    final double newValue = (Randomizer.nextDouble() * (fUpper - fLower)) + fLower;
    node.setHeight(newValue);

    return 0.0;
}
 
开发者ID:CompEvol,项目名称:sampled-ancestors,代码行数:30,代码来源:SAUniform.java

示例4: changeTaxaNumbers

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
public void changeTaxaNumbers(Tree tree, Map<String,String> newTranslationMap) {
    for (int i=0; i < tree.getLeafNodeCount(); i++) {
        String taxon = newTranslationMap.get(String.valueOf(i));
        int oldIndex = i;
        for (int j=i; j < tree.getLeafNodeCount(); j++) {
            if (tree.getNode(j).getID().equals(taxon)) {
                oldIndex = j;
                break;
            }
        }
        if (i != oldIndex) {
            tree.getNode(i).setNr(oldIndex);
            tree.getNode(oldIndex).setNr(i);
            // tree.initArray          TODO implement this, but an array of nodes is private so...
        }

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

示例5: makeTreeSummaryForAllTrees

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
private SATreeComparingAnalysis.TreeSummary[] makeTreeSummaryForAllTrees(List<Tree> trees, int treeCount){
    SATreeComparingAnalysis.TreeSummary[] treeSummary = new TreeSummary[treeCount];
    for(int treeIndex=0; treeIndex < treeCount; treeIndex++) {
        Tree tree = trees.get(treeIndex);
        ArrayList<Integer> dAPattern = new ArrayList<Integer>();
        for (int i=tree.getLeafNodeCount(); i< tree.getNodeCount(); i++){
            if (((ZeroBranchSANode)tree.getNode(i)).isFake()) {
                int descendantsCount = tree.getNode(i).getLeafNodeCount() - 1;
                if (descendantsCount > 0) {
                    for(int j=dAPattern.size(); j<descendantsCount; j++){
                        dAPattern.add(0);
                    }
                    int tmp = dAPattern.get(descendantsCount-1);
                    tmp++;
                    dAPattern.set(descendantsCount - 1, tmp);
                }
            }
        }
        treeSummary[treeIndex] = new TreeSummary(tree.getRoot().getHeight(), tree.getLeafNodeCount() - ((ZeroBranchSATree)tree).getDirectAncestorNodeCount(), dAPattern);
    }
    return treeSummary;
}
 
开发者ID:CompEvol,项目名称:sampled-ancestors,代码行数:23,代码来源:SATreeComparingAnalysis.java

示例6: listSA

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
/**
 * retern the list of sampled ancestors, WARNING works only for zeroBranchTrees
 * @param tree
 * @return
 */
public ArrayList<String> listSA(Tree tree, boolean useRanking){
    ArrayList<String> sampledAncestors = new ArrayList<String>();
    count = 0;
    for (int i=0; i<tree.getLeafNodeCount(); i++){
        if (((ZeroBranchSANode)tree.getNode(i)).isDirectAncestor()) {
            if (useRanking) {
                sampledAncestors.add(Integer.toString(getRank(tree, tree.getNode(i))));
            } else {
                sampledAncestors.add(tree.getNode(i).getID());
                if (tree.getNode(i).getID().equals("0")) {
                    count++;
                }
            }
        }
    }
    return  sampledAncestors;
}
 
开发者ID:CompEvol,项目名称:sampled-ancestors,代码行数:23,代码来源:SampledAncestorTreeAnalysis.java

示例7: resetGeneTreeTipHeights

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
private void resetGeneTreeTipHeights() {
   	final SpeciesTreeInterface speciesTree = speciesTreeInput.get();
       final Map<String, Integer> tipNames = speciesTree.getTipNumberMap();
       final List<Tree> geneTrees = genes.get();

       for (final Tree gtree : geneTrees) {
       	final int leafNodeCount = gtree.getLeafNodeCount();
       	for (int geneLeafNr = 0; geneLeafNr < leafNodeCount; geneLeafNr++) {
       		final Node geneLeaf = gtree.getNode(geneLeafNr);
       		final int speciesLeafNr = tipNames.get(geneLeaf.getID());
       		final Node speciesLeaf = speciesTree.getNode(speciesLeafNr);
       		geneLeaf.setHeight(speciesLeaf.getHeight());
       	}
       }
}
 
开发者ID:genomescale,项目名称:starbeast2,代码行数:16,代码来源:StarBeastInitializer.java

示例8: getNodesToOperateOn

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
private List<Node> getNodesToOperateOn() {
    Tree tree = treeInput.get();

    ArrayList<Node> nodeList = new ArrayList<>();

    if (useNodeNumbers) {
        int leafNodeCount = tree.getLeafNodeCount();
    }  else {
        for (int i = 0; i < taxonIndices.length; i++) {
            nodeList.add(tree.getNode(taxonIndices[i]));
        }
    }
    return nodeList;
}
 
开发者ID:CompEvol,项目名称:sampled-ancestors,代码行数:15,代码来源:SampledNodeDateRandomWalkerForZeroBranchSATrees.java

示例9: listSA

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
/**
 * retern the list of sampled ancestors
 * @param tree
 * @return
 */
public ArrayList<String> listSA(Tree tree, boolean useRanking){
    ArrayList<String> sampledAncestors = new ArrayList<String>();
    for (int i=0; i<tree.getLeafNodeCount(); i++){
        if (tree.getNode(i).isDirectAncestor()) {
            if (useRanking) {
                sampledAncestors.add(Integer.toString(getRank(tree, tree.getNode(i))));
            } else {
                sampledAncestors.add(tree.getNode(i).getID());
            }
        }
    }
    return  sampledAncestors;
}
 
开发者ID:CompEvol,项目名称:sampled-ancestors,代码行数:19,代码来源:SATreeTraceAnalysis.java

示例10: getCanonicalNodeSpacing

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
private double getCanonicalNodeSpacing(Tree tree) {
    return 1.0 / (tree.getLeafNodeCount() - 1);
}
 
开发者ID:CompEvol,项目名称:beastshell,代码行数:4,代码来源:TreeComponent.java

示例11: main

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
public static void main (String[] arg) throws Exception{


        Node root = new Node();
        root.setNr(4);
        root.setHeight(2.0);
        Node left = new Node();
        left.setNr(3);
        left.setHeight(1.0);
        root.setLeft(left);
        left.setParent(root);
        Node right = new Node();
        right.setNr(2);
        right.setHeight(2.0);
        root.setRight(right);
        right.setParent(root);
        Node leftLeft = new Node();
        leftLeft.setNr(0);
        leftLeft.setHeight(0.0);
        left.setLeft(leftLeft);
        leftLeft.setParent(left);
        Node leftRight = new Node();
        leftRight.setNr(1);
        leftRight.setHeight(1.0);
        left.setRight(leftRight);
        leftRight.setParent(left);
        Tree tree = new Tree(root);

        System.out.println("The tree is " + tree.getRoot().toShortNewick(false));


        SATreeComparingAnalysis analysis = new SATreeComparingAnalysis();
        //process tree. consider Fake SA trees
        ArrayList<Integer> dAPattern = new ArrayList<Integer>();
        for (int i=tree.getLeafNodeCount(); i< tree.getNodeCount(); i++){
            if (((ZeroBranchSANode)tree.getNode(i)).isFake()) {
                int descendantsCount = tree.getNode(i).getLeafNodeCount() - 1;
                if (descendantsCount > 0) {
                    for(int j=dAPattern.size(); j<descendantsCount; j++){
                        dAPattern.add(0);
                    }
                    int tmp = dAPattern.get(descendantsCount-1);
                    tmp++;
                    dAPattern.set(descendantsCount - 1, tmp);
                }
            }
        }

        SATreeComparingAnalysis.TreeSummary treeSummary = analysis.new TreeSummary(tree.getRoot().getHeight(), tree.getLeafNodeCount() - ((ZeroBranchSATree)tree).getDirectAncestorNodeCount(), dAPattern);

        System.out.println(treeSummary.dAPattern.toString());
        ArrayList<Integer> a = new ArrayList<Integer> (Arrays.asList(new Integer[]{1, 1}));
        System.out.println(treeSummary.dAPattern.equals(a));
    }
 
开发者ID:CompEvol,项目名称:sampled-ancestors,代码行数:55,代码来源:SATreeComparingAnalysis.java


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