use of dr.evolution.tree.Tree in project beast-mcmc by beast-dev.
the class SpeciesTreeModelParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
SpeciesBindings spb = (SpeciesBindings) xo.getChild(SpeciesBindings.class);
Parameter coalPointsPops = null;
Parameter coalPointsIndicators = null;
final Boolean cr = xo.getAttribute(CONST_ROOT_POPULATION, false);
final Boolean cp = xo.getAttribute(CONSTANT_POPULATION, false);
final Boolean bmp = xo.getAttribute(BMPRIOR, false);
{
XMLObject cxo = xo.getChild(COALESCENT_POINTS_POPULATIONS);
if (cxo != null) {
final double value = cxo.getAttribute(Attributable.VALUE, 1.0);
coalPointsPops = SpeciesTreeModel.createCoalPointsPopParameter(spb, cxo.getAttribute(Attributable.VALUE, value), bmp);
ParameterParser.replaceParameter(cxo, coalPointsPops);
coalPointsPops.addBounds(new Parameter.DefaultBounds(Double.MAX_VALUE, 0, coalPointsPops.getDimension()));
cxo = xo.getChild(COALESCENT_POINTS_INDICATORS);
if (cxo == null) {
throw new XMLParseException("Must have indicators");
}
coalPointsIndicators = new Parameter.Default(coalPointsPops.getDimension(), 0);
ParameterParser.replaceParameter(cxo, coalPointsIndicators);
} else {
// assert ! bmp;
}
}
final XMLObject cxo = xo.getChild(SPP_SPLIT_POPULATIONS);
final double value = cxo.getAttribute(Attributable.VALUE, 1.0);
final boolean nonConstRootPopulation = coalPointsPops == null && !cr;
final Parameter sppSplitPopulations = SpeciesTreeModel.createSplitPopulationsParameter(spb, value, nonConstRootPopulation, cp);
ParameterParser.replaceParameter(cxo, sppSplitPopulations);
final Parameter.DefaultBounds bounds = new Parameter.DefaultBounds(Double.MAX_VALUE, 0, sppSplitPopulations.getDimension());
sppSplitPopulations.addBounds(bounds);
final Tree startTree = (Tree) xo.getChild(Tree.class);
return new SpeciesTreeModel(spb, sppSplitPopulations, coalPointsPops, coalPointsIndicators, startTree, bmp, nonConstRootPopulation, cp);
}
use of dr.evolution.tree.Tree in project beast-mcmc by beast-dev.
the class BetaSplittingModelParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
XMLObject cxo = xo.getChild(PHI);
Parameter phiParameter = (Parameter) cxo.getChild(Parameter.class);
cxo = xo.getChild(TREE);
Tree tree = (Tree) cxo.getChild(Tree.class);
return new BetaSplittingModel(phiParameter, tree);
}
use of dr.evolution.tree.Tree in project beast-mcmc by beast-dev.
the class CompatibilityStatisticParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
String name = xo.getAttribute(Statistic.NAME, xo.getId());
Tree tree1 = (Tree) xo.getChild(Tree.class);
XMLObject cxo = xo.getChild(COMPATIBLE_WITH);
Tree tree2 = (Tree) cxo.getChild(Tree.class);
try {
return new CompatibilityStatistic(name, tree1, tree2);
} catch (TreeUtils.MissingTaxonException mte) {
throw new XMLParseException("Taxon, " + mte + ", in " + getParserName() + "was in the source tree but not the constraints tree.");
}
}
use of dr.evolution.tree.Tree in project beast-mcmc by beast-dev.
the class MsatFullLikelihoodTest method setUp.
public void setUp() throws Exception {
super.setUp();
//taxa
ArrayList<Taxon> taxonList1 = new ArrayList<Taxon>();
Collections.addAll(taxonList1, new Taxon("taxon1"), new Taxon("taxon2"), new Taxon("taxon3"));
Taxa taxa1 = new Taxa(taxonList1);
//msat datatype
Microsatellite msat = new Microsatellite(1, 3);
Patterns msatPatterns = new Patterns(msat, taxa1);
//pattern in the correct code form.
msatPatterns.addPattern(new int[] { 0, 1, 2 });
//create tree
NewickImporter importer = new NewickImporter("(taxon1:7.5,(taxon2:5.3,taxon3:5.3):2.2);");
Tree tree = importer.importTree(null);
//treeModel
TreeModel treeModel = new TreeModel(tree);
//msatsubstModel
AsymmetricQuadraticModel aqm1 = new AsymmetricQuadraticModel(msat, null);
//siteModel
GammaSiteModel siteModel = new GammaSiteModel(aqm1);
//treeLikelihood
treeLikelihood1 = new TreeLikelihood(msatPatterns, treeModel, siteModel, null, null, false, false, true, false, false);
setUpExample2();
setUpExample3();
}
use of dr.evolution.tree.Tree in project beast-mcmc by beast-dev.
the class MsatFullLikelihoodTest method setUpExample2.
private void setUpExample2() throws Exception {
//taxa
ArrayList<Taxon> taxonList2 = new ArrayList<Taxon>();
Collections.addAll(taxonList2, new Taxon("taxon1"), new Taxon("taxon2"), new Taxon("taxon3"), new Taxon("taxon4"), new Taxon("taxon5"));
Taxa taxa2 = new Taxa(taxonList2);
//msat datatype
Microsatellite msat = new Microsatellite(1, 3);
Patterns msatPatterns = new Patterns(msat, taxa2);
//pattern in the correct code form.
msatPatterns.addPattern(new int[] { 0, 1, 2, 1, 2 });
//create tree
NewickImporter importer = new NewickImporter("(((taxon1:1.5,taxon2:1.5):1.5,(taxon3:2.1,taxon4:2.1):0.9):0.7,taxon5:3.7);");
Tree tree = importer.importTree(null);
//treeModel
TreeModel treeModel = new TreeModel(tree);
//msatsubstModel
AsymmetricQuadraticModel aqm2 = new AsymmetricQuadraticModel(msat, null);
//siteModel
GammaSiteModel siteModel = new GammaSiteModel(aqm2);
//treeLikelihood
treeLikelihood2 = new TreeLikelihood(msatPatterns, treeModel, siteModel, null, null, false, false, true, false, false);
}
Aggregations