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;
}
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;
}
Aggregations