Search in sources :

Example 1 with GLMSubstitutionModel

use of dr.oldevomodel.substmodel.GLMSubstitutionModel in project beast-mcmc by beast-dev.

the class GLMSubstitutionModelParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    DataType dataType = DataTypeUtils.getDataType(xo);
    if (dataType == null)
        dataType = (DataType) xo.getChild(DataType.class);
    int rateCount = (dataType.getStateCount() - 1) * dataType.getStateCount();
    LogLinearModel glm = (LogLinearModel) xo.getChild(GeneralizedLinearModel.class);
    int length = glm.getXBeta().length;
    if (length != rateCount) {
        throw new XMLParseException("Rates parameter in " + getParserName() + " element should have " + (rateCount) + " dimensions.  However GLM dimension is " + length);
    }
    XMLObject cxo = xo.getChild(ComplexSubstitutionModelParser.ROOT_FREQUENCIES);
    FrequencyModel rootFreq = (FrequencyModel) cxo.getChild(FrequencyModel.class);
    if (dataType != rootFreq.getDataType()) {
        throw new XMLParseException("Data type of " + getParserName() + " element does not match that of its rootFrequencyModel.");
    }
    return new GLMSubstitutionModel(xo.getId(), dataType, rootFreq, glm);
}
Also used : FrequencyModel(dr.oldevomodel.substmodel.FrequencyModel) GeneralizedLinearModel(dr.inference.distribution.GeneralizedLinearModel) DataType(dr.evolution.datatype.DataType) LogLinearModel(dr.inference.distribution.LogLinearModel) GLMSubstitutionModel(dr.oldevomodel.substmodel.GLMSubstitutionModel)

Aggregations

DataType (dr.evolution.datatype.DataType)1 GeneralizedLinearModel (dr.inference.distribution.GeneralizedLinearModel)1 LogLinearModel (dr.inference.distribution.LogLinearModel)1 FrequencyModel (dr.oldevomodel.substmodel.FrequencyModel)1 GLMSubstitutionModel (dr.oldevomodel.substmodel.GLMSubstitutionModel)1