Search in sources :

Example 1 with TN93

use of dr.evomodel.substmodel.nucleotide.TN93 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 TN93

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

the class TN93Test method testTN93.

public void testTN93() {
    Parameter kappa1 = new Parameter.Default(5.0);
    Parameter kappa2 = new Parameter.Default(2.0);
    double[] pi = new double[] { 0.40, 0.20, 0.30, 0.10 };
    double time = 0.1;
    FrequencyModel freqModel = new FrequencyModel(Nucleotides.INSTANCE, pi);
    TN93 tn = new TN93(kappa1, kappa2, freqModel);
    EigenDecomposition decomp = tn.getEigenDecomposition();
    Vector eval = new Vector(decomp.getEigenValues());
    System.out.println("Eval = " + eval);
    double[] probs = new double[16];
    tn.getTransitionProbabilities(time, probs);
    System.out.println("new probs = " + new Vector(probs));
    // check against old implementation
    dr.oldevomodel.substmodel.FrequencyModel oldFreq = new dr.oldevomodel.substmodel.FrequencyModel(Nucleotides.INSTANCE, pi);
    dr.oldevomodel.substmodel.TN93 oldTN = new dr.oldevomodel.substmodel.TN93(kappa1, kappa2, oldFreq);
    double[] oldProbs = new double[16];
    oldTN.getTransitionProbabilities(time, oldProbs);
    System.out.println("old probs = " + new Vector(oldProbs));
    assertEquals(probs, oldProbs, 10E-6);
}
Also used : FrequencyModel(dr.evomodel.substmodel.FrequencyModel) TN93(dr.evomodel.substmodel.nucleotide.TN93) EigenDecomposition(dr.evomodel.substmodel.EigenDecomposition) Parameter(dr.inference.model.Parameter) Vector(dr.math.matrixAlgebra.Vector)

Example 3 with TN93

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

the class TN93Parser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    Parameter kappa1Param = (Parameter) xo.getElementFirstChild(KAPPA1);
    Parameter kappa2Param = (Parameter) xo.getElementFirstChild(KAPPA2);
    FrequencyModel freqModel = (FrequencyModel) xo.getElementFirstChild(FREQUENCIES);
    Logger.getLogger("dr.evomodel").info("\nCreating TN93 substitution model. Initial kappa = " + kappa1Param.getValue(0) + "," + kappa2Param.getValue(0));
    return new TN93(kappa1Param, kappa2Param, freqModel);
}
Also used : FrequencyModel(dr.evomodel.substmodel.FrequencyModel) TN93(dr.evomodel.substmodel.nucleotide.TN93) Parameter(dr.inference.model.Parameter)

Aggregations

FrequencyModel (dr.evomodel.substmodel.FrequencyModel)3 TN93 (dr.evomodel.substmodel.nucleotide.TN93)3 Parameter (dr.inference.model.Parameter)3 BranchModel (dr.evomodel.branchmodel.BranchModel)1 HomogeneousBranchModel (dr.evomodel.branchmodel.HomogeneousBranchModel)1 EigenDecomposition (dr.evomodel.substmodel.EigenDecomposition)1 EmpiricalRateMatrix (dr.evomodel.substmodel.EmpiricalRateMatrix)1 GY94CodonModel (dr.evomodel.substmodel.codon.GY94CodonModel)1 MG94HKYCodonModel (dr.evomodel.substmodel.codon.MG94HKYCodonModel)1 GTR (dr.evomodel.substmodel.nucleotide.GTR)1 HKY (dr.evomodel.substmodel.nucleotide.HKY)1 Vector (dr.math.matrixAlgebra.Vector)1