use of dr.evomodel.coalescent.VariableDemographicModel in project beast-mcmc by beast-dev.
the class OrnsteinUhlenbeckPriorLikelihoodParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
Parameter mean = getParam(xo, MEAN);
Parameter sigma = getParam(xo, SIGMA);
Parameter lambda = getParam(xo, LAMBDA);
final boolean logSpace = xo.getAttribute(LOG_SPACE, false);
final boolean normalize = xo.getAttribute(NORMALIZE, false);
VariableDemographicModel m = (VariableDemographicModel) xo.getChild(VariableDemographicModel.class);
if (m != null) {
ParametricDistributionModel popMeanPrior = (ParametricDistributionModel) xo.getChild(ParametricDistributionModel.class);
return new OrnsteinUhlenbeckPriorLikelihood(mean, sigma, lambda, m, logSpace, normalize, popMeanPrior);
}
final XMLObject cxo1 = xo.getChild(DATA);
Parameter dataParameter = (Parameter) cxo1.getChild(Parameter.class);
final XMLObject cxo2 = xo.getChild(TIMES);
final Parameter timesParameter = (Parameter) cxo2.getChild(Parameter.class);
return new OrnsteinUhlenbeckPriorLikelihood(mean, sigma, lambda, dataParameter, timesParameter, logSpace, normalize);
}
use of dr.evomodel.coalescent.VariableDemographicModel in project beast-mcmc by beast-dev.
the class VariableDemographicModelParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
XMLObject cxo = xo.getChild(POPULATION_SIZES);
Parameter popParam = (Parameter) cxo.getChild(Parameter.class);
cxo = xo.getChild(INDICATOR_PARAMETER);
Parameter indicatorParam = (Parameter) cxo.getChild(Parameter.class);
cxo = xo.getChild(POPULATION_TREES);
final int nc = cxo.getChildCount();
TreeModel[] treeModels = new TreeModel[nc];
double[] populationFactor = new double[nc];
for (int k = 0; k < treeModels.length; ++k) {
final XMLObject child = (XMLObject) cxo.getChild(k);
populationFactor[k] = child.hasAttribute(PLOIDY) ? child.getDoubleAttribute(PLOIDY) : 1.0;
treeModels[k] = (TreeModel) child.getChild(TreeModel.class);
}
VariableDemographicModel.Type type = VariableDemographicModel.Type.STEPWISE;
if (xo.hasAttribute(TYPE)) {
final String s = xo.getStringAttribute(TYPE);
if (s.equalsIgnoreCase(VariableDemographicModel.Type.STEPWISE.toString())) {
type = VariableDemographicModel.Type.STEPWISE;
} else if (s.equalsIgnoreCase(VariableDemographicModel.Type.LINEAR.toString())) {
type = VariableDemographicModel.Type.LINEAR;
} else if (s.equalsIgnoreCase(VariableDemographicModel.Type.EXPONENTIAL.toString())) {
type = VariableDemographicModel.Type.EXPONENTIAL;
} else {
throw new XMLParseException("Unknown Bayesian Skyline type: " + s);
}
}
final boolean logSpace = xo.getAttribute(LOG_SPACE, false) || type == VariableDemographicModel.Type.EXPONENTIAL;
final boolean useMid = xo.getAttribute(USE_MIDPOINTS, false);
Logger.getLogger("dr.evomodel").info("Variable demographic: " + type.toString() + " control points");
return new VariableDemographicModel(treeModels, populationFactor, popParam, indicatorParam, type, logSpace, useMid);
}
use of dr.evomodel.coalescent.VariableDemographicModel in project beast-mcmc by beast-dev.
the class BMPriorLikelihoodParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
// Parameter mean = getParam(xo, MEAN);
Parameter sigma = getParam(xo, SIGMA);
// Parameter lambda = getParam(xo, LAMBDA);
final boolean logSpace = xo.getAttribute(LOG_SPACE, false);
// final boolean normalize = xo.getAttribute(NORMALIZE, false);
VariableDemographicModel m = (VariableDemographicModel) xo.getChild(VariableDemographicModel.class);
ParametricDistributionModel popMeanPrior = (ParametricDistributionModel) xo.getChild(ParametricDistributionModel.class);
return new BMPriorLikelihood(sigma, m, logSpace, popMeanPrior);
}
Aggregations