Search in sources :

Example 1 with TMRCAStatistic

use of dr.evomodel.tree.TMRCAStatistic in project beast-mcmc by beast-dev.

the class TMRCAStatisticParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    String name = xo.getAttribute(Statistic.NAME, xo.getId());
    Tree tree = (Tree) xo.getChild(Tree.class);
    TaxonList taxa = null;
    if (xo.hasChildNamed(MRCA)) {
        taxa = (TaxonList) xo.getElementFirstChild(MRCA);
    }
    boolean isAbsolute = xo.getAttribute(ABSOLUTE, false);
    boolean includeStem = false;
    if (xo.hasAttribute(PARENT) && xo.hasAttribute(STEM)) {
        throw new XMLParseException("Please use either " + PARENT + " or " + STEM + "!");
    } else if (xo.hasAttribute(PARENT)) {
        includeStem = xo.getBooleanAttribute(PARENT);
    } else if (xo.hasAttribute(STEM)) {
        includeStem = xo.getBooleanAttribute(STEM);
    }
    try {
        return new TMRCAStatistic(name, tree, taxa, isAbsolute, includeStem);
    } catch (TreeUtils.MissingTaxonException mte) {
        throw new XMLParseException("Taxon, " + mte + ", in " + getParserName() + "was not found in the tree.");
    }
}
Also used : TMRCAStatistic(dr.evomodel.tree.TMRCAStatistic) TaxonList(dr.evolution.util.TaxonList) Tree(dr.evolution.tree.Tree) TreeUtils(dr.evolution.tree.TreeUtils)

Aggregations

Tree (dr.evolution.tree.Tree)1 TreeUtils (dr.evolution.tree.TreeUtils)1 TaxonList (dr.evolution.util.TaxonList)1 TMRCAStatistic (dr.evomodel.tree.TMRCAStatistic)1