Search in sources :

Example 51 with Tree

use of dr.evolution.tree.Tree in project beast-mcmc by beast-dev.

the class SpeciesTreeModelParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    SpeciesBindings spb = (SpeciesBindings) xo.getChild(SpeciesBindings.class);
    Parameter coalPointsPops = null;
    Parameter coalPointsIndicators = null;
    final Boolean cr = xo.getAttribute(CONST_ROOT_POPULATION, false);
    final Boolean cp = xo.getAttribute(CONSTANT_POPULATION, false);
    final Boolean bmp = xo.getAttribute(BMPRIOR, false);
    {
        XMLObject cxo = xo.getChild(COALESCENT_POINTS_POPULATIONS);
        if (cxo != null) {
            final double value = cxo.getAttribute(Attributable.VALUE, 1.0);
            coalPointsPops = SpeciesTreeModel.createCoalPointsPopParameter(spb, cxo.getAttribute(Attributable.VALUE, value), bmp);
            ParameterParser.replaceParameter(cxo, coalPointsPops);
            coalPointsPops.addBounds(new Parameter.DefaultBounds(Double.MAX_VALUE, 0, coalPointsPops.getDimension()));
            cxo = xo.getChild(COALESCENT_POINTS_INDICATORS);
            if (cxo == null) {
                throw new XMLParseException("Must have indicators");
            }
            coalPointsIndicators = new Parameter.Default(coalPointsPops.getDimension(), 0);
            ParameterParser.replaceParameter(cxo, coalPointsIndicators);
        } else {
        // assert ! bmp;
        }
    }
    final XMLObject cxo = xo.getChild(SPP_SPLIT_POPULATIONS);
    final double value = cxo.getAttribute(Attributable.VALUE, 1.0);
    final boolean nonConstRootPopulation = coalPointsPops == null && !cr;
    final Parameter sppSplitPopulations = SpeciesTreeModel.createSplitPopulationsParameter(spb, value, nonConstRootPopulation, cp);
    ParameterParser.replaceParameter(cxo, sppSplitPopulations);
    final Parameter.DefaultBounds bounds = new Parameter.DefaultBounds(Double.MAX_VALUE, 0, sppSplitPopulations.getDimension());
    sppSplitPopulations.addBounds(bounds);
    final Tree startTree = (Tree) xo.getChild(Tree.class);
    return new SpeciesTreeModel(spb, sppSplitPopulations, coalPointsPops, coalPointsIndicators, startTree, bmp, nonConstRootPopulation, cp);
}
Also used : SpeciesBindings(dr.evomodel.speciation.SpeciesBindings) Parameter(dr.inference.model.Parameter) Tree(dr.evolution.tree.Tree) SpeciesTreeModel(dr.evomodel.speciation.SpeciesTreeModel)

Example 52 with Tree

use of dr.evolution.tree.Tree in project beast-mcmc by beast-dev.

the class BetaSplittingModelParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    XMLObject cxo = xo.getChild(PHI);
    Parameter phiParameter = (Parameter) cxo.getChild(Parameter.class);
    cxo = xo.getChild(TREE);
    Tree tree = (Tree) cxo.getChild(Tree.class);
    return new BetaSplittingModel(phiParameter, tree);
}
Also used : Parameter(dr.inference.model.Parameter) Tree(dr.evolution.tree.Tree) BetaSplittingModel(dr.evomodel.speciation.BetaSplittingModel)

Example 53 with Tree

use of dr.evolution.tree.Tree in project beast-mcmc by beast-dev.

the class CompatibilityStatisticParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    String name = xo.getAttribute(Statistic.NAME, xo.getId());
    Tree tree1 = (Tree) xo.getChild(Tree.class);
    XMLObject cxo = xo.getChild(COMPATIBLE_WITH);
    Tree tree2 = (Tree) cxo.getChild(Tree.class);
    try {
        return new CompatibilityStatistic(name, tree1, tree2);
    } catch (TreeUtils.MissingTaxonException mte) {
        throw new XMLParseException("Taxon, " + mte + ", in " + getParserName() + "was in the source tree but not the constraints tree.");
    }
}
Also used : Tree(dr.evolution.tree.Tree) CompatibilityStatistic(dr.evomodel.tree.CompatibilityStatistic) TreeUtils(dr.evolution.tree.TreeUtils)

Example 54 with Tree

use of dr.evolution.tree.Tree in project beast-mcmc by beast-dev.

the class MsatFullLikelihoodTest method setUp.

