Search in sources :

Example 66 with TreeModel

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

the class BeagleBranchLikelihoodParser method parseXMLObject.

@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    TreeModel treeModel = (TreeModel) xo.getChild(TreeModel.class);
    // if(xo.hasChildNamed(TreeModel.TREE_MODEL)) {
    //
    // treeModel = (TreeModel) xo.getChild(TreeModel.class);
    // }
    Parameter zParameter = (Parameter) xo.getElementFirstChild(DirichletProcessPriorParser.CATEGORIES);
    List<Likelihood> likelihoods = new ArrayList<Likelihood>();
    XMLObject cxo = (XMLObject) xo.getChild(UNIQUE_LIKELIHOODS);
    for (int i = 0; i < cxo.getChildCount(); i++) {
        Likelihood likelihood = (Likelihood) cxo.getChild(i);
        likelihoods.add(likelihood);
    }
    return null;
//		new BeagleBranchLikelihood(
////				treeModel, likelihoods, zParameter
//				);
}
Also used : TreeModel(dr.evomodel.tree.TreeModel) Likelihood(dr.inference.model.Likelihood) ArrayList(java.util.ArrayList) Parameter(dr.inference.model.Parameter) XMLObject(dr.xml.XMLObject)

Example 67 with TreeModel

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

the class BranchSpecificTraitParser method parseXMLObject.

@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    BranchModel branchModel = (BranchModel) xo.getChild(BranchModel.class);
    //		CompoundParameter parameter = (CompoundParameter) xo.getChild(CompoundParameter.class);
    TreeModel treeModel = (TreeModel) xo.getChild(TreeModel.class);
    return new BranchSpecificTrait(treeModel, branchModel, xo.getId());
}
Also used : TreeModel(dr.evomodel.tree.TreeModel) BranchModel(dr.evomodel.branchmodel.BranchModel)

Example 68 with TreeModel

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

the class CoalescentLikelihoodParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    XMLObject cxo = xo.getChild(MODEL);
    DemographicModel demoModel = (DemographicModel) cxo.getChild(DemographicModel.class);
    List<TreeModel> trees = new ArrayList<TreeModel>();
    List<Double> popFactors = new ArrayList<Double>();
    MultiLociTreeSet treesSet = demoModel instanceof MultiLociTreeSet ? (MultiLociTreeSet) demoModel : null;
    for (int k = 0; k < xo.getChildCount(); ++k) {
        final Object child = xo.getChild(k);
        if (child instanceof XMLObject) {
            cxo = (XMLObject) child;
            if (cxo.getName().equals(POPULATION_TREE)) {
                final TreeModel t = (TreeModel) cxo.getChild(TreeModel.class);
                assert t != null;
                trees.add(t);
                popFactors.add(cxo.getAttribute(POPULATION_FACTOR, 1.0));
            }
        }
    //                in the future we may have arbitrary multi-loci element
    //                else if( child instanceof MultiLociTreeSet )  {
    //                    treesSet = (MultiLociTreeSet)child;
    //                }
    }
    TreeModel treeModel = null;
    if (trees.size() == 1 && popFactors.get(0) == 1.0) {
        treeModel = trees.get(0);
    } else if (trees.size() > 1) {
        treesSet = new MultiLociTreeSet.Default(trees, popFactors);
    } else if (!(trees.size() == 0 && treesSet != null)) {
        throw new XMLParseException("Incorrectly constructed likelihood element");
    }
    TaxonList includeSubtree = null;
    if (xo.hasChildNamed(INCLUDE)) {
        includeSubtree = (TaxonList) xo.getElementFirstChild(INCLUDE);
    }
    List<TaxonList> excludeSubtrees = new ArrayList<TaxonList>();
    if (xo.hasChildNamed(EXCLUDE)) {
        cxo = xo.getChild(EXCLUDE);
        for (int i = 0; i < cxo.getChildCount(); i++) {
            excludeSubtrees.add((TaxonList) cxo.getChild(i));
        }
    }
    if (treeModel != null) {
        try {
            return new CoalescentLikelihood(treeModel, includeSubtree, excludeSubtrees, demoModel);
        } catch (TreeUtils.MissingTaxonException mte) {
            throw new XMLParseException("treeModel missing a taxon from taxon list in " + getParserName() + " element");
        }
    } else {
        if (includeSubtree != null || excludeSubtrees.size() > 0) {
            throw new XMLParseException("Include/Exclude taxa not supported for multi locus sets");
        }
        // a base - and modifing it will probsbly result in a bigger mess.
        return new OldAbstractCoalescentLikelihood(treesSet, demoModel);
    }
}
Also used : TaxonList(dr.evolution.util.TaxonList) ArrayList(java.util.ArrayList) DemographicModel(dr.evomodel.coalescent.DemographicModel) TreeModel(dr.evomodel.tree.TreeModel) CoalescentLikelihood(dr.evomodel.coalescent.CoalescentLikelihood) OldAbstractCoalescentLikelihood(dr.evomodel.coalescent.OldAbstractCoalescentLikelihood) OldAbstractCoalescentLikelihood(dr.evomodel.coalescent.OldAbstractCoalescentLikelihood) MultiLociTreeSet(dr.evomodel.coalescent.MultiLociTreeSet) TreeUtils(dr.evolution.tree.TreeUtils)

