| 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.oldevomodelxml.substmodel; |
| 27 |
|
| 28 |
import dr.xml.*; |
| 29 |
import dr.oldevomodel.substmodel.FrequencyModel; |
| 30 |
import dr.oldevomodel.substmodel.NtdBMA; |
| 31 |
import dr.inference.model.Variable; |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
public class NtdBMAParser extends AbstractXMLObjectParser { |
| 38 |
public static final String NTD_BMA = "ntdBMA"; |
| 39 |
public static final String KAPPA = "kappa"; |
| 40 |
public static final String TN = "tn"; |
| 41 |
public static final String AT = "at"; |
| 42 |
public static final String AC = "ac"; |
| 43 |
public static final String GC = "gc"; |
| 44 |
public static final String GT = "gt"; |
| 45 |
public static final String MODEL_CHOOSE = "modelChoose"; |
| 46 |
|
| 47 |
public static final String FREQUENCIES = "frequencies"; |
| 48 |
|
| 49 |
public String getParserName() { |
| 50 |
return NTD_BMA; |
| 51 |
} |
| 52 |
|
| 53 |
public Object parseXMLObject(XMLObject xo) throws XMLParseException { |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
Variable kappa = (Variable) xo.getElementFirstChild(KAPPA); |
| 58 |
Variable tn = (Variable) xo.getElementFirstChild(TN); |
| 59 |
Variable ac = (Variable) xo.getElementFirstChild(AC); |
| 60 |
Variable at = (Variable) xo.getElementFirstChild(AT); |
| 61 |
Variable gc = (Variable) xo.getElementFirstChild(GC); |
| 62 |
Variable gt = (Variable) xo.getElementFirstChild(GT); |
| 63 |
Variable modelChoose = (Variable) xo.getElementFirstChild(MODEL_CHOOSE); |
| 64 |
XMLObject cxo = xo.getChild(FREQUENCIES); |
| 65 |
FrequencyModel freqModel = (FrequencyModel) cxo.getChild(FrequencyModel.class); |
| 66 |
|
| 67 |
|
| 68 |
return new NtdBMA(kappa, tn, ac, at, gc, gt, modelChoose, freqModel); |
| 69 |
} |
| 70 |
|
| 71 |
public Class getReturnType() { |
| 72 |
return NtdBMA.class; |
| 73 |
} |
| 74 |
|
| 75 |
public XMLSyntaxRule[] getSyntaxRules() { |
| 76 |
return rules; |
| 77 |
} |
| 78 |
|
| 79 |
private final XMLSyntaxRule[] rules = { |
| 80 |
new ElementRule(FREQUENCIES, |
| 81 |
new XMLSyntaxRule[]{new ElementRule(FrequencyModel.class)}), |
| 82 |
new ElementRule(KAPPA, |
| 83 |
new XMLSyntaxRule[]{new ElementRule(Variable.class)}, true), |
| 84 |
new ElementRule(AC, |
| 85 |
new XMLSyntaxRule[]{new ElementRule(Variable.class)}, true), |
| 86 |
new ElementRule(AT, |
| 87 |
new XMLSyntaxRule[]{new ElementRule(Variable.class)}, true), |
| 88 |
new ElementRule(GC, |
| 89 |
new XMLSyntaxRule[]{new ElementRule(Variable.class)}, true), |
| 90 |
new ElementRule(GT, |
| 91 |
new XMLSyntaxRule[]{new ElementRule(Variable.class)}, true), |
| 92 |
new ElementRule(MODEL_CHOOSE, |
| 93 |
new XMLSyntaxRule[]{new ElementRule(Variable.class)}, true), |
| 94 |
}; |
| 95 |
public String getParserDescription() { |
| 96 |
return "A model that allows model averaging over nucleotide substitution models."; |
| 97 |
} |
| 98 |
} |