public void setUp() throws Exception {
    super.setUp();
    //taxa
    ArrayList<Taxon> taxonList1 = new ArrayList<Taxon>();
    Collections.addAll(taxonList1, new Taxon("taxon1"), new Taxon("taxon2"), new Taxon("taxon3"));
    Taxa taxa1 = new Taxa(taxonList1);
    //msat datatype
    Microsatellite msat = new Microsatellite(1, 3);
    Patterns msatPatterns = new Patterns(msat, taxa1);
    //pattern in the correct code form.
    msatPatterns.addPattern(new int[] { 0, 1, 2 });
    //create tree
    NewickImporter importer = new NewickImporter("(taxon1:7.5,(taxon2:5.3,taxon3:5.3):2.2);");
    Tree tree = importer.importTree(null);
    //treeModel
    TreeModel treeModel = new TreeModel(tree);
    //msatsubstModel
    AsymmetricQuadraticModel aqm1 = new AsymmetricQuadraticModel(msat, null);
    //siteModel
    GammaSiteModel siteModel = new GammaSiteModel(aqm1);
    //treeLikelihood
    treeLikelihood1 = new TreeLikelihood(msatPatterns, treeModel, siteModel, null, null, false, false, true, false, false);
    setUpExample2();
    setUpExample3();
}
Also used : Taxa(dr.evolution.util.Taxa) Microsatellite(dr.evolution.datatype.Microsatellite) TreeModel(dr.evomodel.tree.TreeModel) GammaSiteModel(dr.oldevomodel.sitemodel.GammaSiteModel) Taxon(dr.evolution.util.Taxon) NewickImporter(dr.evolution.io.NewickImporter) ArrayList(java.util.ArrayList) AsymmetricQuadraticModel(dr.oldevomodel.substmodel.AsymmetricQuadraticModel) TreeLikelihood(dr.oldevomodel.treelikelihood.TreeLikelihood) Tree(dr.evolution.tree.Tree) Patterns(dr.evolution.alignment.Patterns)

Example 55 with Tree

use of dr.evolution.tree.Tree in project beast-mcmc by beast-dev.

the class MsatFullLikelihoodTest method setUpExample2.

private void setUpExample2() throws Exception {
    //taxa
    ArrayList<Taxon> taxonList2 = new ArrayList<Taxon>();
    Collections.addAll(taxonList2, new Taxon("taxon1"), new Taxon("taxon2"), new Taxon("taxon3"), new Taxon("taxon4"), new Taxon("taxon5"));
    Taxa taxa2 = new Taxa(taxonList2);
    //msat datatype
    Microsatellite msat = new Microsatellite(1, 3);
    Patterns msatPatterns = new Patterns(msat, taxa2);
    //pattern in the correct code form.
    msatPatterns.addPattern(new int[] { 0, 1, 2, 1, 2 });
    //create tree
    NewickImporter importer = new NewickImporter("(((taxon1:1.5,taxon2:1.5):1.5,(taxon3:2.1,taxon4:2.1):0.9):0.7,taxon5:3.7);");
    Tree tree = importer.importTree(null);
    //treeModel
    TreeModel treeModel = new TreeModel(tree);
    //msatsubstModel
    AsymmetricQuadraticModel aqm2 = new AsymmetricQuadraticModel(msat, null);
    //siteModel
    GammaSiteModel siteModel = new GammaSiteModel(aqm2);
    //treeLikelihood
    treeLikelihood2 = new TreeLikelihood(msatPatterns, treeModel, siteModel, null, null, false, false, true, false, false);
}
Also used : Taxa(dr.evolution.util.Taxa) Microsatellite(dr.evolution.datatype.Microsatellite) TreeModel(dr.evomodel.tree.TreeModel) GammaSiteModel(dr.oldevomodel.sitemodel.GammaSiteModel) Taxon(dr.evolution.util.Taxon) NewickImporter(dr.evolution.io.NewickImporter) ArrayList(java.util.ArrayList) AsymmetricQuadraticModel(dr.oldevomodel.substmodel.AsymmetricQuadraticModel) TreeLikelihood(dr.oldevomodel.treelikelihood.TreeLikelihood) Tree(dr.evolution.tree.Tree) Patterns(dr.evolution.alignment.Patterns)

Aggregations

Tree (dr.evolution.tree.Tree)128 NewickImporter (dr.evolution.io.NewickImporter)32 ArrayList (java.util.ArrayList)31 TreeModel (dr.evomodel.tree.TreeModel)26 Parameter (dr.inference.model.Parameter)26 NexusImporter (dr.evolution.io.NexusImporter)18 TaxonList (dr.evolution.util.TaxonList)18 Taxa (dr.evolution.util.Taxa)17 FlexibleTree (dr.evolution.tree.FlexibleTree)16 Taxon (dr.evolution.util.Taxon)15 BranchRateModel (dr.evomodel.branchratemodel.BranchRateModel)15 NodeRef (dr.evolution.tree.NodeRef)14 SimpleTree (dr.evolution.tree.SimpleTree)13 ImportException (dr.evolution.io.Importer.ImportException)12 Importer (dr.evolution.io.Importer)11 DefaultBranchRateModel (dr.evomodel.branchratemodel.DefaultBranchRateModel)11 BeagleSequenceSimulator (dr.app.beagle.tools.BeagleSequenceSimulator)10 Partition (dr.app.beagle.tools.Partition)10 GammaSiteRateModel (dr.evomodel.siteratemodel.GammaSiteRateModel)10 FrequencyModel (dr.evomodel.substmodel.FrequencyModel)9