Search in sources :

Example 1 with MutationDeathModel

use of dr.evomodel.substmodel.MutationDeathModel 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);
    SubstitutionModel evoModel = (SubstitutionModel) xo.getChild(SubstitutionModel.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);
}
Also used : FrequencyModel(dr.evomodel.substmodel.FrequencyModel) Parameter(dr.inference.model.Parameter) MutationDeathModel(dr.evomodel.substmodel.MutationDeathModel) MutationDeathType(dr.evolution.datatype.MutationDeathType) SubstitutionModel(dr.evomodel.substmodel.SubstitutionModel)

Aggregations

MutationDeathType (dr.evolution.datatype.MutationDeathType)1 FrequencyModel (dr.evomodel.substmodel.FrequencyModel)1 MutationDeathModel (dr.evomodel.substmodel.MutationDeathModel)1 SubstitutionModel (dr.evomodel.substmodel.SubstitutionModel)1 Parameter (dr.inference.model.Parameter)1