Example 69 with TreeModel

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

the class EmergingEpidemicModelParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    Units.Type units = XMLUnits.Utils.getUnitsAttr(xo);
    Parameter growthRateParameter = (Parameter) xo.getElementFirstChild(GROWTH_RATE);
    Parameter generationTimeParameter = (Parameter) xo.getElementFirstChild(GENERATION_TIME);
    Parameter generationShapeParameter = (Parameter) xo.getElementFirstChild(GENERATION_DISTRIBUTION_SHAPE);
    Parameter offspringDispersionParameter = (Parameter) xo.getElementFirstChild(OFFSPRING_DISPERSION);
    TreeModel tree = (TreeModel) xo.getElementFirstChild(TREE);
    return new EmergingEpidemicModel(growthRateParameter, generationTimeParameter, generationShapeParameter, offspringDispersionParameter, tree, units);
}
Also used : TreeModel(dr.evomodel.tree.TreeModel) EmergingEpidemicModel(dr.evomodel.coalescent.EmergingEpidemicModel) Parameter(dr.inference.model.Parameter) Units(dr.evolution.util.Units) XMLUnits(dr.evoxml.util.XMLUnits)

Example 70 with TreeModel

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

the class FixedDriftModelParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    /*
        String idOne = xo.getStringAttribute(RATE_ONE_ID);

        String idTwo = xo.getStringAttribute(RATE_TWO_ID);

        Parameter rateOne = (Parameter) xo.getElementFirstChild(RATE_ONE);

        Parameter rateTwo = (Parameter) xo.getElementFirstChild(RATE_TWO);

        Parameter remainingRates = (Parameter) xo.getElementFirstChild(REMAINING_RATES);
        */
    TaxonList taxonList = (TaxonList) xo.getElementFirstChild(BACKBONE_TAXON_LIST);
    TreeModel treeModel = (TreeModel) xo.getChild(TreeModel.class);
    Parameter backboneDrift = (Parameter) xo.getElementFirstChild(BACKBONE_DRIFT);
    Parameter otherDrift = (Parameter) xo.getElementFirstChild(OTHER_DRIFT);
    Logger.getLogger("dr.evomodel").info("Using fixed drift model.");
    return new FixedDriftModel(treeModel, backboneDrift, otherDrift, taxonList);
//  return new FixedDriftModel(rateOne, rateTwo, remainingRates, idOne, idTwo);
}
Also used : TreeModel(dr.evomodel.tree.TreeModel) TaxonList(dr.evolution.util.TaxonList) FixedDriftModel(dr.evomodel.branchratemodel.FixedDriftModel) Parameter(dr.inference.model.Parameter)

Aggregations

TreeModel (dr.evomodel.tree.TreeModel)142 Parameter (dr.inference.model.Parameter)62 BranchRateModel (dr.evomodel.branchratemodel.BranchRateModel)28 ArrayList (java.util.ArrayList)28 Tree (dr.evolution.tree.Tree)26 NewickImporter (dr.evolution.io.NewickImporter)21 GammaSiteRateModel (dr.evomodel.siteratemodel.GammaSiteRateModel)20 FrequencyModel (dr.evomodel.substmodel.FrequencyModel)19 HomogeneousBranchModel (dr.evomodel.branchmodel.HomogeneousBranchModel)18 DefaultBranchRateModel (dr.evomodel.branchratemodel.DefaultBranchRateModel)15 SubstitutionModel (dr.evomodel.substmodel.SubstitutionModel)15 PatternList (dr.evolution.alignment.PatternList)14 NodeRef (dr.evolution.tree.NodeRef)14 Partition (dr.app.beagle.tools.Partition)12 BranchModel (dr.evomodel.branchmodel.BranchModel)12 IOException (java.io.IOException)12 BeagleSequenceSimulator (dr.app.beagle.tools.BeagleSequenceSimulator)11 Taxon (dr.evolution.util.Taxon)11 TaxonList (dr.evolution.util.TaxonList)11 Patterns (dr.evolution.alignment.Patterns)9