Search in sources :

Example 11 with Codons

use of dr.evolution.datatype.Codons in project beast-mcmc by beast-dev.

the class PCACodonModelParser 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;
        }
    }
    // get number of PCs
    Parameter pcaDimensionParameter = (Parameter) xo.getElementFirstChild(PCA_DIMENSION);
    // get directory with pca rate matrix files; fallback to default "pcadata"
    String dirString = "pcadata";
    if (xo.hasAttribute(PCA_DATA_DIR)) {
        dirString = xo.getStringAttribute(PCA_DATA_DIR);
    }
    // get type of rate matrix; fallback to mammalia pca
    AbstractPCARateMatrix pcaType = new PCARateMatrixMammalia(pcaDimensionParameter.getDimension(), dirString);
    // check for other type of pca
    if (xo.hasAttribute(PCATYPE)) {
        String pcaTypeString = xo.getStringAttribute(PCATYPE);
        if (pcaTypeString.equals(PCARateMatrixMammalia.getName())) {
            pcaType = new PCARateMatrixMammalia(pcaDimensionParameter.getDimension(), dirString);
        }
    }
    // decide if getting frequencies from csv or estimating from MSA
    FrequencyModel freqModel = null;
    if (xo.getChild(FrequencyModel.class) != null) {
        freqModel = (FrequencyModel) xo.getChild(FrequencyModel.class);
    } else {
        freqModel = createNewFreqModel(codons, pcaType);
    }
    return new PCACodonModel(codons, pcaType, pcaDimensionParameter, freqModel);
}
Also used : FrequencyModel(dr.evomodel.substmodel.FrequencyModel) PCARateMatrixMammalia(dr.evomodel.substmodel.PCARateMatrixMammalia) AbstractPCARateMatrix(dr.evomodel.substmodel.AbstractPCARateMatrix) PCACodonModel(dr.evomodel.substmodel.codon.PCACodonModel) Parameter(dr.inference.model.Parameter) Codons(dr.evolution.datatype.Codons)

Example 12 with Codons

use of dr.evolution.datatype.Codons 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)

Example 13 with Codons

use of dr.evolution.datatype.Codons in project beast-mcmc by beast-dev.

the class PCACodonModelParser 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;
        }
    }
    // get number of PCs
    Parameter pcaDimensionParameter = (Parameter) xo.getElementFirstChild(PCA_DIMENSION);
    // get directory with pca rate matrix files; fallback to default "pcadata"
    String dirString = "pcadata";
    if (xo.hasAttribute(PCA_DATA_DIR)) {
        dirString = xo.getStringAttribute(PCA_DATA_DIR);
    }
    // get type of rate matrix; fallback to mammalia pca
    AbstractPCARateMatrix pcaType = new PCARateMatrixMammalia(pcaDimensionParameter.getDimension(), dirString);
    // check for other type of pca
    if (xo.hasAttribute(PCATYPE)) {
        String pcaTypeString = xo.getStringAttribute(PCATYPE);
        if (pcaTypeString.equals(PCARateMatrixMammalia.getName())) {
            pcaType = new PCARateMatrixMammalia(pcaDimensionParameter.getDimension(), dirString);
        }
    }
    // decide if getting frequencies from csv or estimating from MSA
    FrequencyModel freqModel = null;
    if (xo.getChild(FrequencyModel.class) != null) {
        freqModel = (FrequencyModel) xo.getChild(FrequencyModel.class);
    } else {
        freqModel = createNewFreqModel(codons, pcaType);
    }
    return new PCACodonModel(codons, pcaType, pcaDimensionParameter, freqModel);
}
Also used : FrequencyModel(dr.oldevomodel.substmodel.FrequencyModel) PCARateMatrixMammalia(dr.oldevomodel.substmodel.PCARateMatrixMammalia) AbstractPCARateMatrix(dr.oldevomodel.substmodel.AbstractPCARateMatrix) PCACodonModel(dr.oldevomodel.substmodel.PCACodonModel) Parameter(dr.inference.model.Parameter) Codons(dr.evolution.datatype.Codons)

Aggregations

Codons (dr.evolution.datatype.Codons)13 Parameter (dr.inference.model.Parameter)9 FrequencyModel (dr.evomodel.substmodel.FrequencyModel)5 BranchRateModel (dr.evomodel.branchratemodel.BranchRateModel)3 FrequencyModel (dr.oldevomodel.substmodel.FrequencyModel)3 DataType (dr.evolution.datatype.DataType)2 DefaultBranchRateModel (dr.evomodel.branchratemodel.DefaultBranchRateModel)2 GammaSiteRateModel (dr.evomodel.siteratemodel.GammaSiteRateModel)2 GY94CodonModel (dr.evomodel.substmodel.codon.GY94CodonModel)2 BeagleSequenceSimulator (dr.app.beagle.tools.BeagleSequenceSimulator)1 CompleteHistorySimulator (dr.app.beagle.tools.CompleteHistorySimulator)1 Partition (dr.app.beagle.tools.Partition)1 SimpleAlignment (dr.evolution.alignment.SimpleAlignment)1 HiddenDataType (dr.evolution.datatype.HiddenDataType)1 Nucleotides (dr.evolution.datatype.Nucleotides)1 NodeRef (dr.evolution.tree.NodeRef)1 Tree (dr.evolution.tree.Tree)1 AbstractPCARateMatrix (dr.evomodel.substmodel.AbstractPCARateMatrix)1 CodonLabeling (dr.evomodel.substmodel.CodonLabeling)1 CodonPartitionedRobustCounting (dr.evomodel.substmodel.CodonPartitionedRobustCounting)1