| 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.coalescent; |
| 27 |
|
| 28 |
import dr.evolution.tree.Tree; |
| 29 |
import dr.evolution.util.Units; |
| 30 |
import dr.evomodel.coalescent.EmergingEpidemicModel; |
| 31 |
import dr.evomodel.coalescent.ExponentialGrowthModel; |
| 32 |
import dr.evomodel.tree.TreeModel; |
| 33 |
import dr.evoxml.util.XMLUnits; |
| 34 |
import dr.inference.model.Parameter; |
| 35 |
import dr.xml.*; |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
public class EmergingEpidemicModelParser extends AbstractXMLObjectParser { |
| 41 |
|
| 42 |
public static String EMERGING_EPIDEMIC_MODEL = "emergingEpidemic"; |
| 43 |
|
| 44 |
|
| 45 |
public static String GROWTH_RATE = "growthRate"; |
| 46 |
public static String GENERATION_TIME = "generationTime"; |
| 47 |
public static String GENERATION_DISTRIBUTION_SHAPE = "generationShape"; |
| 48 |
public static String OFFSPRING_DISPERSION = "offspringDispersion"; |
| 49 |
|
| 50 |
public static String TREE = "epidemicTree"; |
| 51 |
|
| 52 |
|
| 53 |
public String getParserName() { |
| 54 |
return EMERGING_EPIDEMIC_MODEL; |
| 55 |
} |
| 56 |
|
| 57 |
public Object parseXMLObject(XMLObject xo) throws XMLParseException { |
| 58 |
|
| 59 |
Units.Type units = XMLUnits.Utils.getUnitsAttr(xo); |
| 60 |
|
| 61 |
Parameter growthRateParameter = (Parameter)xo.getElementFirstChild(GROWTH_RATE); |
| 62 |
Parameter generationTimeParameter = (Parameter)xo.getElementFirstChild(GENERATION_TIME); |
| 63 |
Parameter generationShapeParameter = (Parameter)xo.getElementFirstChild(GENERATION_DISTRIBUTION_SHAPE); |
| 64 |
Parameter offspringDispersionParameter = (Parameter)xo.getElementFirstChild(OFFSPRING_DISPERSION); |
| 65 |
TreeModel tree = (TreeModel)xo.getElementFirstChild(TREE); |
| 66 |
|
| 67 |
return new EmergingEpidemicModel(growthRateParameter, generationTimeParameter, generationShapeParameter, offspringDispersionParameter, tree, units); |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
public String getParserDescription() { |
| 75 |
return "A self-consistent model of emerging epidemics."; |
| 76 |
} |
| 77 |
|
| 78 |
public Class getReturnType() { |
| 79 |
return EmergingEpidemicModel.class; |
| 80 |
} |
| 81 |
|
| 82 |
public XMLSyntaxRule[] getSyntaxRules() { |
| 83 |
return rules; |
| 84 |
} |
| 85 |
|
| 86 |
private XMLSyntaxRule[] rules = new XMLSyntaxRule[]{ |
| 87 |
new ElementRule(GROWTH_RATE, Parameter.class), |
| 88 |
new ElementRule(GENERATION_TIME, Parameter.class), |
| 89 |
new ElementRule(GENERATION_DISTRIBUTION_SHAPE, Parameter.class), |
| 90 |
new ElementRule(OFFSPRING_DISPERSION, Parameter.class), |
| 91 |
new ElementRule(TREE, Tree.class), |
| 92 |
|
| 93 |
XMLUnits.SYNTAX_RULES[0] |
| 94 |
}; |
| 95 |
|
| 96 |
|
| 97 |
} |