Search in sources :

Example 1 with MG94HKYCodonModel

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

the class PartitionData method createBranchModel.

public BranchModel createBranchModel() {
    BranchModel branchModel = null;
    if (this.substitutionModelIndex == 0) {
        // HKY
        Parameter kappa = new Parameter.Default(1, substitutionParameterValues[0]);
        FrequencyModel frequencyModel = this.createFrequencyModel();
        HKY hky = new HKY(kappa, frequencyModel);
        branchModel = new HomogeneousBranchModel(hky);
    } else if (this.substitutionModelIndex == 1) {
        // GTR
        Parameter ac = new Parameter.Default(1, substitutionParameterValues[1]);
        Parameter ag = new Parameter.Default(1, substitutionParameterValues[2]);
        Parameter at = new Parameter.Default(1, substitutionParameterValues[3]);
        Parameter cg = new Parameter.Default(1, substitutionParameterValues[4]);
        Parameter ct = new Parameter.Default(1, substitutionParameterValues[5]);
        Parameter gt = new Parameter.Default(1, substitutionParameterValues[6]);
        FrequencyModel frequencyModel = this.createFrequencyModel();
        GTR gtr = new GTR(ac, ag, at, cg, ct, gt, frequencyModel);
        branchModel = new HomogeneousBranchModel(gtr);
    } else if (this.substitutionModelIndex == 2) {
        // TN93
        Parameter kappa1 = new Parameter.Default(1, substitutionParameterValues[7]);
        Parameter kappa2 = new Parameter.Default(1, substitutionParameterValues[8]);
        FrequencyModel frequencyModel = this.createFrequencyModel();
        TN93 tn93 = new TN93(kappa1, kappa2, frequencyModel);
        branchModel = new HomogeneousBranchModel(tn93);
    } else if (this.substitutionModelIndex == 3) {
        // Yang Codon Model
        FrequencyModel frequencyModel = this.createFrequencyModel();
        Parameter kappa = new Parameter.Default(1, substitutionParameterValues[9]);
        Parameter omega = new Parameter.Default(1, substitutionParameterValues[10]);
        GY94CodonModel yangCodonModel = new GY94CodonModel(Codons.UNIVERSAL, omega, kappa, frequencyModel);
        branchModel = new HomogeneousBranchModel(yangCodonModel);
    } else if (this.substitutionModelIndex == 4) {
        // MG94CodonModel
        FrequencyModel frequencyModel = this.createFrequencyModel();
        Parameter alpha = new Parameter.Default(1, substitutionParameterValues[11]);
        Parameter beta = new Parameter.Default(1, substitutionParameterValues[12]);
        Parameter kappa = new Parameter.Default(1, substitutionParameterValues[13]);
        MG94HKYCodonModel mg94 = new MG94HKYCodonModel(Codons.UNIVERSAL, alpha, beta, kappa, frequencyModel);
        branchModel = new HomogeneousBranchModel(mg94);
    } else if (this.substitutionModelIndex == 5) {
        // Blosum62
        FrequencyModel frequencyModel = this.createFrequencyModel();
        EmpiricalRateMatrix rateMatrix = Blosum62.INSTANCE;
        EmpiricalAminoAcidModel empiricalAminoAcidModel = new EmpiricalAminoAcidModel(rateMatrix, frequencyModel);
        branchModel = new HomogeneousBranchModel(empiricalAminoAcidModel);
    } else if (this.substitutionModelIndex == 6) {
        // CPREV
        FrequencyModel frequencyModel = this.createFrequencyModel();
        EmpiricalRateMatrix rateMatrix = CPREV.INSTANCE;
        EmpiricalAminoAcidModel empiricalAminoAcidModel = new EmpiricalAminoAcidModel(rateMatrix, frequencyModel);
        branchModel = new HomogeneousBranchModel(empiricalAminoAcidModel);
    } else if (this.substitutionModelIndex == 7) {
        // Dayhoff
        FrequencyModel frequencyModel = this.createFrequencyModel();
        EmpiricalRateMatrix rateMatrix = Dayhoff.INSTANCE;
        EmpiricalAminoAcidModel empiricalAminoAcidModel = new EmpiricalAminoAcidModel(rateMatrix, frequencyModel);
        branchModel = new HomogeneousBranchModel(empiricalAminoAcidModel);
    } else if (this.substitutionModelIndex == 8) {
        // JTT
        FrequencyModel frequencyModel = this.createFrequencyModel();
        EmpiricalRateMatrix rateMatrix = JTT.INSTANCE;
        EmpiricalAminoAcidModel empiricalAminoAcidModel = new EmpiricalAminoAcidModel(rateMatrix, frequencyModel);
        branchModel = new HomogeneousBranchModel(empiricalAminoAcidModel);
    } else if (this.substitutionModelIndex == 9) {
        // LG
        FrequencyModel frequencyModel = this.createFrequencyModel();
        EmpiricalRateMatrix rateMatrix = LG.INSTANCE;
        EmpiricalAminoAcidModel empiricalAminoAcidModel = new EmpiricalAminoAcidModel(rateMatrix, frequencyModel);
        branchModel = new HomogeneousBranchModel(empiricalAminoAcidModel);
    } else if (this.substitutionModelIndex == 10) {
        // MTREV
        FrequencyModel frequencyModel = this.createFrequencyModel();
        EmpiricalRateMatrix rateMatrix = MTREV.INSTANCE;
        EmpiricalAminoAcidModel empiricalAminoAcidModel = new EmpiricalAminoAcidModel(rateMatrix, frequencyModel);
        branchModel = new HomogeneousBranchModel(empiricalAminoAcidModel);
    } else if (this.substitutionModelIndex == 11) {
        // WAG
        FrequencyModel frequencyModel = this.createFrequencyModel();
        EmpiricalRateMatrix rateMatrix = WAG.INSTANCE;
        EmpiricalAminoAcidModel empiricalAminoAcidModel = new EmpiricalAminoAcidModel(rateMatrix, frequencyModel);
        branchModel = new HomogeneousBranchModel(empiricalAminoAcidModel);
    } else {
        System.out.println("Not yet implemented");
    }
    return branchModel;
}
Also used : FrequencyModel(dr.evomodel.substmodel.FrequencyModel) EmpiricalRateMatrix(dr.evomodel.substmodel.EmpiricalRateMatrix) GTR(dr.evomodel.substmodel.nucleotide.GTR) HomogeneousBranchModel(dr.evomodel.branchmodel.HomogeneousBranchModel) HomogeneousBranchModel(dr.evomodel.branchmodel.HomogeneousBranchModel) BranchModel(dr.evomodel.branchmodel.BranchModel) TN93(dr.evomodel.substmodel.nucleotide.TN93) HKY(dr.evomodel.substmodel.nucleotide.HKY) Parameter(dr.inference.model.Parameter) GY94CodonModel(dr.evomodel.substmodel.codon.GY94CodonModel) MG94HKYCodonModel(dr.evomodel.substmodel.codon.MG94HKYCodonModel)

