Search in sources :

Example 1 with BranchAssignmentModel

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);
}
Also used : TreeModel(dr.evomodel.tree.TreeModel) BranchAssignmentModel(dr.evomodel.branchmodel.BranchAssignmentModel) XMLObject(dr.xml.XMLObject) SubstitutionModel(dr.evomodel.substmodel.SubstitutionModel) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

BranchAssignmentModel (dr.evomodel.branchmodel.BranchAssignmentModel)1 SubstitutionModel (dr.evomodel.substmodel.SubstitutionModel)1 TreeModel (dr.evomodel.tree.TreeModel)1 XMLObject (dr.xml.XMLObject)1 LinkedHashMap (java.util.LinkedHashMap)1