use of dr.oldevomodel.sitemodel.GammaSiteBMA in project beast-mcmc by beast-dev.
the class testGammaSiteBMA method testGammaSiteBMA.
public void testGammaSiteBMA() {
for (Instance test : all) {
SubstitutionModel substModel = test.getSubstModel();
Parameter mu = new Parameter.Default(test.getMu());
Parameter logitInvar = new Parameter.Default(test.getLogitInvar());
Parameter logShape = new Parameter.Default(test.getLogShape());
int catCount = test.getCategoryCount();
Variable<Integer> modelChoose = test.getModelChoose();
GammaSiteBMA gammaSiteBMA = new GammaSiteBMA(substModel, mu, logitInvar, logShape, catCount, modelChoose);
double[] catRates = gammaSiteBMA.getCategoryRates();
double[] expectedCatRates = test.getCategoryRates();
for (int i = 0; i < catRates.length; i++) {
assertEquals(catRates[i], expectedCatRates[i], 8e-10);
}
double[] catProps = gammaSiteBMA.getCategoryProportions();
double[] expectedCatProps = test.getCategoryProportions();
for (int i = 0; i < catProps.length; i++) {
assertEquals(catProps[i], expectedCatProps[i], 1e-10);
}
}
}
use of dr.oldevomodel.sitemodel.GammaSiteBMA in project beast-mcmc by beast-dev.
the class GammaSiteBMAParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
SubstitutionModel substitutionModel = (SubstitutionModel) xo.getElementFirstChild(SUBSTITUTION_MODEL);
Parameter muParam = (Parameter) xo.getElementFirstChild(MUTATION_RATE);
Parameter logitInvar = (Parameter) xo.getElementFirstChild(LOGIT_PROPORTION_INVARIANT);
final XMLObject cxo = xo.getChild(LOG_GAMMA_SHAPE);
Parameter logShape = (Parameter) cxo.getChild(Parameter.class);
int catCount = cxo.getIntegerAttribute(GAMMA_CATEGORIES);
Variable<Integer> modelChoose = (Variable<Integer>) xo.getElementFirstChild(MODEL_CHOOSE);
return new GammaSiteBMA(substitutionModel, muParam, logitInvar, logShape, catCount, modelChoose);
}
Aggregations