Search in sources :

Example 1 with OldGLMSubstitutionModel

use of dr.evomodel.substmodel.OldGLMSubstitutionModel in project beast-mcmc by beast-dev.

the class OldGLMSubstitutionModelParser 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(dr.oldevomodelxml.substmodel.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 OldGLMSubstitutionModel(xo.getId(), dataType, rootFreq, glm);
}
Also used : FrequencyModel(dr.evomodel.substmodel.FrequencyModel) GeneralizedLinearModel(dr.inference.distribution.GeneralizedLinearModel) DataType(dr.evolution.datatype.DataType) LogLinearModel(dr.inference.distribution.LogLinearModel) OldGLMSubstitutionModel(dr.evomodel.substmodel.OldGLMSubstitutionModel)

Aggregations

DataType (dr.evolution.datatype.DataType)1 FrequencyModel (dr.evomodel.substmodel.FrequencyModel)1 OldGLMSubstitutionModel (dr.evomodel.substmodel.OldGLMSubstitutionModel)1 GeneralizedLinearModel (dr.inference.distribution.GeneralizedLinearModel)1 LogLinearModel (dr.inference.distribution.LogLinearModel)1