use of dr.evomodel.branchmodel.BranchAssignmentModel in project beast-mcmc by beast-dev.
the class BranchAssignmentModelParser method parseXMLObject.
@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
Logger.getLogger("dr.evomodel").info("\nUsing branch assignment branch model.");
TreeModel treeModel = (TreeModel) xo.getChild(TreeModel.class);
String annotation = xo.getStringAttribute(ANNOTATION);
LinkedHashMap<Integer, SubstitutionModel> modelIndexMap = new LinkedHashMap<Integer, SubstitutionModel>();
for (int i = 0; i < xo.getChildCount(); i++) {
if (xo.getChild(i) instanceof XMLObject) {
XMLObject xoc = (XMLObject) xo.getChild(i);
if (xoc.getName().equals(ASSIGNMENT)) {
Integer index = null;
if (xoc.hasAttribute(ANNOTATION_VALUE)) {
index = xoc.getIntegerAttribute(ANNOTATION_VALUE);
}
SubstitutionModel model = (SubstitutionModel) xoc.getChild(SubstitutionModel.class);
modelIndexMap.put(index, model);
}
}
}
SubstitutionModel baseModel = (SubstitutionModel) xo.getElementFirstChild(BASE_MODEL);
return new BranchAssignmentModel(treeModel, annotation, modelIndexMap, baseModel);
}
Aggregations