Example 2 with MG94HKYCodonModel

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

the class MG94CodonModelParser 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);
        codons = Codons.findByName(codeStr);
    }
    Parameter alphaParam = (Parameter) xo.getElementFirstChild(ALPHA);
    Parameter betaParam = (Parameter) xo.getElementFirstChild(BETA);
    FrequencyModel freqModel = (FrequencyModel) xo.getChild(FrequencyModel.class);
    MG94CodonModel codonModel;
    if (xo.hasChildNamed(GTR_MODEL)) {
        //TODO: change this into constructing a MG94CodonModel (needs to be written), which is started underneath
        codonModel = new MG94CodonModel(codons, alphaParam, betaParam, freqModel);
        Parameter rateACValue = null;
        if (xo.hasChildNamed(A_TO_C)) {
            rateACValue = (Parameter) xo.getElementFirstChild(A_TO_C);
        }
        Parameter rateAGValue = null;
        if (xo.hasChildNamed(A_TO_G)) {
            rateAGValue = (Parameter) xo.getElementFirstChild(A_TO_G);
        }
        Parameter rateATValue = null;
        if (xo.hasChildNamed(A_TO_T)) {
            rateATValue = (Parameter) xo.getElementFirstChild(A_TO_T);
        }
        Parameter rateCGValue = null;
        if (xo.hasChildNamed(C_TO_G)) {
            rateCGValue = (Parameter) xo.getElementFirstChild(C_TO_G);
        }
        Parameter rateCTValue = null;
        if (xo.hasChildNamed(C_TO_T)) {
            rateCTValue = (Parameter) xo.getElementFirstChild(C_TO_T);
        }
        Parameter rateGTValue = null;
        if (xo.hasChildNamed(G_TO_T)) {
            rateGTValue = (Parameter) xo.getElementFirstChild(G_TO_T);
        }
        int countNull = 0;
        if (rateACValue == null)
            countNull++;
        if (rateAGValue == null)
            countNull++;
        if (rateATValue == null)
            countNull++;
        if (rateCGValue == null)
            countNull++;
        if (rateCTValue == null)
            countNull++;
        if (rateGTValue == null)
            countNull++;
        if (countNull != 1)
            throw new XMLParseException("Only five parameters may be specified in GTR, leave exactly one out, the others will be specifed relative to the one left out.");
        if (xo.hasAttribute(KAPPA)) {
            System.err.print("using GTR rates -- overrides KAPPA");
        }
    } else if (xo.hasChildNamed(KAPPA)) {
        Parameter kappaParam = (Parameter) xo.getElementFirstChild(KAPPA);
        codonModel = new MG94HKYCodonModel(codons, alphaParam, betaParam, kappaParam, freqModel);
    //            System.err.println("setting up MG94HKYCodonModel");
    } else {
        //resort to standard MG94 without nucleotide rate bias
        codonModel = new MG94CodonModel(codons, alphaParam, betaParam, freqModel);
    }
    if (!xo.getAttribute(NORMALIZED, true)) {
    //            codonModel.setNormalization(false);
    //            Logger.getLogger("dr.app.beagle.evomodel").info("MG94CodonModel normalization: false");
    }
    return codonModel;
}
Also used : FrequencyModel(dr.evomodel.substmodel.FrequencyModel) MG94CodonModel(dr.evomodel.substmodel.codon.MG94CodonModel) Parameter(dr.inference.model.Parameter) Codons(dr.evolution.datatype.Codons) MG94HKYCodonModel(dr.evomodel.substmodel.codon.MG94HKYCodonModel)

Aggregations

FrequencyModel (dr.evomodel.substmodel.FrequencyModel)2 MG94HKYCodonModel (dr.evomodel.substmodel.codon.MG94HKYCodonModel)2 Parameter (dr.inference.model.Parameter)2 Codons (dr.evolution.datatype.Codons)1 BranchModel (dr.evomodel.branchmodel.BranchModel)1 HomogeneousBranchModel (dr.evomodel.branchmodel.HomogeneousBranchModel)1 EmpiricalRateMatrix (dr.evomodel.substmodel.EmpiricalRateMatrix)1 GY94CodonModel (dr.evomodel.substmodel.codon.GY94CodonModel)1 MG94CodonModel (dr.evomodel.substmodel.codon.MG94CodonModel)1 GTR (dr.evomodel.substmodel.nucleotide.GTR)1 HKY (dr.evomodel.substmodel.nucleotide.HKY)1 TN93 (dr.evomodel.substmodel.nucleotide.TN93)1