| 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.TreeNodeSlide; |
| 29 |
import dr.evomodel.speciation.SpeciesBindings; |
| 30 |
import dr.evomodel.speciation.SpeciesTreeModel; |
| 31 |
import dr.inference.operators.MCMCOperator; |
| 32 |
import dr.xml.*; |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
public class TreeNodeSlideParser extends AbstractXMLObjectParser { |
| 37 |
public static final String TREE_NODE_REHEIGHT = "nodeReHeight"; |
| 38 |
|
| 39 |
public String getParserName() { |
| 40 |
return TREE_NODE_REHEIGHT; |
| 41 |
} |
| 42 |
|
| 43 |
public Object parseXMLObject(XMLObject xo) throws XMLParseException { |
| 44 |
SpeciesBindings species = (SpeciesBindings) xo.getChild(SpeciesBindings.class); |
| 45 |
SpeciesTreeModel tree = (SpeciesTreeModel) xo.getChild(SpeciesTreeModel.class); |
| 46 |
|
| 47 |
final double weight = xo.getDoubleAttribute(MCMCOperator.WEIGHT); |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
return new TreeNodeSlide(tree, species , weight); |
| 54 |
} |
| 55 |
|
| 56 |
public String getParserDescription() { |
| 57 |
return "Specialized Species tree operator, transform tree without breaking embedding of gene trees."; |
| 58 |
} |
| 59 |
|
| 60 |
public Class getReturnType() { |
| 61 |
return TreeNodeSlide.class; |
| 62 |
} |
| 63 |
|
| 64 |
public XMLSyntaxRule[] getSyntaxRules() { |
| 65 |
return new XMLSyntaxRule[]{ |
| 66 |
AttributeRule.newDoubleRule(MCMCOperator.WEIGHT), |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
new ElementRule(SpeciesBindings.class), |
| 71 |
new ElementRule(SpeciesTreeModel.class) |
| 72 |
}; |
| 73 |
} |
| 74 |
|
| 75 |
} |