use of dr.evolution.util.Units in project beast-mcmc by beast-dev.
the class PiecewisePopulationModelParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
Units.Type units = XMLUnits.Utils.getUnitsAttr(xo);
XMLObject obj = xo.getChild(EPOCH_WIDTHS);
double[] epochWidths = obj.getDoubleArrayAttribute(WIDTHS);
if (xo.hasChildNamed(EPOCH_SIZES)) {
Parameter epochSizes = (Parameter) xo.getElementFirstChild(EPOCH_SIZES);
boolean isLinear = false;
if (xo.hasAttribute(LINEAR)) {
isLinear = xo.getBooleanAttribute(LINEAR);
}
return new PiecewisePopulationModel(PIECEWISE_POPULATION, epochSizes, epochWidths, isLinear, units);
} else {
Parameter populationSize = (Parameter) xo.getElementFirstChild(POPULATION_SIZE);
Parameter growthRates = (Parameter) xo.getElementFirstChild(GROWTH_RATES);
return new PiecewisePopulationModel(PIECEWISE_POPULATION, populationSize, growthRates, epochWidths, units);
}
}
use of dr.evolution.util.Units in project beast-mcmc by beast-dev.
the class TaxonRichnessBirthDeathModelParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
Units.Type units = XMLUnits.Utils.getUnitsAttr(xo);
XMLObject cxo = xo.getChild(BIRTH_RATE);
Parameter brParameter = (Parameter) cxo.getChild(Parameter.class);
cxo = xo.getChild(BIRTH_RATE_INDICATORS);
Parameter indicatorsParameter = (Parameter) cxo.getChild(Parameter.class);
Parameter meanRate = (Parameter) xo.getElementFirstChild(MEAN_RATE);
boolean ratesAsMultipliers = xo.getBooleanAttribute(RATES_AS_MULTIPLIERS);
int dp = xo.getAttribute("dp", 4);
return new TaxonRichnessBirthDeathModel(brParameter, indicatorsParameter, meanRate, ratesAsMultipliers, units, dp);
}
use of dr.evolution.util.Units in project beast-mcmc by beast-dev.
the class BirthDeathModelParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
final Units.Type units = XMLUnits.Utils.getUnitsAttr(xo);
final String s = xo.getAttribute(TREE_TYPE, BirthDeathGernhard08Model.TreeType.UNSCALED.toString());
final BirthDeathGernhard08Model.TreeType treeType = BirthDeathGernhard08Model.TreeType.valueOf(s);
final boolean conditonalOnRoot = xo.getAttribute(CONDITIONAL_ON_ROOT, false);
final Parameter birthParameter = (Parameter) xo.getElementFirstChild(BIRTHDIFF_RATE);
final Parameter deathParameter = (Parameter) xo.getElementFirstChild(RELATIVE_DEATH_RATE);
final Parameter sampleProbability = xo.hasChildNamed(SAMPLE_PROB) ? (Parameter) xo.getElementFirstChild(SAMPLE_PROB) : null;
Logger.getLogger("dr.evomodel").info(xo.hasChildNamed(SAMPLE_PROB) ? getCitationRHO() : getCitation());
final String modelName = xo.getId();
return new BirthDeathGernhard08Model(modelName, birthParameter, deathParameter, sampleProbability, treeType, units, conditonalOnRoot);
}
use of dr.evolution.util.Units in project beast-mcmc by beast-dev.
the class BirthDeathSerialSkylineModelParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
final String modelName = xo.getId();
final Units.Type units = XMLUnits.Utils.getUnitsAttr(xo);
final Parameter times = (Parameter) xo.getElementFirstChild(TIMES);
final Parameter lambda = (Parameter) xo.getElementFirstChild(LAMBDA);
boolean relativeDeath = xo.hasChildNamed(RELATIVE_MU);
Parameter mu;
if (relativeDeath) {
mu = (Parameter) xo.getElementFirstChild(RELATIVE_MU);
} else {
mu = (Parameter) xo.getElementFirstChild(MU);
}
final Parameter psi = (Parameter) xo.getElementFirstChild(PSI);
final Parameter p = (Parameter) xo.getElementFirstChild(SAMPLE_PROBABILITY);
final boolean timesStartFromOrigin = xo.getAttribute(TIMES_START_FROM_ORIGIN, false);
Parameter origin = null;
if (xo.hasChildNamed(ORIGIN)) {
origin = (Parameter) xo.getElementFirstChild(ORIGIN);
}
final Parameter r = xo.hasChildNamed(SAMPLE_BECOMES_NON_INFECTIOUS) ? (Parameter) xo.getElementFirstChild(SAMPLE_BECOMES_NON_INFECTIOUS) : new Parameter.Default(0.0);
// r.setParameterValueQuietly(0, 1 - r.getParameterValue(0)); // donot use it, otherwise log is changed improperly
Logger.getLogger("dr.evomodel").info(xo.hasChildNamed(SAMPLE_BECOMES_NON_INFECTIOUS) ? getCitationRT() : getCitationPsiOrg());
return new BirthDeathSerialSkylineModel(modelName, times, lambda, mu, psi, p, origin, relativeDeath, false, timesStartFromOrigin, units);
}
use of dr.evolution.util.Units in project beast-mcmc by beast-dev.
the class AlloppNetworkPriorModelParser method parseXMLObject.
@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
final Units.Type units = XMLUnits.Utils.getUnitsAttr(xo);
final XMLObject erXo = xo.getChild(EVENTRATE);
final Parameter eventrate = (Parameter) erXo.getChild(Parameter.class);
final XMLObject psfXo = xo.getChild(POPULATION_SCALING_FACTOR);
final Parameter popscalingfactor = (Parameter) psfXo.getChild(Parameter.class);
final XMLObject tpdXo = xo.getChild(TIP_POPULATION_DISTRIBUTION);
ParametricDistributionModel tippopmodel = (ParametricDistributionModel) tpdXo.getChild(ParametricDistributionModel.class);
final XMLObject rpdXo = xo.getChild(ROOT_POPULATION_DISTRIBUTION);
ParametricDistributionModel rootpopmodel = (ParametricDistributionModel) rpdXo.getChild(ParametricDistributionModel.class);
final XMLObject hpdXo = xo.getChild(HYBRID_POPULATION_DISTRIBUTION);
ParametricDistributionModel hybpopmodel = (ParametricDistributionModel) hpdXo.getChild(ParametricDistributionModel.class);
return new AlloppNetworkPriorModel(eventrate, popscalingfactor, tippopmodel, rootpopmodel, hybpopmodel, units);
}
Aggregations