use of dr.evolution.tree.TreeTraitProvider in project beast-mcmc by beast-dev.
the class AncestralTraitParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
String traitName = xo.getAttribute(TRAIT_NAME, STATES);
String name = xo.getAttribute(NAME, traitName);
Tree tree = (Tree) xo.getChild(Tree.class);
TreeTraitProvider treeTraitProvider = (TreeTraitProvider) xo.getChild(TreeTraitProvider.class);
TaxonList taxa = null;
if (xo.hasChildNamed(MRCA)) {
taxa = (TaxonList) xo.getElementFirstChild(MRCA);
}
TreeTrait trait = treeTraitProvider.getTreeTrait(traitName);
if (trait == null) {
throw new XMLParseException("A trait called, " + traitName + ", was not available from the TreeTraitProvider supplied to " + getParserName() + (xo.hasId() ? ", with ID " + xo.getId() : ""));
}
try {
return new AncestralTrait(name, trait, tree, taxa);
} catch (TreeUtils.MissingTaxonException mte) {
throw new XMLParseException("Taxon, " + mte + ", in " + getParserName() + "was not found in the tree.");
}
}
Aggregations