use of dr.evomodel.branchratemodel.ContinuousBranchValueProvider in project beast-mcmc by beast-dev.
the class BranchSpecificFixedEffectsParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
// Parameter allocationParameter = (Parameter) xo.getElementFirstChild(ALLOCATION);
TreeModel treeModel = (TreeModel) xo.getChild(TreeModel.class);
Parameter coefficients = (Parameter) xo.getChild(Parameter.class);
boolean includeIntercept = xo.getAttribute(INCLUDE_INTERCEPT, true);
List<CountableBranchCategoryProvider> categories = new ArrayList<CountableBranchCategoryProvider>();
for (XMLObject xoc : xo.getAllChildren(CATEGORY)) {
CountableBranchCategoryProvider.CladeBranchCategoryModel cladeModel = new CountableBranchCategoryProvider.CladeBranchCategoryModel(treeModel, new Parameter.Default(treeModel.getNodeCount() - 1));
parseCladeCategories(xoc, cladeModel);
categories.add(cladeModel);
}
List<ContinuousBranchValueProvider> values = new ArrayList<ContinuousBranchValueProvider>();
boolean timeDependentEffect = xo.getAttribute(TIME_DEPENDENT_EFFECT, false);
if (timeDependentEffect) {
values.add(new ContinuousBranchValueProvider.MidPoint());
}
List<BranchRates> branchRates = new ArrayList<BranchRates>();
for (int i = 0; i < xo.getChildCount(); ++i) {
Object obj = xo.getChild(i);
if (obj instanceof BranchRates) {
branchRates.add((BranchRates) obj);
}
}
Transform transform = (Transform) xo.getChild(Transform.class);
BranchSpecificFixedEffects.Default fixedEffects = new BranchSpecificFixedEffects.Default(xo.getId(), categories, values, branchRates, coefficients, includeIntercept);
double[][] designMatrix = fixedEffects.getDesignMatrix(treeModel);
Logger.getLogger("dr.evomodel").info("Using a fixed effects model with initial design matrix:\n" + annotateDesignMatrix(designMatrix, treeModel));
if (transform != null) {
return new BranchSpecificFixedEffects.Transformed(fixedEffects, transform);
} else {
return fixedEffects;
}
}
Aggregations