use of dr.evolution.util.Units in project beast-mcmc by beast-dev.
the class ConstantPopulationSizeModelParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
Units.Type units = XMLUnits.Utils.getUnitsAttr(xo);
Parameter N0Param = null;
if (xo.hasChildNamed(LOG_POPULATION_SIZE)) {
N0Param = (Parameter) xo.getElementFirstChild(LOG_POPULATION_SIZE);
}
return new ConstantPopulationSizeModel(N0Param, units);
}
use of dr.evolution.util.Units in project beast-mcmc by beast-dev.
the class ExpConstExpDemographicModelParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
Units.Type units = XMLUnits.Utils.getUnitsAttr(xo);
XMLObject cxo = xo.getChild(POPULATION_SIZE);
Parameter N0Param = (Parameter) cxo.getChild(Parameter.class);
cxo = xo.getChild(RELATIVE_PLATEAU_SIZE);
Parameter N1Param = (Parameter) cxo.getChild(Parameter.class);
cxo = xo.getChild(RELATIVE_TIME_OF_MODERN_GROWTH);
Parameter rtParam = (Parameter) cxo.getChild(Parameter.class);
cxo = xo.getChild(TIME_PLATEAU);
Parameter tParam = (Parameter) cxo.getChild(Parameter.class);
cxo = xo.getChild(ANCIENT_GROWTH_RATE);
Parameter rParam = (Parameter) cxo.getChild(Parameter.class);
return new ExpConstExpDemographicModel(N0Param, N1Param, rParam, tParam, rtParam, units);
}
use of dr.evolution.util.Units in project beast-mcmc by beast-dev.
the class ExponentialConstantModelParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
Units.Type units = XMLUnits.Utils.getUnitsAttr(xo);
XMLObject cxo = xo.getChild(POPULATION_SIZE);
Parameter N0Param = (Parameter) cxo.getChild(Parameter.class);
cxo = xo.getChild(GROWTH_RATE);
Parameter logGrowthParam = (Parameter) cxo.getChild(Parameter.class);
cxo = xo.getChild(TRANSITION_TIME);
Parameter timeParam = (Parameter) cxo.getChild(Parameter.class);
return new ExponentialConstantModel(N0Param, logGrowthParam, timeParam, units);
}
use of dr.evolution.util.Units in project beast-mcmc by beast-dev.
the class ExponentialGrowthModelParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
Units.Type units = XMLUnits.Utils.getUnitsAttr(xo);
XMLObject cxo = xo.getChild(POPULATION_SIZE);
boolean logSpace = cxo.getAttribute(LOG_SPACE, false);
Parameter N0Param = (Parameter) cxo.getChild(Parameter.class);
Parameter rParam;
boolean usingGrowthRate = true;
if (xo.getChild(GROWTH_RATE) != null) {
cxo = xo.getChild(GROWTH_RATE);
rParam = (Parameter) cxo.getChild(Parameter.class);
} else {
cxo = xo.getChild(DOUBLING_TIME);
rParam = (Parameter) cxo.getChild(Parameter.class);
usingGrowthRate = false;
}
if (logSpace) {
if (!usingGrowthRate) {
throw new XMLParseException("Doubling time parameterization is not compatible with log population size");
}
// ExponentialPopulationSizeModel provides a model with N0 in log space
return new ExponentialPopulationSizeModel(N0Param, rParam, units);
} else {
return new ExponentialGrowthModel(N0Param, rParam, units, usingGrowthRate);
}
}
use of dr.evolution.util.Units in project beast-mcmc by beast-dev.
the class PiecewisePopulationSizeModelParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
Units.Type units = XMLUnits.Utils.getUnitsAttr(xo);
Parameter epochDurations = (Parameter) xo.getElementFirstChild(EPOCH_DURATIONS);
Parameter populationSize = (Parameter) xo.getElementFirstChild(LOG_POPULATION_SIZE);
XMLObject cxo = xo.getChild(EPOCHS);
List<PopulationSizeModel> epochs = cxo.getAllChildren(PopulationSizeModel.class);
if (epochDurations.getDimension() != epochs.size() - 1) {
throw new XMLParseException("The dimension of the epoch duration parameter should be one fewer than the number of epochs.");
}
return new PiecewisePopulationSizeModel(PIECEWISE_POPULATION_SIZE, populationSize, epochs, epochDurations, units);
}
Aggregations