Search in sources :

Example 36 with TreeModel

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

the class SingleTipObservationProcessParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    Parameter mu = (Parameter) xo.getElementFirstChild(AnyTipObservationProcessParser.DEATH_RATE);
    Parameter lam = (Parameter) xo.getElementFirstChild(AnyTipObservationProcessParser.IMMIGRATION_RATE);
    TreeModel treeModel = (TreeModel) xo.getChild(TreeModel.class);
    PatternList patterns = (PatternList) xo.getChild(PatternList.class);
    Taxon sourceTaxon = (Taxon) xo.getChild(Taxon.class);
    SiteModel siteModel = (SiteModel) xo.getChild(SiteModel.class);
    BranchRateModel branchRateModel = (BranchRateModel) xo.getChild(BranchRateModel.class);
    Logger.getLogger("dr.evomodel.MSSD").info("Creating SingleTipObservationProcess model. All traits are assumed extant in " + sourceTaxon.getId() + "Initial mu = " + mu.getParameterValue(0) + " initial lam = " + lam.getParameterValue(0));
    return new SingleTipObservationProcess(treeModel, patterns, siteModel, branchRateModel, mu, lam, sourceTaxon);
}
Also used : TreeModel(dr.evomodel.tree.TreeModel) SingleTipObservationProcess(dr.oldevomodel.MSSD.SingleTipObservationProcess) BranchRateModel(dr.evomodel.branchratemodel.BranchRateModel) Taxon(dr.evolution.util.Taxon) PatternList(dr.evolution.alignment.PatternList) Parameter(dr.inference.model.Parameter) SiteModel(dr.oldevomodel.sitemodel.SiteModel)

Example 37 with TreeModel

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

the class ScaledPiecewiseModelParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    Units.Type units = XMLUnits.Utils.getUnitsAttr(xo);
    XMLObject cxo = xo.getChild(EPOCH_SIZES);
    Parameter epochSizes = (Parameter) cxo.getChild(Parameter.class);
    cxo = xo.getChild(TREE_MODEL);
    TreeModel treeModel = (TreeModel) cxo.getChild(TreeModel.class);
    boolean isLinear = xo.getBooleanAttribute("linear");
    return new ScaledPiecewiseModel(epochSizes, treeModel, isLinear, units);
}
Also used : TreeModel(dr.evomodel.tree.TreeModel) Parameter(dr.inference.model.Parameter) Units(dr.evolution.util.Units) XMLUnits(dr.evoxml.util.XMLUnits) ScaledPiecewiseModel(dr.evomodel.coalescent.ScaledPiecewiseModel)

Example 38 with TreeModel

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

the class VariableSkylineLikelihoodParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    XMLObject cxo = xo.getChild(POPULATION_SIZES);
    Parameter param = (Parameter) cxo.getChild(Parameter.class);
    cxo = xo.getChild(INDICATOR_PARAMETER);
    Parameter param2 = (Parameter) cxo.getChild(Parameter.class);
    cxo = xo.getChild(CoalescentLikelihoodParser.POPULATION_TREE);
    TreeModel treeModel = (TreeModel) cxo.getChild(TreeModel.class);
    VariableSkylineLikelihood.Type type = VariableSkylineLikelihood.Type.STEPWISE;
    if (xo.hasAttribute(TYPE)) {
        final String s = xo.getStringAttribute(TYPE);
        if (s.equalsIgnoreCase(STEPWISE)) {
            type = VariableSkylineLikelihood.Type.STEPWISE;
        } else if (s.equalsIgnoreCase(LINEAR)) {
            type = VariableSkylineLikelihood.Type.LINEAR;
        } else if (s.equalsIgnoreCase(EXPONENTIAL)) {
            type = VariableSkylineLikelihood.Type.EXPONENTIAL;
        } else {
            throw new XMLParseException("Unknown Bayesian Skyline type: " + s);
        }
    }
    boolean logSpace = xo.getBooleanAttribute(LOG_SPACE);
    Logger.getLogger("dr.evomodel").info("Variable skyline plot: " + type.toString() + " control points");
    return new VariableSkylineLikelihood(treeModel, param, param2, type, logSpace);
}
Also used : TreeModel(dr.evomodel.tree.TreeModel) VariableSkylineLikelihood(dr.evomodel.coalescent.VariableSkylineLikelihood) Parameter(dr.inference.model.Parameter)

Example 39 with TreeModel

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

the class NNIParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    TreeModel treeModel = (TreeModel) xo.getChild(TreeModel.class);
    double weight = xo.getDoubleAttribute(MCMCOperator.WEIGHT);
    return new NNI(treeModel, weight);
}
Also used : TreeModel(dr.evomodel.tree.TreeModel) NNI(dr.evomodel.operators.NNI)

Example 40 with TreeModel

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

the class LeafTraitExtractorParser method parseXMLObject.

@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    TreeModel model = (TreeModel) xo.getChild(TreeModel.class);
    final CompoundParameter allTraits = (CompoundParameter) xo.getChild(CompoundParameter.class);
    String taxonString = (String) xo.getAttribute(TreeModelParser.TAXON);
    final int leafIndex = model.getTaxonIndex(taxonString);
    if (leafIndex == -1) {
        throw new XMLParseException("Unable to find taxon '" + taxonString + "' in trees.");
    }
    final Parameter leafTrait = allTraits.getParameter(leafIndex);
    boolean setBounds = xo.getAttribute(SET_BOUNDS, true);
    if (setBounds) {
        Parameter.DefaultBounds bound = new Parameter.DefaultBounds(Double.MAX_VALUE, -Double.MAX_VALUE, leafTrait.getDimension());
        leafTrait.addBounds(bound);
    }
    return leafTrait;
}
Also used : CompoundParameter(dr.inference.model.CompoundParameter) TreeModel(dr.evomodel.tree.TreeModel) CompoundParameter(dr.inference.model.CompoundParameter) 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