Search in sources :

Example 1 with TestStatistic

use of dr.inference.model.TestStatistic in project beast-mcmc by beast-dev.

the class TestStatisticParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    String name = xo.getAttribute(Statistic.NAME, xo.hasId() ? xo.getId() : "");
    Attribute attr = (Attribute) xo.getChild(Attribute.class);
    double testValue1;
    TestStatistic statistic;
    if (xo.hasChildNamed(SEQUALS)) {
        Attribute attr2 = (Attribute) xo.getElementFirstChild(SEQUALS);
        statistic = new TestStatistic(name, attr, attr2, TestStatistic.EQUALS);
    } else if (xo.hasChildNamed(SGREATER_THAN)) {
        Attribute attr2 = (Attribute) xo.getElementFirstChild(SGREATER_THAN);
        statistic = new TestStatistic(name, attr, attr2, TestStatistic.GREATER_THAN);
    } else if (xo.hasChildNamed(SLESS_THAN)) {
        Attribute attr2 = (Attribute) xo.getElementFirstChild(SLESS_THAN);
        statistic = new TestStatistic(name, attr, attr2, TestStatistic.LESS_THAN);
    } else if (xo.hasAttribute(SEQUALS)) {
        testValue1 = xo.getDoubleAttribute(SEQUALS);
        statistic = new TestStatistic(name, attr, testValue1, TestStatistic.EQUALS);
    } else if (xo.hasAttribute(SGREATER_THAN)) {
        testValue1 = xo.getDoubleAttribute(SGREATER_THAN);
        statistic = new TestStatistic(name, attr, testValue1, TestStatistic.GREATER_THAN);
    } else if (xo.hasAttribute(SLESS_THAN)) {
        testValue1 = xo.getDoubleAttribute(SLESS_THAN);
        statistic = new TestStatistic(name, attr, testValue1, TestStatistic.LESS_THAN);
    } else if (xo.hasAttribute(SINSIDE)) {
        double[] values = xo.getDoubleArrayAttribute(SINSIDE);
        if (values.length != 2)
            throw new XMLParseException("inside attribute of test element requires two values");
        statistic = new TestStatistic(name, attr, values[0], values[1], TestStatistic.INSIDE);
    } else if (xo.hasAttribute(SOUTSIDE)) {
        double[] values = xo.getDoubleArrayAttribute(SOUTSIDE);
        if (values.length != 2)
            throw new XMLParseException("outside attribute of test element requires two values");
        statistic = new TestStatistic(name, attr, values[0], values[1], TestStatistic.OUTSIDE);
    } else
        throw new XMLParseException();
    return statistic;
}
Also used : TestStatistic(dr.inference.model.TestStatistic) Attribute(dr.util.Attribute)

Aggregations

TestStatistic (dr.inference.model.TestStatistic)1 Attribute (dr.util.Attribute)1