use of dr.evolution.datatype.OldHiddenNucleotides in project beast-mcmc by beast-dev.
the class CovarionHKYTest method setUp.
public void setUp() throws Exception {
super.setUp();
alpha = new Parameter.Default(0.0);
switchingRate = new Parameter.Default(1.0);
kappa = new Parameter.Default(2.0);
dataType = new OldHiddenNucleotides(2);
}
use of dr.evolution.datatype.OldHiddenNucleotides in project beast-mcmc by beast-dev.
the class CovarionGTRParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
XMLObject cxo = xo.getChild(AbstractCovarionDNAModel.FREQUENCIES);
FrequencyModel freqModel = (FrequencyModel) cxo.getChild(FrequencyModel.class);
OldHiddenNucleotides dataType = (OldHiddenNucleotides) freqModel.getDataType();
Parameter hiddenRates = (Parameter) xo.getElementFirstChild(AbstractCovarionDNAModel.HIDDEN_CLASS_RATES);
Parameter switchingRates = (Parameter) xo.getElementFirstChild(AbstractCovarionDNAModel.SWITCHING_RATES);
Parameter rateACParameter = null;
if (xo.hasChildNamed(GTRParser.A_TO_C)) {
rateACParameter = (Parameter) xo.getElementFirstChild(GTRParser.A_TO_C);
}
Parameter rateAGParameter = null;
if (xo.hasChildNamed(GTRParser.A_TO_G)) {
rateAGParameter = (Parameter) xo.getElementFirstChild(GTRParser.A_TO_G);
}
Parameter rateATParameter = null;
if (xo.hasChildNamed(GTRParser.A_TO_T)) {
rateATParameter = (Parameter) xo.getElementFirstChild(GTRParser.A_TO_T);
}
Parameter rateCGParameter = null;
if (xo.hasChildNamed(GTRParser.C_TO_G)) {
rateCGParameter = (Parameter) xo.getElementFirstChild(GTRParser.C_TO_G);
}
Parameter rateCTParameter = null;
if (xo.hasChildNamed(GTRParser.C_TO_T)) {
rateCTParameter = (Parameter) xo.getElementFirstChild(GTRParser.C_TO_T);
}
Parameter rateGTParameter = null;
if (xo.hasChildNamed(GTRParser.G_TO_T)) {
rateGTParameter = (Parameter) xo.getElementFirstChild(GTRParser.G_TO_T);
}
if (dataType != freqModel.getDataType()) {
throw new XMLParseException("Data type of " + getParserName() + " element does not match that of its frequencyModel.");
}
return new CovarionGTR(dataType, hiddenRates, switchingRates, rateACParameter, rateAGParameter, rateATParameter, rateCGParameter, rateCTParameter, rateGTParameter, freqModel);
}
use of dr.evolution.datatype.OldHiddenNucleotides in project beast-mcmc by beast-dev.
the class CovarionHKYParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
Parameter kappaParam;
Parameter switchingRates;
Parameter hiddenClassRates;
FrequencyModel freqModel;
kappaParam = (Parameter) xo.getElementFirstChild(KAPPA);
switchingRates = (Parameter) xo.getElementFirstChild(AbstractCovarionDNAModel.SWITCHING_RATES);
hiddenClassRates = (Parameter) xo.getElementFirstChild(AbstractCovarionDNAModel.HIDDEN_CLASS_RATES);
freqModel = (FrequencyModel) xo.getElementFirstChild(AbstractCovarionDNAModel.FREQUENCIES);
if (!(freqModel.getDataType() instanceof OldHiddenNucleotides)) {
throw new IllegalArgumentException("Datatype must be hidden nucleotides!!");
}
OldHiddenNucleotides dataType = (OldHiddenNucleotides) freqModel.getDataType();
int hiddenStateCount = dataType.getHiddenClassCount();
int switchingRatesCount = hiddenStateCount * (hiddenStateCount - 1) / 2;
if (switchingRates.getDimension() != switchingRatesCount) {
throw new IllegalArgumentException("switching rates parameter must have " + switchingRatesCount + " dimensions, for " + hiddenStateCount + " hidden categories");
}
CovarionHKY model = new CovarionHKY(dataType, kappaParam, hiddenClassRates, switchingRates, freqModel);
System.out.println(model);
return model;
}
Aggregations