| 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.operators; |
| 27 |
|
| 28 |
import dr.evomodel.operators.FNPR; |
| 29 |
import dr.evomodel.tree.TreeModel; |
| 30 |
import dr.inference.operators.MCMCOperator; |
| 31 |
import dr.xml.*; |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
public class FNPRParser extends AbstractXMLObjectParser { |
| 36 |
|
| 37 |
public static final String FNPR = "FixedNodeheightSubtreePruneRegraft"; |
| 38 |
|
| 39 |
public String getParserName() { |
| 40 |
return FNPR; |
| 41 |
} |
| 42 |
|
| 43 |
public Object parseXMLObject(XMLObject xo) throws XMLParseException { |
| 44 |
|
| 45 |
TreeModel treeModel = (TreeModel) xo.getChild(TreeModel.class); |
| 46 |
double weight = xo.getDoubleAttribute(MCMCOperator.WEIGHT); |
| 47 |
|
| 48 |
return new FNPR(treeModel, weight); |
| 49 |
} |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
public String getParserDescription() { |
| 56 |
return "This element represents a FNPR operator. " |
| 57 |
+ "This operator swaps a random subtree with its uncle."; |
| 58 |
} |
| 59 |
|
| 60 |
public Class getReturnType() { |
| 61 |
return FNPR.class; |
| 62 |
} |
| 63 |
|
| 64 |
public XMLSyntaxRule[] getSyntaxRules() { |
| 65 |
return rules; |
| 66 |
} |
| 67 |
|
| 68 |
private final XMLSyntaxRule[] rules = { |
| 69 |
AttributeRule.newDoubleRule(MCMCOperator.WEIGHT), |
| 70 |
new ElementRule(TreeModel.class) |
| 71 |
}; |
| 72 |
} |