本文整理汇总了Java中beast.evolution.tree.Tree.assignFromWithoutID方法的典型用法代码示例。如果您正苦于以下问题:Java Tree.assignFromWithoutID方法的具体用法?Java Tree.assignFromWithoutID怎么用?Java Tree.assignFromWithoutID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类beast.evolution.tree.Tree
的用法示例。
在下文中一共展示了Tree.assignFromWithoutID方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initWithMRCACalibrations
import beast.evolution.tree.Tree; //导入方法依赖的package包/类
private void initWithMRCACalibrations(List<MRCAPrior> calibrations) {
final Tree spTree = speciesTreeInput.get();
final RandomTree rnd = new RandomTree();
rnd.setInputValue("taxonset", spTree.getTaxonset());
for( final MRCAPrior cal : calibrations ) {
rnd.setInputValue("constraint", cal);
}
ConstantPopulation pf = new ConstantPopulation();
pf.setInputValue("popSize", new RealParameter("1.0"));
rnd.setInputValue("populationModel", pf);
rnd.initAndValidate();
spTree.assignFromWithoutID((Tree)rnd);
final double rootHeight = spTree.getRoot().getHeight();
randomInitGeneTrees(rootHeight);
}
示例2: initFromNewick
import beast.evolution.tree.Tree; //导入方法依赖的package包/类
private void initFromNewick(final Tree speciesTree, final String newick) {
final TreeParser parser = new TreeParser(newick);
speciesTree.assignFromWithoutID(parser);
System.out.println(speciesTree.toString());
}
示例3: sample
import beast.evolution.tree.Tree; //导入方法依赖的package包/类
/**
* Sampling only implemented for no-origin case currently.
*/
@Override
public void sample(State state, Random random) {
if (sampledFlag)
return;
sampledFlag = true;
// Cause conditional parameters to be sampled
sampleConditions(state, random);
Tree tree = (Tree) treeInput.get();
RealParameter birthRate = birthDiffRateParameterInput.get();
// Simulate tree conditional on new parameters
List<Node> activeLineages = new ArrayList<>();
for (Node oldLeaf : tree.getExternalNodes()) {
Node newLeaf = new Node(oldLeaf.getID());
newLeaf.setNr(oldLeaf.getNr());
newLeaf.setHeight(0.0);
activeLineages.add(newLeaf);
}
int nextNr = activeLineages.size();
double t = 0.0;
while (activeLineages.size() > 1) {
int k = activeLineages.size();
double a = birthRate.getValue() * k;
t += -Math.log(random.nextDouble())/a;
Node node1 = activeLineages.get(random.nextInt(k));
Node node2;
do {
node2 = activeLineages.get(random.nextInt(k));
} while (node2.equals(node1));
Node newParent = new Node();
newParent.setNr(nextNr++);
newParent.setHeight(t);
newParent.addChild(node1);
newParent.addChild(node2);
activeLineages.remove(node1);
activeLineages.remove(node2);
activeLineages.add(newParent);
}
tree.assignFromWithoutID(new Tree(activeLineages.get(0)));
}