| 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.SpeciesTreeBMPrior; |
| 29 |
import dr.evomodel.speciation.SpeciesTreeModel; |
| 30 |
import dr.inference.distribution.ParametricDistributionModel; |
| 31 |
import dr.inference.model.Parameter; |
| 32 |
import dr.xml.*; |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
public class SpeciesTreeBMPriorParser extends AbstractXMLObjectParser { |
| 37 |
public static final String TIPS = "tipsDistribution"; |
| 38 |
|
| 39 |
public static final String STPRIOR = "STPopulationPrior"; |
| 40 |
|
| 41 |
public static final String LOG_ROOT = "log_root"; |
| 42 |
public static final String STSIGMA = "STsigma"; |
| 43 |
public static final String SIGMA = "sigma"; |
| 44 |
|
| 45 |
public String getParserDescription() { |
| 46 |
return ""; |
| 47 |
} |
| 48 |
|
| 49 |
public Class getReturnType() { |
| 50 |
return SpeciesTreeBMPrior.class; |
| 51 |
} |
| 52 |
|
| 53 |
public String getParserName() { |
| 54 |
return STPRIOR; |
| 55 |
} |
| 56 |
|
| 57 |
public Object parseXMLObject(XMLObject xo) throws XMLParseException { |
| 58 |
final SpeciesTreeModel st = (SpeciesTreeModel) xo.getChild(SpeciesTreeModel.class); |
| 59 |
|
| 60 |
|
| 61 |
final Object child = xo.getChild(SIGMA); |
| 62 |
Parameter popSigma = child != null ? (Parameter)((XMLObject) child).getChild(Parameter.class) : null; |
| 63 |
Parameter stSigma = (Parameter)((XMLObject)xo.getChild(STSIGMA)).getChild(Parameter.class); |
| 64 |
|
| 65 |
final XMLObject cxo = (XMLObject) xo.getChild(TIPS); |
| 66 |
final ParametricDistributionModel tipsPrior = |
| 67 |
(ParametricDistributionModel) cxo.getChild(ParametricDistributionModel.class); |
| 68 |
final boolean logRoot = xo.getAttribute(LOG_ROOT, false); |
| 69 |
return new SpeciesTreeBMPrior(st, popSigma, stSigma, tipsPrior, logRoot); |
| 70 |
} |
| 71 |
|
| 72 |
public XMLSyntaxRule[] getSyntaxRules() { |
| 73 |
return new XMLSyntaxRule[]{ |
| 74 |
AttributeRule.newBooleanRule(LOG_ROOT, true), |
| 75 |
new ElementRule(SpeciesTreeModel.class), |
| 76 |
new ElementRule(TIPS, |
| 77 |
new XMLSyntaxRule[] { new ElementRule(ParametricDistributionModel.class) }), |
| 78 |
|
| 79 |
new ElementRule(SIGMA, new XMLSyntaxRule[] { new ElementRule(Parameter.class) }, true), |
| 80 |
new ElementRule(STSIGMA, new XMLSyntaxRule[] { new ElementRule(Parameter.class) }) |
| 81 |
}; |
| 82 |
} |
| 83 |
} |