use of dr.oldevomodel.substmodel.AbstractSubstitutionModel in project beast-mcmc by beast-dev.
the class MutationDeathModelParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
Parameter dummyFreqParameter;
Parameter delParam = (Parameter) xo.getChild(Parameter.class);
Logger.getLogger("dr.evomodel").info("Creating MutationDeath substitution model.\n\tInitial death rate is " + delParam.getParameterValue(0));
MutationDeathType dT = (MutationDeathType) xo.getChild(MutationDeathType.class);
AbstractSubstitutionModel evoModel = (AbstractSubstitutionModel) xo.getChild(AbstractSubstitutionModel.class);
if (evoModel == null) {
// Assuming pure survival model
Logger.getLogger("dr.evomodel").info("\tSubstitutionModel not provided assuming pure death/survival model.");
dummyFreqParameter = new Parameter.Default(new double[] { 1.0, 0.0 });
} else {
dummyFreqParameter = new Parameter.Default(dT.getStateCount());
double[] freqs = evoModel.getFrequencyModel().getFrequencies();
for (int i = 0; i < freqs.length; ++i) {
dummyFreqParameter.setParameterValueQuietly(i, freqs[i]);
}
dummyFreqParameter.setParameterValueQuietly(dT.getStateCount() - 1, 0.0);
}
FrequencyModel dummyFrequencies = new FrequencyModel(dT, dummyFreqParameter);
Parameter mutationRate;
if (xo.hasChildNamed(MUTATION_RATE)) {
mutationRate = (Parameter) xo.getElementFirstChild(MUTATION_RATE);
} else {
mutationRate = new Parameter.Default(new double[] { 1.0 });
}
Logger.getLogger("dr.evomodel").info("\tInitial mutation rate is " + mutationRate.getParameterValue(0));
return new MutationDeathModel(delParam, dT, evoModel, dummyFrequencies, mutationRate);
}
Aggregations