Search in sources :

Example 1 with DefaultTreeModel

use of dr.evomodel.tree.DefaultTreeModel in project beast-mcmc by beast-dev.

the class DataLikelihoodTester2 method createSpecifiedTree.

private static TreeModel createSpecifiedTree(String t) throws Exception {
    NewickImporter importer = new NewickImporter(t);
    Tree tree = importer.importTree(null);
    // treeModel
    return new DefaultTreeModel(tree);
}
Also used : NewickImporter(dr.evolution.io.NewickImporter) Tree(dr.evolution.tree.Tree) DefaultTreeModel(dr.evomodel.tree.DefaultTreeModel)

Example 2 with DefaultTreeModel

use of dr.evomodel.tree.DefaultTreeModel in project beast-mcmc by beast-dev.

the class SubtreeSlideOperatorParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    boolean swapRates = xo.getAttribute(SWAP_RATES, false);
    boolean swapTraits = xo.getAttribute(SWAP_TRAITS, false);
    boolean scaledDirichletBranches = xo.getAttribute(DIRICHLET_BRANCHES, false);
    AdaptationMode mode = AdaptationMode.DEFAULT;
    if (xo.hasAttribute(AdaptableMCMCOperator.AUTO_OPTIMIZE)) {
        if (xo.getBooleanAttribute(AdaptableMCMCOperator.AUTO_OPTIMIZE)) {
            mode = AdaptationMode.ADAPTATION_ON;
        } else {
            mode = AdaptationMode.ADAPTATION_OFF;
        }
    }
    DefaultTreeModel treeModel = (DefaultTreeModel) xo.getChild(DefaultTreeModel.class);
    final double weight = xo.getDoubleAttribute(MCMCOperator.WEIGHT);
    final double targetAcceptance = xo.getAttribute(TARGET_ACCEPTANCE, 0.234);
    final double size = xo.getAttribute("size", 1.0);
    if (Double.isInfinite(size) || size <= 0.0) {
        throw new XMLParseException("size attribute must be positive and not infinite. was " + size + " for tree " + treeModel.getId());
    }
    final boolean gaussian = xo.getBooleanAttribute("gaussian");
    SubtreeSlideOperator operator = new SubtreeSlideOperator(treeModel, weight, size, gaussian, swapRates, swapTraits, scaledDirichletBranches, mode, targetAcceptance);
    return operator;
}
Also used : AdaptationMode(dr.inference.operators.AdaptationMode) SubtreeSlideOperator(dr.evomodel.operators.SubtreeSlideOperator) DefaultTreeModel(dr.evomodel.tree.DefaultTreeModel)

Example 3 with DefaultTreeModel

use of dr.evomodel.tree.DefaultTreeModel in project beast-mcmc by beast-dev.

the class TreeBitRandomWalkOperatorParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    double weight = xo.getDoubleAttribute(MCMCOperator.WEIGHT);
    DefaultTreeModel treeModel = (DefaultTreeModel) xo.getChild(DefaultTreeModel.class);
    String trait1 = null;
    String trait2 = null;
    if (xo.hasAttribute(INDICTATOR_TRAIT))
        trait1 = xo.getStringAttribute(INDICTATOR_TRAIT);
    if (xo.hasAttribute(TRAIT2))
        trait2 = xo.getStringAttribute(TRAIT2);
    int k = xo.getAttribute("k", 1);
    boolean swapTrait2 = xo.getAttribute(SWAP_TRAIT2, true);
    return new TreeBitRandomWalkOperator(treeModel, trait1, trait2, weight, k, swapTrait2);
}
Also used : DefaultTreeModel(dr.evomodel.tree.DefaultTreeModel) TreeBitRandomWalkOperator(dr.evomodel.operators.TreeBitRandomWalkOperator)

Example 4 with DefaultTreeModel

use of dr.evomodel.tree.DefaultTreeModel in project beast-mcmc by beast-dev.

the class TreeBitMoveOperatorParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    double weight = xo.getDoubleAttribute(MCMCOperator.WEIGHT);
    DefaultTreeModel treeModel = (DefaultTreeModel) xo.getChild(DefaultTreeModel.class);
    String trait1 = null;
    String trait2 = null;
    if (xo.hasAttribute(INDICTATOR_TRAIT))
        trait1 = xo.getStringAttribute(INDICTATOR_TRAIT);
    if (xo.hasAttribute(TRAIT2))
        trait2 = xo.getStringAttribute(TRAIT2);
    return new TreeBitMoveOperator(treeModel, trait1, trait2, weight);
}
Also used : TreeBitMoveOperator(dr.evomodel.operators.TreeBitMoveOperator) DefaultTreeModel(dr.evomodel.tree.DefaultTreeModel)

Example 5 with DefaultTreeModel

