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


Java Tree.getNode方法代码示例

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


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

示例1: proposal

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
@Override
public double proposal() {
    Tree tree = treeInput.get(this);

    // randomly select leaf node
    int i = Randomizer.nextInt(taxonIndices.length);
    Node node = tree.getNode(taxonIndices[i]);
    double upper = node.getParent().getHeight();
    //double lower = 0.0;
    //final double newValue = (Randomizer.nextDouble() * (upper -lower)) + lower;

    // scale node
    double scale = (scaleFactor + (Randomizer.nextDouble() * ((1.0 / scaleFactor) - scaleFactor)));
    final double newValue = node.getHeight() * scale;

    // check the tree does not get negative branch lengths
    if (newValue > upper) {
        return Double.NEGATIVE_INFINITY;
    }
    node.setHeight(newValue);

    return -Math.log(scale);
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:24,代码来源:TipDatesScaler.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);

    // randomly select internal node
    final int nodeCount = tree.getNodeCount();
    
    // Abort if no non-root internal nodes
    if (tree.getInternalNodeCount()==1)
        return Double.NEGATIVE_INFINITY;
    
    Node node;
    do {
        final int nodeNr = nodeCount / 2 + 1 + Randomizer.nextInt(nodeCount / 2);
        node = tree.getNode(nodeNr);
    } while (node.isRoot() || node.isLeaf());
    final double upper = node.getParent().getHeight();
    final double lower = Math.max(node.getLeft().getHeight(), node.getRight().getHeight());
    final double newValue = (Randomizer.nextDouble() * (upper - lower)) + lower;
    node.setHeight(newValue);

    return 0.0;
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:29,代码来源:Uniform.java

