Search in sources :

Example 1 with RandomBranchModel

use of dr.evomodel.branchmodel.RandomBranchModel in project beast-mcmc by beast-dev.

the class RandomBranchModelParser method parseXMLObject.

@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    Logger.getLogger("dr.evomodel").info("\nUsing random assignment branch model.");
    TreeModel treeModel = (TreeModel) xo.getChild(TreeModel.class);
    GY94CodonModel baseSubstitutionModel = (GY94CodonModel) xo.getElementFirstChild(BASE_MODEL);
    long seed = -1;
    boolean hasSeed = false;
    if (xo.hasAttribute(SEED)) {
        seed = xo.getLongIntegerAttribute(SEED);
        hasSeed = true;
    }
    double rate = 1;
    if (xo.hasAttribute(RATE)) {
        rate = xo.getDoubleAttribute(RATE);
    }
    return new RandomBranchModel(treeModel, baseSubstitutionModel, rate, hasSeed, seed);
}
Also used : TreeModel(dr.evomodel.tree.TreeModel) RandomBranchModel(dr.evomodel.branchmodel.RandomBranchModel) GY94CodonModel(dr.evomodel.substmodel.codon.GY94CodonModel)

Example 2 with RandomBranchModel

use of dr.evomodel.branchmodel.RandomBranchModel in project beast-mcmc by beast-dev.

the class BeagleSeqSimTest method simulateRandomBranchAssignment.

// END: main
static void simulateRandomBranchAssignment() {
    try {
        System.out.println("Test case I dunno which: simulate random branch assignments");
        MathUtils.setSeed(666);
        int sequenceLength = 10;
        ArrayList<Partition> partitionsList = new ArrayList<Partition>();
        File treeFile = new File("/home/filip/Dropbox/BeagleSequenceSimulator/SimTree/SimTree.figtree");
        Tree tree = Utils.importTreeFromFile(treeFile);
        TreeModel treeModel = new TreeModel(tree);
        // create Frequency Model
        Parameter freqs = new Parameter.Default(Utils.UNIFORM_CODON_FREQUENCIES);
        FrequencyModel freqModel = new FrequencyModel(Codons.UNIVERSAL, freqs);
        // create base subst model
        Parameter omegaParameter = new Parameter.Default("omega", 1, 1.0);
        Parameter kappaParameter = new Parameter.Default("kappa", 1, 1.0);
        GY94CodonModel baseSubModel = new GY94CodonModel(Codons.UNIVERSAL, omegaParameter, kappaParameter, freqModel);
        RandomBranchModel substitutionModel = new RandomBranchModel(treeModel, baseSubModel, 0.25, false, -1);
        // create site model
        GammaSiteRateModel siteRateModel = new GammaSiteRateModel("siteModel");
        // create branch rate model
        BranchRateModel branchRateModel = new DefaultBranchRateModel();
        // create partition
        Partition partition1 = new //
        Partition(//
        treeModel, //
        substitutionModel, //
        siteRateModel, //
        branchRateModel, //
        freqModel, // from
        0, // to
        sequenceLength - 1, // every
        1);
        //			Sequence ancestralSequence = new Sequence();
        //			ancestralSequence.appendSequenceString("TCAAGTGAGG");
        //			partition1.setRootSequence(ancestralSequence);
        partitionsList.add(partition1);
        // feed to sequence simulator and generate data
        BeagleSequenceSimulator simulator = new BeagleSequenceSimulator(partitionsList);
        SimpleAlignment alignment = simulator.simulate(simulateInPar, true);
        // alignment.setOutputType(SimpleAlignment.OutputType.NEXUS);
        alignment.setOutputType(SimpleAlignment.OutputType.XML);
        System.out.println(alignment.toString());
    } catch (Exception e) {
        e.printStackTrace();
    }
// END: try-catch
}
Also used : FrequencyModel(dr.evomodel.substmodel.FrequencyModel) Partition(dr.app.beagle.tools.Partition) ArrayList(java.util.ArrayList) GammaSiteRateModel(dr.evomodel.siteratemodel.GammaSiteRateModel) BeagleSequenceSimulator(dr.app.beagle.tools.BeagleSequenceSimulator) ImportException(dr.evolution.io.Importer.ImportException) IOException(java.io.IOException) DefaultBranchRateModel(dr.evomodel.branchratemodel.DefaultBranchRateModel) TreeModel(dr.evomodel.tree.TreeModel) RandomBranchModel(dr.evomodel.branchmodel.RandomBranchModel) SimpleAlignment(dr.evolution.alignment.SimpleAlignment) DefaultBranchRateModel(dr.evomodel.branchratemodel.DefaultBranchRateModel) BranchRateModel(dr.evomodel.branchratemodel.BranchRateModel) Tree(dr.evolution.tree.Tree) Parameter(dr.inference.model.Parameter) GY94CodonModel(dr.evomodel.substmodel.codon.GY94CodonModel) File(java.io.File)

Aggregations

RandomBranchModel (dr.evomodel.branchmodel.RandomBranchModel)2 GY94CodonModel (dr.evomodel.substmodel.codon.GY94CodonModel)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 ImportException (dr.evolution.io.Importer.ImportException)1 Tree (dr.evolution.tree.Tree)1 BranchRateModel (dr.evomodel.branchratemodel.BranchRateModel)1 DefaultBranchRateModel (dr.evomodel.branchratemodel.DefaultBranchRateModel)1 GammaSiteRateModel (dr.evomodel.siteratemodel.GammaSiteRateModel)1 FrequencyModel (dr.evomodel.substmodel.FrequencyModel)1 Parameter (dr.inference.model.Parameter)1 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1