| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
package dr.evomodelxml.tree; |
| 27 |
|
| 28 |
import dr.evomodel.tree.TreeModel; |
| 29 |
import dr.evomodel.tree.TreeShapeStatistic; |
| 30 |
import dr.inference.model.Statistic; |
| 31 |
import dr.xml.*; |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
public class TreeShapeStatisticParser extends AbstractXMLObjectParser { |
| 36 |
|
| 37 |
public static final String TREE_SHAPE_STATISTIC = "treeShapeStatistics"; |
| 38 |
public static final String TARGET = "target"; |
| 39 |
|
| 40 |
public String getParserName() { |
| 41 |
return TREE_SHAPE_STATISTIC; |
| 42 |
} |
| 43 |
|
| 44 |
public Object parseXMLObject(XMLObject xo) throws XMLParseException { |
| 45 |
|
| 46 |
String name = xo.getAttribute(Statistic.NAME, xo.getId()); |
| 47 |
TreeModel target = (TreeModel) xo.getElementFirstChild(TARGET); |
| 48 |
|
| 49 |
return new TreeShapeStatistic(name, target); |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
public String getParserDescription() { |
| 57 |
return "A statistic that reports a handful of tree shape statistics on the given target tree."; |
| 58 |
} |
| 59 |
|
| 60 |
public Class getReturnType() { |
| 61 |
return TreeShapeStatistic.class; |
| 62 |
} |
| 63 |
|
| 64 |
public XMLSyntaxRule[] getSyntaxRules() { |
| 65 |
return rules; |
| 66 |
} |
| 67 |
|
| 68 |
private XMLSyntaxRule[] rules = new XMLSyntaxRule[]{ |
| 69 |
new StringAttributeRule(Statistic.NAME, "A name for this statistic primarily for the purposes of logging", true), |
| 70 |
new ElementRule(TARGET, |
| 71 |
new XMLSyntaxRule[]{new ElementRule(TreeModel.class)}) |
| 72 |
}; |
| 73 |
|
| 74 |
} |