| 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.evolution.util.Units; |
| 29 |
import dr.evomodel.speciation.BirthDeathSerialSamplingModel; |
| 30 |
import dr.evoxml.util.XMLUnits; |
| 31 |
import dr.inference.model.Parameter; |
| 32 |
import dr.xml.*; |
| 33 |
|
| 34 |
import java.util.logging.Logger; |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
public class BirthDeathEpidemiologyModelParser extends AbstractXMLObjectParser { |
| 43 |
|
| 44 |
public static final String BIRTH_DEATH_EPIDEMIOLOGY = "birthDeathEpidemiology"; |
| 45 |
public static final String R0 = "R0"; |
| 46 |
public static final String RECOVERY_RATE = "recoveryRate"; |
| 47 |
public static final String SAMPLING_PROBABILITY = "samplingProbability"; |
| 48 |
public static final String ORIGIN = BirthDeathSerialSamplingModelParser.ORIGIN; |
| 49 |
|
| 50 |
public String getParserName() { |
| 51 |
return BIRTH_DEATH_EPIDEMIOLOGY; |
| 52 |
} |
| 53 |
|
| 54 |
public Object parseXMLObject(XMLObject xo) throws XMLParseException { |
| 55 |
|
| 56 |
final String modelName = xo.getId(); |
| 57 |
final Units.Type units = XMLUnits.Utils.getUnitsAttr(xo); |
| 58 |
|
| 59 |
final Parameter R0Parameter = (Parameter) xo.getElementFirstChild(R0); |
| 60 |
final Parameter recoveryRateParameter = (Parameter) xo.getElementFirstChild(RECOVERY_RATE); |
| 61 |
final Parameter samplingProbabiltyParameter = (Parameter) xo.getElementFirstChild(SAMPLING_PROBABILITY); |
| 62 |
|
| 63 |
Parameter origin = null; |
| 64 |
if (xo.hasChildNamed(ORIGIN)) { |
| 65 |
origin = (Parameter) xo.getElementFirstChild(ORIGIN); |
| 66 |
} |
| 67 |
|
| 68 |
Logger.getLogger("dr.evomodel").info("Using epidemiological parameterization of " + getCitationRT()); |
| 69 |
|
| 70 |
return new BirthDeathSerialSamplingModel(modelName, R0Parameter, recoveryRateParameter, samplingProbabiltyParameter, origin, units); |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
public static String getCitationPsiOrg() { |
| 78 |
|
| 79 |
return "Stadler T (2010) J Theor Biol 267, 396-404 [Birth-Death with Serial Samples]."; |
| 80 |
} |
| 81 |
|
| 82 |
public static String getCitationRT() { |
| 83 |
return "Stadler et al (2011) : Estimating the basic reproductive number from viral sequence data, " + |
| 84 |
"Mol.Biol.Evol., doi: 10.1093/molbev/msr217, 2011"; |
| 85 |
} |
| 86 |
|
| 87 |
public String getParserDescription() { |
| 88 |
return "Stadler et al (2011) model of epidemiology."; |
| 89 |
} |
| 90 |
|
| 91 |
public Class getReturnType() { |
| 92 |
return BirthDeathSerialSamplingModel.class; |
| 93 |
} |
| 94 |
|
| 95 |
public XMLSyntaxRule[] getSyntaxRules() { |
| 96 |
return rules; |
| 97 |
} |
| 98 |
|
| 99 |
private final XMLSyntaxRule[] rules = { |
| 100 |
new ElementRule(ORIGIN, Parameter.class, "The origin of the infection, x0 > tree.rootHeight", true), |
| 101 |
new ElementRule(R0, new XMLSyntaxRule[]{new ElementRule(Parameter.class)}), |
| 102 |
new ElementRule(RECOVERY_RATE, new XMLSyntaxRule[]{new ElementRule(Parameter.class)}), |
| 103 |
new ElementRule(SAMPLING_PROBABILITY, new XMLSyntaxRule[]{new ElementRule(Parameter.class)}), |
| 104 |
XMLUnits.SYNTAX_RULES[0] |
| 105 |
}; |
| 106 |
} |