Search in sources :

Example 1 with DnDsLogger

use of dr.evomodel.treelikelihood.utilities.DnDsLogger in project beast-mcmc by beast-dev.

the class DnDsLoggerParser method parseXMLObject.

@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    String[] names = DnDsLogger.traitNames;
    TreeTrait[] foundTraits = new TreeTrait[names.length];
    for (int i = 0; i < xo.getChildCount(); i++) {
        Object obj = xo.getChild(i);
        if (obj instanceof CodonPartitionedRobustCounting) {
            CodonPartitionedRobustCounting thisCount = (CodonPartitionedRobustCounting) obj;
            for (int j = 0; j < names.length; j++) {
                TreeTrait trait = thisCount.getTreeTrait(names[j]);
                if (trait != null) {
                    foundTraits[j] = trait;
                }
            }
        }
    }
    for (int i = 0; i < foundTraits.length; i++) {
        if (foundTraits[i] == null) {
            throw new XMLParseException("Unable to find trait '" + names[i] + "'");
        }
    }
    Tree tree = (Tree) xo.getChild(Tree.class);
    // Use AttributeRules for options here
    boolean useSmoothing = xo.getAttribute(USE_SMOOTHING, true);
    boolean useDnMinusDs = xo.getAttribute(USE_DNMINUSDS, false);
    boolean conditionalCounts = xo.getAttribute(COUNTS, false);
    boolean synonymous = xo.getAttribute(SYNONYMOUS, false);
    return new DnDsLogger(xo.getId(), tree, foundTraits, useSmoothing, useDnMinusDs, conditionalCounts, synonymous);
}
Also used : CodonPartitionedRobustCounting(dr.evomodel.substmodel.CodonPartitionedRobustCounting) Tree(dr.evolution.tree.Tree) DnDsLogger(dr.evomodel.treelikelihood.utilities.DnDsLogger) TreeTrait(dr.evolution.tree.TreeTrait)

Aggregations

Tree (dr.evolution.tree.Tree)1 TreeTrait (dr.evolution.tree.TreeTrait)1 CodonPartitionedRobustCounting (dr.evomodel.substmodel.CodonPartitionedRobustCounting)1 DnDsLogger (dr.evomodel.treelikelihood.utilities.DnDsLogger)1