Search in sources :

Example 6 with Variable

use of dr.inference.model.Variable in project beast-mcmc by beast-dev.

the class GTRParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    XMLObject cxo = xo.getChild(FREQUENCIES);
    FrequencyModel freqModel = (FrequencyModel) cxo.getChild(FrequencyModel.class);
    Variable rateACValue = null;
    if (xo.hasChildNamed(A_TO_C)) {
        rateACValue = (Variable) xo.getElementFirstChild(A_TO_C);
    }
    Variable rateAGValue = null;
    if (xo.hasChildNamed(A_TO_G)) {
        rateAGValue = (Variable) xo.getElementFirstChild(A_TO_G);
    }
    Variable rateATValue = null;
    if (xo.hasChildNamed(A_TO_T)) {
        rateATValue = (Variable) xo.getElementFirstChild(A_TO_T);
    }
    Variable rateCGValue = null;
    if (xo.hasChildNamed(C_TO_G)) {
        rateCGValue = (Variable) xo.getElementFirstChild(C_TO_G);
    }
    Variable rateCTValue = null;
    if (xo.hasChildNamed(C_TO_T)) {
        rateCTValue = (Variable) xo.getElementFirstChild(C_TO_T);
    }
    Variable rateGTValue = null;
    if (xo.hasChildNamed(G_TO_T)) {
        rateGTValue = (Variable) xo.getElementFirstChild(G_TO_T);
    }
    int countNull = 0;
    if (rateACValue == null)
        countNull++;
    if (rateAGValue == null)
        countNull++;
    if (rateATValue == null)
        countNull++;
    if (rateCGValue == null)
        countNull++;
    if (rateCTValue == null)
        countNull++;
    if (rateGTValue == null)
        countNull++;
    if (countNull != 1)
        throw new XMLParseException("Only five parameters may be specified in GTR, leave exactly one out, the others will be specifed relative to the one left out.");
    return new GTR(rateACValue, rateAGValue, rateATValue, rateCGValue, rateCTValue, rateGTValue, freqModel);
}
Also used : FrequencyModel(dr.oldevomodel.substmodel.FrequencyModel) Variable(dr.inference.model.Variable) GTR(dr.oldevomodel.substmodel.GTR)

Example 7 with Variable

use of dr.inference.model.Variable in project beast-mcmc by beast-dev.

the class UniformIntegerOperatorParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    double weight = xo.getDoubleAttribute(MCMCOperator.WEIGHT);
    Variable parameter = (Variable) xo.getChild(Variable.class);
    int count = 1;
    if (xo.hasAttribute("count"))
        count = xo.getIntegerAttribute("count");
    if (parameter instanceof Parameter) {
        int lower = (int) (double) ((Parameter) parameter).getBounds().getLowerLimit(0);
        if (xo.hasAttribute("lower"))
            lower = xo.getIntegerAttribute("lower");
        int upper = (int) (double) ((Parameter) parameter).getBounds().getUpperLimit(0);
        if (xo.hasAttribute("upper"))
            upper = xo.getIntegerAttribute("upper");
        if (upper == lower || lower == (int) Double.NEGATIVE_INFINITY || upper == (int) Double.POSITIVE_INFINITY) {
            throw new XMLParseException(this.getParserName() + " boundaries not found in parameter " + parameter.getId() + " Use operator lower and upper !");
        }
        return new UniformIntegerOperator((Parameter) parameter, lower, upper, weight, count);
    } else {
        // Variable<Integer>, Bounds.Staircase
        return new UniformIntegerOperator(parameter, weight, count);
    }
}
Also used : Variable(dr.inference.model.Variable) Parameter(dr.inference.model.Parameter) UniformIntegerOperator(dr.inference.operators.UniformIntegerOperator)

Example 8 with Variable

use of dr.inference.model.Variable in project beast-mcmc by beast-dev.

the class RandomWalkIntegerOperatorParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    double weight = xo.getDoubleAttribute(MCMCOperator.WEIGHT);
    double d = xo.getDoubleAttribute(WINDOW_SIZE);
    if (d != Math.floor(d)) {
        throw new XMLParseException("The window size of a " + RANDOM_WALK_INTEGER_OPERATOR + " should be an integer");
    }
    int windowSize = (int) d;
    Variable parameter = (Variable) xo.getChild(Variable.class);
    return new RandomWalkIntegerOperator(parameter, windowSize, weight);
}
Also used : Variable(dr.inference.model.Variable) RandomWalkIntegerOperator(dr.inference.operators.RandomWalkIntegerOperator)

Example 9 with Variable

use of dr.inference.model.Variable in project beast-mcmc by beast-dev.

the class HKYParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    Variable kappaParam = (Variable) xo.getElementFirstChild(KAPPA);
    FrequencyModel freqModel = (FrequencyModel) xo.getElementFirstChild(FrequencyModelParser.FREQUENCIES);
    Logger.getLogger("dr.evomodel").info("Creating HKY substitution model. Initial kappa = " + kappaParam.getValue(0));
    return new HKY(kappaParam, freqModel);
}
Also used : FrequencyModel(dr.oldevomodel.substmodel.FrequencyModel) Variable(dr.inference.model.Variable) HKY(dr.oldevomodel.substmodel.HKY)

Aggregations

Variable (dr.inference.model.Variable)9 FrequencyModel (dr.oldevomodel.substmodel.FrequencyModel)4 Parameter (dr.inference.model.Parameter)3 AbstractDistributionLikelihood (dr.inference.distribution.AbstractDistributionLikelihood)1 CachedDistributionLikelihood (dr.inference.distribution.CachedDistributionLikelihood)1 DistributionLikelihood (dr.inference.distribution.DistributionLikelihood)1 NormalDistributionModel (dr.inference.distribution.NormalDistributionModel)1 MCLogger (dr.inference.loggers.MCLogger)1 MCMC (dr.inference.mcmc.MCMC)1 MCMCOperator (dr.inference.operators.MCMCOperator)1 RandomWalkIntegerOperator (dr.inference.operators.RandomWalkIntegerOperator)1 ScaleOperator (dr.inference.operators.ScaleOperator)1 UniformIntegerOperator (dr.inference.operators.UniformIntegerOperator)1 GammaSiteBMA (dr.oldevomodel.sitemodel.GammaSiteBMA)1 GTR (dr.oldevomodel.substmodel.GTR)1 HKY (dr.oldevomodel.substmodel.HKY)1 NtdBMA (dr.oldevomodel.substmodel.NtdBMA)1 SubstitutionModel (dr.oldevomodel.substmodel.SubstitutionModel)1 TN93 (dr.oldevomodel.substmodel.TN93)1 Attribute (dr.util.Attribute)1