Search in sources :

Example 31 with Units

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

the class ConstantPopulationSizeModelParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    Units.Type units = XMLUnits.Utils.getUnitsAttr(xo);
    Parameter N0Param = null;
    if (xo.hasChildNamed(LOG_POPULATION_SIZE)) {
        N0Param = (Parameter) xo.getElementFirstChild(LOG_POPULATION_SIZE);
    }
    return new ConstantPopulationSizeModel(N0Param, units);
}
Also used : ConstantPopulationSizeModel(dr.evomodel.coalescent.ConstantPopulationSizeModel) Parameter(dr.inference.model.Parameter) Units(dr.evolution.util.Units) XMLUnits(dr.evoxml.util.XMLUnits)

Example 32 with Units

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

the class ExpConstExpDemographicModelParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    Units.Type units = XMLUnits.Utils.getUnitsAttr(xo);
    XMLObject cxo = xo.getChild(POPULATION_SIZE);
    Parameter N0Param = (Parameter) cxo.getChild(Parameter.class);
    cxo = xo.getChild(RELATIVE_PLATEAU_SIZE);
    Parameter N1Param = (Parameter) cxo.getChild(Parameter.class);
    cxo = xo.getChild(RELATIVE_TIME_OF_MODERN_GROWTH);
    Parameter rtParam = (Parameter) cxo.getChild(Parameter.class);
    cxo = xo.getChild(TIME_PLATEAU);
    Parameter tParam = (Parameter) cxo.getChild(Parameter.class);
    cxo = xo.getChild(ANCIENT_GROWTH_RATE);
    Parameter rParam = (Parameter) cxo.getChild(Parameter.class);
    return new ExpConstExpDemographicModel(N0Param, N1Param, rParam, tParam, rtParam, units);
}
Also used : Parameter(dr.inference.model.Parameter) ExpConstExpDemographicModel(dr.evomodel.coalescent.demographicmodel.ExpConstExpDemographicModel) Units(dr.evolution.util.Units) XMLUnits(dr.evoxml.util.XMLUnits)

Example 33 with Units

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

the class ExponentialConstantModelParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    Units.Type units = XMLUnits.Utils.getUnitsAttr(xo);
    XMLObject cxo = xo.getChild(POPULATION_SIZE);
    Parameter N0Param = (Parameter) cxo.getChild(Parameter.class);
    cxo = xo.getChild(GROWTH_RATE);
    Parameter logGrowthParam = (Parameter) cxo.getChild(Parameter.class);
    cxo = xo.getChild(TRANSITION_TIME);
    Parameter timeParam = (Parameter) cxo.getChild(Parameter.class);
    return new ExponentialConstantModel(N0Param, logGrowthParam, timeParam, units);
}
Also used : Parameter(dr.inference.model.Parameter) ExponentialConstantModel(dr.evomodel.coalescent.demographicmodel.ExponentialConstantModel) Units(dr.evolution.util.Units) XMLUnits(dr.evoxml.util.XMLUnits)

Example 34 with Units

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

the class ExponentialGrowthModelParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    Units.Type units = XMLUnits.Utils.getUnitsAttr(xo);
    XMLObject cxo = xo.getChild(POPULATION_SIZE);
    boolean logSpace = cxo.getAttribute(LOG_SPACE, false);
    Parameter N0Param = (Parameter) cxo.getChild(Parameter.class);
    Parameter rParam;
    boolean usingGrowthRate = true;
    if (xo.getChild(GROWTH_RATE) != null) {
        cxo = xo.getChild(GROWTH_RATE);
        rParam = (Parameter) cxo.getChild(Parameter.class);
    } else {
        cxo = xo.getChild(DOUBLING_TIME);
        rParam = (Parameter) cxo.getChild(Parameter.class);
        usingGrowthRate = false;
    }
    if (logSpace) {
        if (!usingGrowthRate) {
            throw new XMLParseException("Doubling time parameterization is not compatible with log population size");
        }
        // ExponentialPopulationSizeModel provides a model with N0 in log space
        return new ExponentialPopulationSizeModel(N0Param, rParam, units);
    } else {
        return new ExponentialGrowthModel(N0Param, rParam, units, usingGrowthRate);
    }
}
Also used : ExponentialGrowthModel(dr.evomodel.coalescent.demographicmodel.ExponentialGrowthModel) Parameter(dr.inference.model.Parameter) Units(dr.evolution.util.Units) XMLUnits(dr.evoxml.util.XMLUnits) ExponentialPopulationSizeModel(dr.evomodel.coalescent.ExponentialPopulationSizeModel)

Example 35 with Units

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

the class PiecewisePopulationSizeModelParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    Units.Type units = XMLUnits.Utils.getUnitsAttr(xo);
    Parameter epochDurations = (Parameter) xo.getElementFirstChild(EPOCH_DURATIONS);
    Parameter populationSize = (Parameter) xo.getElementFirstChild(LOG_POPULATION_SIZE);
    XMLObject cxo = xo.getChild(EPOCHS);
    List<PopulationSizeModel> epochs = cxo.getAllChildren(PopulationSizeModel.class);
    if (epochDurations.getDimension() != epochs.size() - 1) {
        throw new XMLParseException("The dimension of the epoch duration parameter should be one fewer than the number of epochs.");
    }
    return new PiecewisePopulationSizeModel(PIECEWISE_POPULATION_SIZE, populationSize, epochs, epochDurations, units);
}
Also used : PiecewisePopulationSizeModel(dr.evomodel.coalescent.PiecewisePopulationSizeModel) Parameter(dr.inference.model.Parameter) PiecewisePopulationSizeModel(dr.evomodel.coalescent.PiecewisePopulationSizeModel) PopulationSizeModel(dr.evomodel.coalescent.PopulationSizeModel) 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