use of dr.evomodel.branchratemodel.MixtureModelBranchRates in project beast-mcmc by beast-dev.
the class MixtureModelBranchRatesParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
ArrayList<ParametricDistributionModel> modelsList = new ArrayList<ParametricDistributionModel>();
final boolean normalize = xo.getAttribute(NORMALIZE, false);
final double normalizeBranchRateTo = xo.getAttribute(NORMALIZE_BRANCH_RATE_TO, Double.NaN);
final boolean useQuantilesForRates = xo.getAttribute(USE_QUANTILE, true);
TreeModel tree = (TreeModel) xo.getChild(TreeModel.class);
for (int i = 0; i < xo.getChildCount(); i++) {
Object child = xo.getChild(i);
if (child instanceof XMLObject) {
if (((XMLObject) child).getName().equals(DISTRIBUTION)) {
XMLObject childXML = (XMLObject) child;
modelsList.add((ParametricDistributionModel) childXML.getChild(0));
}
}
}
//Parameter rateCategoryParameter = (Parameter) xo.getElementFirstChild(RATE_CATEGORIES);
ParametricDistributionModel[] models = modelsList.toArray(new ParametricDistributionModel[modelsList.size()]);
Parameter rateCategoryQuantilesParameter = (Parameter) xo.getElementFirstChild(RATE_CATEGORY_QUANTILES);
Parameter distributionIndexParameter = (Parameter) xo.getElementFirstChild(DISTRIBUTION_INDEX);
Logger.getLogger("dr.evomodel").info("Using random discretized relaxed clock model with a mixture distribution.");
for (int i = 0; i < models.length; i++) {
Logger.getLogger("dr.evomodel").info(" parametric model " + (i + 1) + " = " + models[i].getModelName());
}
//Logger.getLogger("dr.evomodel").info(" rate categories = " + rateCategoryParameter.getDimension());
Logger.getLogger("dr.evomodel").info(" rate categories = " + rateCategoryQuantilesParameter.getDimension());
if (normalize) {
Logger.getLogger("dr.evomodel").info(" mean rate is normalized to " + normalizeBranchRateTo);
}
if (xo.hasAttribute(SINGLE_ROOT_RATE)) {
//singleRootRate = xo.getBooleanAttribute(SINGLE_ROOT_RATE);
Logger.getLogger("dr.evomodel").warning(" WARNING: single root rate is not implemented!");
}
if (!useQuantilesForRates) {
Logger.getLogger("dr.evomodel").info("Rates are set to not being drawn using quantiles. Thus they are not drawn from any particular distribution.");
}
return new MixtureModelBranchRates(tree, rateCategoryQuantilesParameter, models, distributionIndexParameter, useQuantilesForRates, normalize, normalizeBranchRateTo);
}
Aggregations