| 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.speciation; |
| 27 |
|
| 28 |
import dr.evomodel.speciation.SpeciesTreeModel; |
| 29 |
import dr.evomodel.speciation.SpeciesTreeSimplePrior; |
| 30 |
import dr.inference.distribution.ParametricDistributionModel; |
| 31 |
import dr.inference.model.Parameter; |
| 32 |
import dr.xml.*; |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
public class SpeciesTreeSimplePriorParser extends AbstractXMLObjectParser { |
| 37 |
private static final String STPRIOR = "speciesTreePopulationPrior"; |
| 38 |
public static final String TIPS = "tipsDistribution"; |
| 39 |
|
| 40 |
public String getParserDescription() { |
| 41 |
return ""; |
| 42 |
} |
| 43 |
|
| 44 |
public Class getReturnType() { |
| 45 |
return SpeciesTreeSimplePrior.class; |
| 46 |
} |
| 47 |
|
| 48 |
public String getParserName() { |
| 49 |
return STPRIOR; |
| 50 |
} |
| 51 |
|
| 52 |
public Object parseXMLObject(XMLObject xo) throws XMLParseException { |
| 53 |
SpeciesTreeModel st = (SpeciesTreeModel) xo.getChild(SpeciesTreeModel.class); |
| 54 |
|
| 55 |
|
| 56 |
Parameter pr = (Parameter)((XMLObject)xo.getChild("sigma")).getChild(Parameter.class); |
| 57 |
|
| 58 |
final XMLObject cxo = xo.getChild(TIPS); |
| 59 |
final ParametricDistributionModel tipsPrior = (ParametricDistributionModel) cxo.getChild(ParametricDistributionModel.class); |
| 60 |
|
| 61 |
return new SpeciesTreeSimplePrior(st, pr, tipsPrior); |
| 62 |
} |
| 63 |
|
| 64 |
public XMLSyntaxRule[] getSyntaxRules() { |
| 65 |
return new XMLSyntaxRule[]{ |
| 66 |
new ElementRule(SpeciesTreeModel.class), |
| 67 |
new ElementRule(TIPS, |
| 68 |
new XMLSyntaxRule[] { new ElementRule(ParametricDistributionModel.class) }), |
| 69 |
|
| 70 |
new ElementRule("sigma", new XMLSyntaxRule[] { new ElementRule(Parameter.class) }) |
| 71 |
}; |
| 72 |
} |
| 73 |
} |