use of dr.evomodel.branchmodel.BranchSpecificBranchModel in project beast-mcmc by beast-dev.
the class BranchSpecificBranchModelParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
Logger.getLogger("dr.evomodel").info("\nUsing clade-specific branch model.");
TreeModel tree = (TreeModel) xo.getChild(TreeModel.class);
SubstitutionModel substitutionModel = (SubstitutionModel) xo.getChild(SubstitutionModel.class);
BranchSpecificBranchModel branchModel = new BranchSpecificBranchModel(tree, 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(CLADE)) {
double stemWeight = xoc.getAttribute(STEM_WEIGHT, 0.0);
substitutionModel = (SubstitutionModel) xoc.getChild(SubstitutionModel.class);
TaxonList taxonList = (TaxonList) xoc.getChild(TaxonList.class);
if (taxonList.getTaxonCount() == 1) {
throw new XMLParseException("A clade must be defined by at least two taxa");
}
try {
branchModel.addClade(taxonList, substitutionModel, stemWeight);
} catch (TreeUtils.MissingTaxonException mte) {
throw new XMLParseException("Taxon, " + mte + ", in " + getParserName() + " was not found in the tree.");
}
} else if (xoc.getName().equals(EXTERNAL_BRANCHES)) {
substitutionModel = (SubstitutionModel) xoc.getChild(SubstitutionModel.class);
TaxonList taxonList = (TaxonList) xoc.getChild(TaxonList.class);
try {
branchModel.addExternalBranches(taxonList, substitutionModel);
} catch (TreeUtils.MissingTaxonException mte) {
throw new XMLParseException("Taxon, " + mte + ", in " + getParserName() + " was not found in the tree.");
}
} else if (xoc.getName().equals(BACKBONE)) {
substitutionModel = (SubstitutionModel) xoc.getChild(SubstitutionModel.class);
TaxonList taxonList = (TaxonList) xoc.getChild(TaxonList.class);
try {
branchModel.addBackbone(taxonList, substitutionModel);
} catch (TreeUtils.MissingTaxonException mte) {
throw new XMLParseException("Taxon, " + mte + ", in " + getParserName() + " was not found in the tree.");
}
}
}
}
return branchModel;
}
Aggregations