use of dr.evomodel.tree.TreeModel in project beast-mcmc by beast-dev.
the class SingleTipObservationProcessParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
Parameter mu = (Parameter) xo.getElementFirstChild(AnyTipObservationProcessParser.DEATH_RATE);
Parameter lam = (Parameter) xo.getElementFirstChild(AnyTipObservationProcessParser.IMMIGRATION_RATE);
TreeModel treeModel = (TreeModel) xo.getChild(TreeModel.class);
PatternList patterns = (PatternList) xo.getChild(PatternList.class);
Taxon sourceTaxon = (Taxon) xo.getChild(Taxon.class);
SiteModel siteModel = (SiteModel) xo.getChild(SiteModel.class);
BranchRateModel branchRateModel = (BranchRateModel) xo.getChild(BranchRateModel.class);
Logger.getLogger("dr.evomodel.MSSD").info("Creating SingleTipObservationProcess model. All traits are assumed extant in " + sourceTaxon.getId() + "Initial mu = " + mu.getParameterValue(0) + " initial lam = " + lam.getParameterValue(0));
return new SingleTipObservationProcess(treeModel, patterns, siteModel, branchRateModel, mu, lam, sourceTaxon);
}
use of dr.evomodel.tree.TreeModel in project beast-mcmc by beast-dev.
the class ScaledPiecewiseModelParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
Units.Type units = XMLUnits.Utils.getUnitsAttr(xo);
XMLObject cxo = xo.getChild(EPOCH_SIZES);
Parameter epochSizes = (Parameter) cxo.getChild(Parameter.class);
cxo = xo.getChild(TREE_MODEL);
TreeModel treeModel = (TreeModel) cxo.getChild(TreeModel.class);
boolean isLinear = xo.getBooleanAttribute("linear");
return new ScaledPiecewiseModel(epochSizes, treeModel, isLinear, units);
}
use of dr.evomodel.tree.TreeModel in project beast-mcmc by beast-dev.
the class VariableSkylineLikelihoodParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
XMLObject cxo = xo.getChild(POPULATION_SIZES);
Parameter param = (Parameter) cxo.getChild(Parameter.class);
cxo = xo.getChild(INDICATOR_PARAMETER);
Parameter param2 = (Parameter) cxo.getChild(Parameter.class);
cxo = xo.getChild(CoalescentLikelihoodParser.POPULATION_TREE);
TreeModel treeModel = (TreeModel) cxo.getChild(TreeModel.class);
VariableSkylineLikelihood.Type type = VariableSkylineLikelihood.Type.STEPWISE;
if (xo.hasAttribute(TYPE)) {
final String s = xo.getStringAttribute(TYPE);
if (s.equalsIgnoreCase(STEPWISE)) {
type = VariableSkylineLikelihood.Type.STEPWISE;
} else if (s.equalsIgnoreCase(LINEAR)) {
type = VariableSkylineLikelihood.Type.LINEAR;
} else if (s.equalsIgnoreCase(EXPONENTIAL)) {
type = VariableSkylineLikelihood.Type.EXPONENTIAL;
} else {
throw new XMLParseException("Unknown Bayesian Skyline type: " + s);
}
}
boolean logSpace = xo.getBooleanAttribute(LOG_SPACE);
Logger.getLogger("dr.evomodel").info("Variable skyline plot: " + type.toString() + " control points");
return new VariableSkylineLikelihood(treeModel, param, param2, type, logSpace);
}
use of dr.evomodel.tree.TreeModel in project beast-mcmc by beast-dev.
the class NNIParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
TreeModel treeModel = (TreeModel) xo.getChild(TreeModel.class);
double weight = xo.getDoubleAttribute(MCMCOperator.WEIGHT);
return new NNI(treeModel, weight);
}
use of dr.evomodel.tree.TreeModel in project beast-mcmc by beast-dev.
the class LeafTraitExtractorParser method parseXMLObject.
@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
TreeModel model = (TreeModel) xo.getChild(TreeModel.class);
final CompoundParameter allTraits = (CompoundParameter) xo.getChild(CompoundParameter.class);
String taxonString = (String) xo.getAttribute(TreeModelParser.TAXON);
final int leafIndex = model.getTaxonIndex(taxonString);
if (leafIndex == -1) {
throw new XMLParseException("Unable to find taxon '" + taxonString + "' in trees.");
}
final Parameter leafTrait = allTraits.getParameter(leafIndex);
boolean setBounds = xo.getAttribute(SET_BOUNDS, true);
if (setBounds) {
Parameter.DefaultBounds bound = new Parameter.DefaultBounds(Double.MAX_VALUE, -Double.MAX_VALUE, leafTrait.getDimension());
leafTrait.addBounds(bound);
}
return leafTrait;
}
Aggregations