use of dr.evomodel.tree.DefaultTreeModel in project beast-mcmc by beast-dev.

the class BeagleSeqSimTest method simulateAminoAcid.

// END: simulateThreePartitions
static void simulateAminoAcid() {
    try {
        System.out.println("Test case 4: simulateAminoAcid");
        MathUtils.setSeed(666);
        int sequenceLength = 10;
        ArrayList<Partition> partitionsList = new ArrayList<Partition>();
        // create tree
        NewickImporter importer = new NewickImporter("(SimSeq1:73.7468,(SimSeq2:25.256989999999995,SimSeq3:45.256989999999995):18.48981);");
        Tree tree = importer.importTree(null);
        DefaultTreeModel treeModel = new DefaultTreeModel(tree);
        // create site model
        GammaSiteRateModel siteRateModel = new GammaSiteRateModel("siteModel");
        // create branch rate model
        BranchRateModel branchRateModel = new DefaultBranchRateModel();
        // create Frequency Model
        Parameter freqs = new Parameter.Default(new double[] { 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05 });
        FrequencyModel freqModel = new FrequencyModel(AminoAcids.INSTANCE, freqs);
        // create substitution model
        EmpiricalRateMatrix rateMatrix = Blosum62.INSTANCE;
        EmpiricalAminoAcidModel empiricalAminoAcidModel = new EmpiricalAminoAcidModel(rateMatrix, freqModel);
        HomogeneousBranchModel substitutionModel = new HomogeneousBranchModel(empiricalAminoAcidModel);
        // create partition
        Partition partition1 = new // 
        Partition(// 
        treeModel, // 
        substitutionModel, // 
        siteRateModel, // 
        branchRateModel, // 
        freqModel, // from
        0, // to
        sequenceLength - 1, // every
        1);
        partitionsList.add(partition1);
        // feed to sequence simulator and generate data
        BeagleSequenceSimulator simulator = new BeagleSequenceSimulator(partitionsList);
        System.out.println(simulator.simulate(simulateInPar, false).toString());
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(-1);
    }
// END: try-catch
}
Also used : FrequencyModel(dr.evomodel.substmodel.FrequencyModel) Partition(dr.app.beagle.tools.Partition) EmpiricalRateMatrix(dr.evomodel.substmodel.EmpiricalRateMatrix) EmpiricalAminoAcidModel(dr.evomodel.substmodel.aminoacid.EmpiricalAminoAcidModel) ArrayList(java.util.ArrayList) HomogeneousBranchModel(dr.evomodel.branchmodel.HomogeneousBranchModel) GammaSiteRateModel(dr.evomodel.siteratemodel.GammaSiteRateModel) DefaultTreeModel(dr.evomodel.tree.DefaultTreeModel) BeagleSequenceSimulator(dr.app.beagle.tools.BeagleSequenceSimulator) ImportException(dr.evolution.io.Importer.ImportException) IOException(java.io.IOException) DefaultBranchRateModel(dr.evomodel.branchratemodel.DefaultBranchRateModel) DefaultBranchRateModel(dr.evomodel.branchratemodel.DefaultBranchRateModel) BranchRateModel(dr.evomodel.branchratemodel.BranchRateModel) NewickImporter(dr.evolution.io.NewickImporter) Tree(dr.evolution.tree.Tree) Parameter(dr.inference.model.Parameter)

Aggregations

DefaultTreeModel (dr.evomodel.tree.DefaultTreeModel)46 Tree (dr.evolution.tree.Tree)21 NewickImporter (dr.evolution.io.NewickImporter)19 Parameter (dr.inference.model.Parameter)19 ArrayList (java.util.ArrayList)14 BranchRateModel (dr.evomodel.branchratemodel.BranchRateModel)10 TreeModel (dr.evomodel.tree.TreeModel)10 GammaSiteModel (dr.oldevomodel.sitemodel.GammaSiteModel)10 HomogeneousBranchModel (dr.evomodel.branchmodel.HomogeneousBranchModel)9 GammaSiteRateModel (dr.evomodel.siteratemodel.GammaSiteRateModel)9 FrequencyModel (dr.evomodel.substmodel.FrequencyModel)9 TreeLikelihood (dr.oldevomodel.treelikelihood.TreeLikelihood)9 BeagleSequenceSimulator (dr.app.beagle.tools.BeagleSequenceSimulator)8 Partition (dr.app.beagle.tools.Partition)8 ImportException (dr.evolution.io.Importer.ImportException)8 Taxa (dr.evolution.util.Taxa)8 Taxon (dr.evolution.util.Taxon)8 DefaultBranchRateModel (dr.evomodel.branchratemodel.DefaultBranchRateModel)8 IOException (java.io.IOException)8 ExchangeOperator (dr.evomodel.operators.ExchangeOperator)7