Search in sources :

Example 1 with EmpiricalRateMatrixReader

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

the class EmpiricalCodonModelParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    Codons codons = Codons.UNIVERSAL;
    if (xo.hasAttribute(GeneticCode.GENETIC_CODE)) {
        String codeStr = xo.getStringAttribute(GeneticCode.GENETIC_CODE);
        if (codeStr.equals(GeneticCode.UNIVERSAL.getName())) {
            codons = Codons.UNIVERSAL;
        } else if (codeStr.equals(GeneticCode.VERTEBRATE_MT.getName())) {
            codons = Codons.VERTEBRATE_MT;
        } else if (codeStr.equals(GeneticCode.YEAST.getName())) {
            codons = Codons.YEAST;
        } else if (codeStr.equals(GeneticCode.MOLD_PROTOZOAN_MT.getName())) {
            codons = Codons.MOLD_PROTOZOAN_MT;
        } else if (codeStr.equals(GeneticCode.INVERTEBRATE_MT.getName())) {
            codons = Codons.INVERTEBRATE_MT;
        } else if (codeStr.equals(GeneticCode.CILIATE.getName())) {
            codons = Codons.CILIATE;
        } else if (codeStr.equals(GeneticCode.ECHINODERM_MT.getName())) {
            codons = Codons.ECHINODERM_MT;
        } else if (codeStr.equals(GeneticCode.EUPLOTID_NUC.getName())) {
            codons = Codons.EUPLOTID_NUC;
        } else if (codeStr.equals(GeneticCode.BACTERIAL.getName())) {
            codons = Codons.BACTERIAL;
        } else if (codeStr.equals(GeneticCode.ALT_YEAST.getName())) {
            codons = Codons.ALT_YEAST;
        } else if (codeStr.equals(GeneticCode.ASCIDIAN_MT.getName())) {
            codons = Codons.ASCIDIAN_MT;
        } else if (codeStr.equals(GeneticCode.FLATWORM_MT.getName())) {
            codons = Codons.FLATWORM_MT;
        } else if (codeStr.equals(GeneticCode.BLEPHARISMA_NUC.getName())) {
            codons = Codons.BLEPHARISMA_NUC;
        } else if (codeStr.equals(GeneticCode.NO_STOPS.getName())) {
            codons = Codons.NO_STOPS;
        }
    }
    Parameter omegaParam = (Parameter) xo.getElementFirstChild(OMEGA);
    Parameter kappaParam = null;
    Parameter mntParam = null;
    if (xo.hasChildNamed(KAPPATSTV)) {
        kappaParam = (Parameter) xo.getElementFirstChild(KAPPATSTV);
        if (kappaParam.getDimension() != 2 && kappaParam.getDimension() != 9) {
            throw new XMLParseException("If you use the kappa parameter, you need to enter exactly\n" + "two values for ts and tv or nine values\n" + "according to the Kosiol ECM+F+omega+9k model");
        }
    } else {
        mntParam = (Parameter) xo.getElementFirstChild(MULTI_NT_CHANGE);
    }
    String dirString = xo.getStringAttribute(ECM_DATA_DIR);
    String freqString = xo.getStringAttribute(ECM_FREQ_MATRIX);
    String matString = xo.getStringAttribute(ECM_DATA_MATRIX);
    EmpiricalRateMatrixReader rateMat = new EmpiricalRateMatrixReader(EMPIRICAL_RATE_MATRIX, codons, dirString, freqString, matString);
    FrequencyModel freqModel = null;
    if (xo.getChild(FrequencyModel.class) != null) {
        freqModel = (FrequencyModel) xo.getChild(FrequencyModel.class);
    } else {
        freqModel = createNewFreqModel(codons, rateMat);
    }
    return new EmpiricalCodonModel(codons, omegaParam, kappaParam, mntParam, rateMat, freqModel);
}
Also used : FrequencyModel(dr.evomodel.substmodel.FrequencyModel) Parameter(dr.inference.model.Parameter) EmpiricalRateMatrixReader(dr.evomodel.substmodel.EmpiricalRateMatrixReader) Codons(dr.evolution.datatype.Codons) EmpiricalCodonModel(dr.evomodel.substmodel.codon.EmpiricalCodonModel)

Aggregations

Codons (dr.evolution.datatype.Codons)1 EmpiricalRateMatrixReader (dr.evomodel.substmodel.EmpiricalRateMatrixReader)1 FrequencyModel (dr.evomodel.substmodel.FrequencyModel)1 EmpiricalCodonModel (dr.evomodel.substmodel.codon.EmpiricalCodonModel)1 Parameter (dr.inference.model.Parameter)1