Search in sources :

Example 1 with AncestralTrait

use of dr.evomodel.tree.AncestralTrait 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.");
    }
}
Also used : TreeTraitProvider(dr.evolution.tree.TreeTraitProvider) TaxonList(dr.evolution.util.TaxonList) Tree(dr.evolution.tree.Tree) AncestralTrait(dr.evomodel.tree.AncestralTrait) TreeTrait(dr.evolution.tree.TreeTrait) TreeUtils(dr.evolution.tree.TreeUtils)

Aggregations

Tree (dr.evolution.tree.Tree)1 TreeTrait (dr.evolution.tree.TreeTrait)1 TreeTraitProvider (dr.evolution.tree.TreeTraitProvider)1 TreeUtils (dr.evolution.tree.TreeUtils)1 TaxonList (dr.evolution.util.TaxonList)1 AncestralTrait (dr.evomodel.tree.AncestralTrait)1