示例3: setupAttributes

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
private void setupAttributes(Tree tree) {
    for (int i = 0; i < tree.getNodeCount(); i++) {
        Node node = tree.getNode(i);
        Set<String> iter = node.getMetaDataNames();
        if (iter != null) {
        	for (String name : iter) {
                attributeNames.add(name);
            }
        }
    }

    for (TreeAnnotationPlugin beastObject : beastObjects) {
        Set<String> claimed = beastObject.setAttributeNames(attributeNames);
        attributeNames.removeAll(claimed);
    }
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:17,代码来源:TreeAnnotator.java

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

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

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

示例7: wide

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
/**
 * @param tree
 */
public double wide(final Tree tree) {

    final int nodeCount = tree.getNodeCount();

    //make sure that there are at least two distinct non-root nodes which are not direct ancestors.
    if (nodeCount == 3 && (tree.getRoot()).isFake()) {
        return Double.NEGATIVE_INFINITY;
    }

    Node i, j, iP, jP;
    do {
        i = tree.getNode(Randomizer.nextInt(nodeCount));
    } while (i.isRoot() || (i).isDirectAncestor());

    do {
        j = tree.getNode(Randomizer.nextInt(nodeCount));
    } while (j.getNr() == i.getNr() || j.isRoot() || (j).isDirectAncestor());

    iP = i.getParent();
    jP = j.getParent();

    if ((iP != jP) && (i != jP) && (j != iP)
            && (j.getHeight() < iP.getHeight())
            && (i.getHeight() < jP.getHeight())) {
        exchangeNodes(i, j, iP, jP);

        return 0.0;
    }

    // Couldn't find valid wide move on this beast.tree!
    return Double.NEGATIVE_INFINITY;
}
 
开发者ID:CompEvol,项目名称:sampled-ancestors,代码行数:36,代码来源:SAExchange.java

示例8: wide

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
/**
 * @param tree
 */
public double wide(final Tree tree) {

    final int nodeCount = tree.getNodeCount();

    //make sure that there are at least two distinct non-root nodes which are not direct ancestors.
    if (nodeCount == 3 && ((ZeroBranchSANode)tree.getRoot()).isFake()) {
        return Double.NEGATIVE_INFINITY;
    }

    Node i, j, iP, jP;
    do {
        i = tree.getNode(Randomizer.nextInt(nodeCount));
    } while (i.isRoot() || ((ZeroBranchSANode)i).isDirectAncestor());

    do {
        j = tree.getNode(Randomizer.nextInt(nodeCount));
    } while (j.getNr() == i.getNr() || j.isRoot() || ((ZeroBranchSANode)j).isDirectAncestor());

    iP = i.getParent();
    jP = j.getParent();

    if ((iP != jP) && (i != jP) && (j != iP)
            && (j.getHeight() < iP.getHeight())
            && (i.getHeight() < jP.getHeight())) {
        exchangeNodes(i, j, iP, jP);

        return 0.0;
    }

    // Couldn't find valid wide move on this beast.tree!
    return Double.NEGATIVE_INFINITY;
}
 
开发者ID:CompEvol,项目名称:sampled-ancestors,代码行数:36,代码来源:ExchangeForZeroBranchSampledAncestorTrees.java

示例9: collectTimes

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
/**
 * extract coalescent times and tip information into array times from tree.
 */
private static void collectTimes(Tree tree, double[] times, int[] childCounts) {

    for (int i = 0; i < tree.getNodeCount(); i++) {
        NodeRef node = tree.getNode(i);
        times[i] = tree.getNodeHeight(node);
        childCounts[i] = tree.getChildCount(node);
    }
}
 
开发者ID:armanbilge,项目名称:B3,代码行数:12,代码来源:TreeIntervals.java

示例10: narrow

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
public double narrow(final Tree tree) {

        final int nodeCount = tree.getNodeCount();

        //make sure that there are at least two distinct non-root nodes which are not direct ancestors.
        if (nodeCount == 3 && (tree.getRoot()).isFake()) {
            return Double.NEGATIVE_INFINITY;
        }

        Node i;
        do {
            i = tree.getNode(Randomizer.nextInt(nodeCount));
        } while (i.isRoot() || i.getParent().isRoot() || (i).isDirectAncestor());

        final Node iParent = i.getParent();
        final Node iGrandParent = iParent.getParent();
        Node iUncle = iGrandParent.getLeft();
        if (iUncle.getNr() == iParent.getNr()) {
            iUncle = iGrandParent.getRight();
            //assert (iUncle.getNr() != iParent.getNr());
        }
        //assert iUncle == getOtherChild(iGrandParent, iParent);

        //assert i.getHeight() <= iGrandParent.getHeight();

        if (iUncle.getHeight() < iParent.getHeight()) {
            exchangeNodes(i, iUncle, iParent, iGrandParent);
            return 0.0;
        } else {
            // Couldn't find valid narrow move on this beast.tree!!
            return Double.NEGATIVE_INFINITY;
        }

//        final int nInternalNodes = tree.getInternalNodeCount();  //TODO look if I can implement this more efficient code for SA trees
//        final int leafNodeCount = tree.getLeafNodeCount();
//        // make sure that the tree has at least two internal nodes
//        if (nInternalNodes <= 1 ) {
//            return Double.NEGATIVE_INFINITY;
//        }
//
//        //choose one of internal nodes that has at least one non-leaf node
//        //(there is always at least one such node as long as the tree has at least 2 internal nodes)
//        Node iGrandParent;
//        do  {
//            iGrandParent = tree.getNode(leafNodeCount + Randomizer.nextInt(nInternalNodes));
//        } while (iGrandParent.getLeft().isLeaf() && iGrandParent.getRight().isLeaf());
//
//        Node iParent = iGrandParent.getLeft();
//        Node iUncle = iGrandParent.getRight();
//        if (iParent.getHeight() < iUncle.getHeight()) {
//            iParent = iGrandParent.getRight();
//            iUncle = iGrandParent.getLeft();
//        }
//
//        if( iParent.isLeaf() ) {
//            return Double.NEGATIVE_INFINITY;
//        }
//
//        final Node i;
//
//        if (iParent.isFake()) {
//            if (iParent.getLeft().isDirectAncestor()) {
//                i = iParent.getRight();
//            }  else i = iParent.getLeft();
//        }  else {
//            i = (Randomizer.nextBoolean() ? iParent.getLeft() : iParent.getRight());
//        }
//
//        exchangeNodes(i, iUncle, iParent, iGrandParent);
//
//        return 0.0;

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

示例11: narrow

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
public double narrow(final Tree tree) {

        final int nodeCount = tree.getNodeCount();

        //make sure that there are at least two distinct non-root nodes which are not direct ancestors.
        if (nodeCount == 3 && ((ZeroBranchSANode)tree.getRoot()).isFake()) {
            return Double.NEGATIVE_INFINITY;
        }

        Node i;
        do {
            i = tree.getNode(Randomizer.nextInt(nodeCount));
        } while (i.isRoot() || i.getParent().isRoot() || ((ZeroBranchSANode)i).isDirectAncestor());

        final Node iParent = i.getParent();
        final Node iGrandParent = iParent.getParent();
        Node iUncle = iGrandParent.getLeft();
        if (iUncle.getNr() == iParent.getNr()) {
            iUncle = iGrandParent.getRight();
            //assert (iUncle.getNr() != iParent.getNr());
        }
        //assert iUncle == getOtherChild(iGrandParent, iParent);

        //assert i.getHeight() <= iGrandParent.getHeight();

        if (iUncle.getHeight() < iParent.getHeight()) {
            exchangeNodes(i, iUncle, iParent, iGrandParent);
            return 0.0;
        } else {
            // Couldn't find valid narrow move on this beast.tree!!
            return Double.NEGATIVE_INFINITY;
        }

//        final int nInternalNodes = tree.getInternalNodeCount();  //TODO look if I can implement this more efficient code for SA trees
//        final int leafNodeCount = tree.getLeafNodeCount();
//        // make sure that the tree has at least two internal nodes
//        if (nInternalNodes <= 1 ) {
//            return Double.NEGATIVE_INFINITY;
//        }
//
//        //choose one of internal nodes that has at least one non-leaf node
//        //(there is always at least one such node as long as the tree has at least 2 internal nodes)
//        Node iGrandParent;
//        do  {
//            iGrandParent = tree.getNode(leafNodeCount + Randomizer.nextInt(nInternalNodes));
//        } while (iGrandParent.getLeft().isLeaf() && iGrandParent.getRight().isLeaf());
//
//        Node iParent = iGrandParent.getLeft();
//        Node iUncle = iGrandParent.getRight();
//        if (iParent.getHeight() < iUncle.getHeight()) {
//            iParent = iGrandParent.getRight();
//            iUncle = iGrandParent.getLeft();
//        }
//
//        if( iParent.isLeaf() ) {
//            return Double.NEGATIVE_INFINITY;
//        }
//
//        final Node i;
//
//        if (iParent.isFake()) {
//            if (iParent.getLeft().isDirectAncestor()) {
//                i = iParent.getRight();
//            }  else i = iParent.getLeft();
//        }  else {
//            i = (Randomizer.nextBoolean() ? iParent.getLeft() : iParent.getRight());
//        }
//
//        exchangeNodes(i, iUncle, iParent, iGrandParent);
//
//        return 0.0;

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


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