Search in sources :

Example 6 with GY94CodonModel

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

the class RandomBranchModel method setup.

// END: Constructor
private void setup() {
    DataType dataType = baseSubstitutionModel.getDataType();
    FrequencyModel freqModel = baseSubstitutionModel.getFrequencyModel();
    Parameter kappaParameter = new Parameter.Default("kappa", 1, baseSubstitutionModel.getKappa());
    substitutionModels = new LinkedList<SubstitutionModel>();
    branchAssignmentMap = new LinkedHashMap<NodeRef, Integer>();
    int branchClass = 0;
    for (NodeRef node : treeModel.getNodes()) {
        if (!treeModel.isRoot(node)) {
            double nodeHeight = treeModel.getNodeHeight(node);
            double parentHeight = treeModel.getNodeHeight(treeModel.getParent(node));
            double time = 0.5 * (parentHeight + nodeHeight);
            double baseOmega = baseSubstitutionModel.getOmega();
            double fixed = baseOmega * time;
            //Math.exp((random.nextGaussian() * stdev + mean));
            double epsilon = (Math.log(1 - random.nextDouble()) / (-rate));
            double value = fixed + epsilon;
            Parameter omegaParameter = new Parameter.Default("omega", 1, value);
            GY94CodonModel gy94 = new GY94CodonModel((Codons) dataType, omegaParameter, kappaParameter, freqModel);
            substitutionModels.add(gy94);
            branchAssignmentMap.put(node, branchClass);
            branchClass++;
        }
    //END: root check
    }
// END: nodes loop
}
Also used : FrequencyModel(dr.evomodel.substmodel.FrequencyModel) NodeRef(dr.evolution.tree.NodeRef) DataType(dr.evolution.datatype.DataType) Parameter(dr.inference.model.Parameter) GY94CodonModel(dr.evomodel.substmodel.codon.GY94CodonModel) SubstitutionModel(dr.evomodel.substmodel.SubstitutionModel)

Aggregations

GY94CodonModel (dr.evomodel.substmodel.codon.GY94CodonModel)6 FrequencyModel (dr.evomodel.substmodel.FrequencyModel)5 Parameter (dr.inference.model.Parameter)5 Codons (dr.evolution.datatype.Codons)2 RandomBranchModel (dr.evomodel.branchmodel.RandomBranchModel)2 BranchRateModel (dr.evomodel.branchratemodel.BranchRateModel)2 DefaultBranchRateModel (dr.evomodel.branchratemodel.DefaultBranchRateModel)2 GammaSiteRateModel (dr.evomodel.siteratemodel.GammaSiteRateModel)2 TreeModel (dr.evomodel.tree.TreeModel)2 BeagleSequenceSimulator (dr.app.beagle.tools.BeagleSequenceSimulator)1 Partition (dr.app.beagle.tools.Partition)1 SimpleAlignment (dr.evolution.alignment.SimpleAlignment)1 DataType (dr.evolution.datatype.DataType)1 ImportException (dr.evolution.io.Importer.ImportException)1 NodeRef (dr.evolution.tree.NodeRef)1 Tree (dr.evolution.tree.Tree)1 BranchModel (dr.evomodel.branchmodel.BranchModel)1 HomogeneousBranchModel (dr.evomodel.branchmodel.HomogeneousBranchModel)1 EmpiricalRateMatrix (dr.evomodel.substmodel.EmpiricalRateMatrix)1 SubstitutionModel (dr.evomodel.substmodel.SubstitutionModel)1