| 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.substmodel; |
| 27 |
|
| 28 |
import dr.inference.model.Parameter; |
| 29 |
import dr.xml.*; |
| 30 |
import dr.evomodel.substmodel.FrequencyModel; |
| 31 |
import dr.evomodel.substmodel.nucleotide.HKY; |
| 32 |
|
| 33 |
import java.util.logging.Logger; |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
public class HKYParser extends AbstractXMLObjectParser { |
| 40 |
|
| 41 |
public static final String HKY_MODEL = "hkyModel"; |
| 42 |
public static final String KAPPA = "kappa"; |
| 43 |
public static final String FREQUENCIES = "frequencies"; |
| 44 |
|
| 45 |
public String getParserName() { |
| 46 |
return HKY_MODEL; |
| 47 |
} |
| 48 |
|
| 49 |
public Object parseXMLObject(XMLObject xo) throws XMLParseException { |
| 50 |
|
| 51 |
Parameter kappaParam = (Parameter) xo.getElementFirstChild(KAPPA); |
| 52 |
FrequencyModel freqModel = (FrequencyModel) xo.getElementFirstChild(FrequencyModelParser.FREQUENCIES); |
| 53 |
|
| 54 |
if (kappaParam.getId() == null && kappaParam.getParameterValue(0) == 1.0) { |
| 55 |
Logger.getLogger("dr.evomodel").info("\nCreating JC substitution model."); |
| 56 |
} else { |
| 57 |
Logger.getLogger("dr.evomodel").info("\nCreating HKY substitution model. Initial kappa = " + |
| 58 |
kappaParam.getParameterValue(0)); |
| 59 |
} |
| 60 |
return new HKY(kappaParam, freqModel); |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
public String getParserDescription() { |
| 68 |
return "This element represents an instance of the HKY85 " + |
| 69 |
"(Hasegawa, Kishino & Yano, 1985) model of nucleotide evolution."; |
| 70 |
} |
| 71 |
|
| 72 |
public Class getReturnType() { |
| 73 |
return HKY.class; |
| 74 |
} |
| 75 |
|
| 76 |
public XMLSyntaxRule[] getSyntaxRules() { |
| 77 |
return rules; |
| 78 |
} |
| 79 |
|
| 80 |
private final XMLSyntaxRule[] rules = { |
| 81 |
new ElementRule(FrequencyModelParser.FREQUENCIES, |
| 82 |
new XMLSyntaxRule[]{new ElementRule(FrequencyModel.class)}), |
| 83 |
new ElementRule(KAPPA, |
| 84 |
new XMLSyntaxRule[]{new ElementRule(Parameter.class)}) |
| 85 |
}; |
| 86 |
|
| 87 |
} |