本文整理汇总了Java中dr.evomodel.coalescent.CoalescentSimulator类的典型用法代码示例。如果您正苦于以下问题:Java CoalescentSimulator类的具体用法?Java CoalescentSimulator怎么用?Java CoalescentSimulator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CoalescentSimulator类属于dr.evomodel.coalescent包,在下文中一共展示了CoalescentSimulator类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doOperation
import dr.evomodel.coalescent.CoalescentSimulator; //导入依赖的package包/类
/**
* change the parameter and return the hastings ratio.
*/
public double doOperation() {
CoalescentSimulator simulator = new CoalescentSimulator();
List<TaxonList> taxonLists = new ArrayList<TaxonList>();
double rootHeight = -1.0;
double oldLikelihood = 0.0;
double newLikelihood = 0.0;
// should have one child that is node
for (int i = 0; i < xo.getChildCount(); i++) {
final Object child = xo.getChild(i);
//careful: Trees are TaxonLists ... (AER); see OldCoalescentSimulatorParser
if (child instanceof Tree) {
//do nothing
} else if (child instanceof TaxonList) {
//taxonLists.add((TaxonList) child);
taxonLists.add((Taxa) child);
//taxa added
break;
}
}
try {
Tree[] trees = new Tree[taxonLists.size()];
// simulate each taxonList separately
for (int i = 0; i < taxonLists.size(); i++) {
trees[i] = simulator.simulateTree(taxonLists.get(i), demoModel);
}
oldLikelihood = coalescent.getLogLikelihood();
SimpleTree simTree = simulator.simulateTree(trees, demoModel, rootHeight, trees.length != 1);
//this would be the normal way to do it
treeModel.beginTreeEdit();
//now it's allowed to adjust the tree structure
treeModel.adoptTreeStructure(simTree);
//endTreeEdit() would then fire the events
treeModel.endTreeEdit();
newLikelihood = coalescent.getLogLikelihood();
} catch (IllegalArgumentException iae) {
try {
throw new XMLParseException(iae.getMessage());
} catch (XMLParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//return oldLikelihood - newLikelihood;
return 0;
}
示例2: doOperation
import dr.evomodel.coalescent.CoalescentSimulator; //导入依赖的package包/类
/**
* change the parameter and return the hastings ratio.
*/
public double doOperation() {
CoalescentSimulator simulator = new CoalescentSimulator();
List<TaxonList> taxonLists = new ArrayList<TaxonList>();
double rootHeight = -1.0;
double oldLikelihood = 0.0;
double newLikelihood = 0.0;
// should have one child that is node
for (int i = 0; i < xo.getChildCount(); i++) {
final Object child = xo.getChild(i);
//careful: Trees are TaxonLists ... (AER); see OldCoalescentSimulatorParser
if (child instanceof Tree) {
//do nothing
} else if (child instanceof TaxonList) {
//taxonLists.add((TaxonList) child);
taxonLists.add((Taxa) child);
//taxa added
break;
}
}
try {
Tree[] trees = new Tree[taxonLists.size()];
// simulate each taxonList separately
for (int i = 0; i < taxonLists.size(); i++) {
trees[i] = simulator.simulateTree(taxonLists.get(i), demoModel);
}
oldLikelihood = coalescent.getLogLikelihood();
SimpleTree simTree = simulator.simulateTree(trees, demoModel, rootHeight, trees.length != 1);
//this would be the normal way to do it
treeModel.beginTreeEdit();
//now it's allowed to adjust the tree structure
treeModel.adoptTreeStructure(simTree);
//endTreeEdit() would then fire the events
treeModel.endTreeEdit();
newLikelihood = coalescent.getLogLikelihood();
} catch (IllegalArgumentException iae) {
try {
throw new XMLParseException(iae.getMessage());
} catch (XMLParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return oldLikelihood - newLikelihood;
}
示例3: getReturnType
import dr.evomodel.coalescent.CoalescentSimulator; //导入依赖的package包/类
public Class getReturnType() {
return CoalescentSimulator.class; //Object.class;
}
示例4: parseXMLObject
import dr.evomodel.coalescent.CoalescentSimulator; //导入依赖的package包/类
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
CoalescentSimulator simulator = new CoalescentSimulator();
DemographicModel demoModel = (DemographicModel) xo.getChild(DemographicModel.class);
List<TaxonList> taxonLists = new ArrayList<TaxonList>();
List<Tree> subtrees = new ArrayList<Tree>();
double height = xo.getAttribute(HEIGHT, Double.NaN);
// should have one child that is node
for (int i = 0; i < xo.getChildCount(); i++) {
final Object child = xo.getChild(i);
// AER - swapped the order of these round because Trees are TaxonLists...
if (child instanceof Tree) {
subtrees.add((Tree) child);
} else if (child instanceof TaxonList) {
taxonLists.add((TaxonList) child);
}
}
if (taxonLists.size() == 0) {
if (subtrees.size() == 1) {
return subtrees.get(0);
}
throw new XMLParseException("Expected at least one taxonList or two subtrees in "
+ getParserName() + " element.");
}
Taxa remainingTaxa = new Taxa();
for (int i = 0; i < taxonLists.size(); i++) {
remainingTaxa.addTaxa(taxonLists.get(i));
}
for (int i = 0; i < subtrees.size(); i++) {
remainingTaxa.removeTaxa(subtrees.get(i));
}
try {
Tree[] trees = new Tree[subtrees.size() + remainingTaxa.getTaxonCount()];
// add the preset trees
for (int i = 0; i < subtrees.size(); i++) {
trees[i] = subtrees.get(i);
}
// add all the remaining taxa in as single tip trees...
for (int i = 0; i < remainingTaxa.getTaxonCount(); i++) {
Taxa tip = new Taxa();
tip.addTaxon(remainingTaxa.getTaxon(i));
trees[i + subtrees.size()] = simulator.simulateTree(tip, demoModel);
}
return simulator.simulateTree(trees, demoModel, height, trees.length != 1);
} catch (IllegalArgumentException iae) {
throw new XMLParseException(iae.getMessage());
}
}