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);
}
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);
}
}
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);
}
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);
}
Aggregations