Search in sources :

Example 46 with Units

use of dr.evolution.util.Units in project beast-mcmc by beast-dev.

the class PiecewisePopulationModelParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    Units.Type units = XMLUnits.Utils.getUnitsAttr(xo);
    XMLObject obj = xo.getChild(EPOCH_WIDTHS);
    double[] epochWidths = obj.getDoubleArrayAttribute(WIDTHS);
    if (xo.hasChildNamed(EPOCH_SIZES)) {
        Parameter epochSizes = (Parameter) xo.getElementFirstChild(EPOCH_SIZES);
        boolean isLinear = false;
        if (xo.hasAttribute(LINEAR)) {
            isLinear = xo.getBooleanAttribute(LINEAR);
        }
        return new PiecewisePopulationModel(PIECEWISE_POPULATION, epochSizes, epochWidths, isLinear, units);
    } else {
        Parameter populationSize = (Parameter) xo.getElementFirstChild(POPULATION_SIZE);
        Parameter growthRates = (Parameter) xo.getElementFirstChild(GROWTH_RATES);
        return new PiecewisePopulationModel(PIECEWISE_POPULATION, populationSize, growthRates, epochWidths, units);
    }
}
Also used : Parameter(dr.inference.model.Parameter) PiecewisePopulationModel(dr.evomodel.coalescent.demographicmodel.PiecewisePopulationModel) Units(dr.evolution.util.Units) XMLUnits(dr.evoxml.util.XMLUnits)

Example 47 with Units

use of dr.evolution.util.Units in project beast-mcmc by beast-dev.

the class TaxonRichnessBirthDeathModelParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    Units.Type units = XMLUnits.Utils.getUnitsAttr(xo);
    XMLObject cxo = xo.getChild(BIRTH_RATE);
    Parameter brParameter = (Parameter) cxo.getChild(Parameter.class);
    cxo = xo.getChild(BIRTH_RATE_INDICATORS);
    Parameter indicatorsParameter = (Parameter) cxo.getChild(Parameter.class);
    Parameter meanRate = (Parameter) xo.getElementFirstChild(MEAN_RATE);
    boolean ratesAsMultipliers = xo.getBooleanAttribute(RATES_AS_MULTIPLIERS);
    int dp = xo.getAttribute("dp", 4);
    return new TaxonRichnessBirthDeathModel(brParameter, indicatorsParameter, meanRate, ratesAsMultipliers, units, dp);
}
Also used : TaxonRichnessBirthDeathModel(dr.evomodel.speciation.TaxonRichnessBirthDeathModel) Parameter(dr.inference.model.Parameter) Units(dr.evolution.util.Units) XMLUnits(dr.evoxml.util.XMLUnits)

Example 48 with Units

use of dr.evolution.util.Units in project beast-mcmc by beast-dev.

the class BirthDeathModelParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    final Units.Type units = XMLUnits.Utils.getUnitsAttr(xo);
    final String s = xo.getAttribute(TREE_TYPE, BirthDeathGernhard08Model.TreeType.UNSCALED.toString());
    final BirthDeathGernhard08Model.TreeType treeType = BirthDeathGernhard08Model.TreeType.valueOf(s);
    final boolean conditonalOnRoot = xo.getAttribute(CONDITIONAL_ON_ROOT, false);
    final Parameter birthParameter = (Parameter) xo.getElementFirstChild(BIRTHDIFF_RATE);
    final Parameter deathParameter = (Parameter) xo.getElementFirstChild(RELATIVE_DEATH_RATE);
    final Parameter sampleProbability = xo.hasChildNamed(SAMPLE_PROB) ? (Parameter) xo.getElementFirstChild(SAMPLE_PROB) : null;
    Logger.getLogger("dr.evomodel").info(xo.hasChildNamed(SAMPLE_PROB) ? getCitationRHO() : getCitation());
    final String modelName = xo.getId();
    return new BirthDeathGernhard08Model(modelName, birthParameter, deathParameter, sampleProbability, treeType, units, conditonalOnRoot);
}
Also used : BirthDeathGernhard08Model(dr.evomodel.speciation.BirthDeathGernhard08Model) Parameter(dr.inference.model.Parameter) Units(dr.evolution.util.Units) XMLUnits(dr.evoxml.util.XMLUnits)

Example 49 with Units

use of dr.evolution.util.Units in project beast-mcmc by beast-dev.

the class BirthDeathSerialSkylineModelParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    final String modelName = xo.getId();
    final Units.Type units = XMLUnits.Utils.getUnitsAttr(xo);
    final Parameter times = (Parameter) xo.getElementFirstChild(TIMES);
    final Parameter lambda = (Parameter) xo.getElementFirstChild(LAMBDA);
    boolean relativeDeath = xo.hasChildNamed(RELATIVE_MU);
    Parameter mu;
    if (relativeDeath) {
        mu = (Parameter) xo.getElementFirstChild(RELATIVE_MU);
    } else {
        mu = (Parameter) xo.getElementFirstChild(MU);
    }
    final Parameter psi = (Parameter) xo.getElementFirstChild(PSI);
    final Parameter p = (Parameter) xo.getElementFirstChild(SAMPLE_PROBABILITY);
    final boolean timesStartFromOrigin = xo.getAttribute(TIMES_START_FROM_ORIGIN, false);
    Parameter origin = null;
    if (xo.hasChildNamed(ORIGIN)) {
        origin = (Parameter) xo.getElementFirstChild(ORIGIN);
    }
    final Parameter r = xo.hasChildNamed(SAMPLE_BECOMES_NON_INFECTIOUS) ? (Parameter) xo.getElementFirstChild(SAMPLE_BECOMES_NON_INFECTIOUS) : new Parameter.Default(0.0);
    // r.setParameterValueQuietly(0, 1 - r.getParameterValue(0)); // donot use it, otherwise log is changed improperly
    Logger.getLogger("dr.evomodel").info(xo.hasChildNamed(SAMPLE_BECOMES_NON_INFECTIOUS) ? getCitationRT() : getCitationPsiOrg());
    return new BirthDeathSerialSkylineModel(modelName, times, lambda, mu, psi, p, origin, relativeDeath, false, timesStartFromOrigin, units);
}
Also used : BirthDeathSerialSkylineModel(dr.evomodel.speciation.BirthDeathSerialSkylineModel) Parameter(dr.inference.model.Parameter) Units(dr.evolution.util.Units) XMLUnits(dr.evoxml.util.XMLUnits)

Example 50 with Units

use of dr.evolution.util.Units in project beast-mcmc by beast-dev.

the class AlloppNetworkPriorModelParser method parseXMLObject.

@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    final Units.Type units = XMLUnits.Utils.getUnitsAttr(xo);
    final XMLObject erXo = xo.getChild(EVENTRATE);
    final Parameter eventrate = (Parameter) erXo.getChild(Parameter.class);
    final XMLObject psfXo = xo.getChild(POPULATION_SCALING_FACTOR);
    final Parameter popscalingfactor = (Parameter) psfXo.getChild(Parameter.class);
    final XMLObject tpdXo = xo.getChild(TIP_POPULATION_DISTRIBUTION);
    ParametricDistributionModel tippopmodel = (ParametricDistributionModel) tpdXo.getChild(ParametricDistributionModel.class);
    final XMLObject rpdXo = xo.getChild(ROOT_POPULATION_DISTRIBUTION);
    ParametricDistributionModel rootpopmodel = (ParametricDistributionModel) rpdXo.getChild(ParametricDistributionModel.class);
    final XMLObject hpdXo = xo.getChild(HYBRID_POPULATION_DISTRIBUTION);
    ParametricDistributionModel hybpopmodel = (ParametricDistributionModel) hpdXo.getChild(ParametricDistributionModel.class);
    return new AlloppNetworkPriorModel(eventrate, popscalingfactor, tippopmodel, rootpopmodel, hybpopmodel, units);
}
Also used : AlloppNetworkPriorModel(dr.evomodel.alloppnet.speciation.AlloppNetworkPriorModel) ParametricDistributionModel(dr.inference.distribution.ParametricDistributionModel) XMLObject(dr.xml.XMLObject) Parameter(dr.inference.model.Parameter) Units(dr.evolution.util.Units) XMLUnits(dr.evoxml.util.XMLUnits)

Aggregations

Units (dr.evolution.util.Units)70 XMLUnits (dr.evoxml.util.XMLUnits)65 Parameter (dr.inference.model.Parameter)62 TreeModel (dr.evomodel.tree.TreeModel)4 Date (dr.evolution.util.Date)3 MultiEpochExponential (dr.evolution.coalescent.MultiEpochExponential)2 ConstantPopulationSizeModel (dr.evomodel.coalescent.ConstantPopulationSizeModel)2 ExponentialPopulationSizeModel (dr.evomodel.coalescent.ExponentialPopulationSizeModel)2 BirthDeathGernhard08Model (dr.evomodel.speciation.BirthDeathGernhard08Model)2 BirthDeathSerialSamplingModel (dr.evomodel.speciation.BirthDeathSerialSamplingModel)2 TreePriorParameterizationType (dr.app.beauti.types.TreePriorParameterizationType)1 TreePriorType (dr.app.beauti.types.TreePriorType)1 ExponentialExponential (dr.evolution.coalescent.ExponentialExponential)1 ExponentialGrowth (dr.evolution.coalescent.ExponentialGrowth)1 Importer (dr.evolution.io.Importer)1 NewickImporter (dr.evolution.io.NewickImporter)1 SimpleNode (dr.evolution.tree.SimpleNode)1 SimpleTree (dr.evolution.tree.SimpleTree)1 Tree (dr.evolution.tree.Tree)1 Taxon (dr.evolution.util.Taxon)1