Search in sources :

Example 1 with OldHiddenNucleotides

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);
}
Also used : OldHiddenNucleotides(dr.evolution.datatype.OldHiddenNucleotides) Parameter(dr.inference.model.Parameter)

Example 2 with OldHiddenNucleotides

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);
}
Also used : FrequencyModel(dr.oldevomodel.substmodel.FrequencyModel) OldHiddenNucleotides(dr.evolution.datatype.OldHiddenNucleotides) Parameter(dr.inference.model.Parameter) CovarionGTR(dr.oldevomodel.substmodel.CovarionGTR)

Example 3 with OldHiddenNucleotides

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;
}
Also used : FrequencyModel(dr.oldevomodel.substmodel.FrequencyModel) OldHiddenNucleotides(dr.evolution.datatype.OldHiddenNucleotides) Parameter(dr.inference.model.Parameter) CovarionHKY(dr.oldevomodel.substmodel.CovarionHKY)

Aggregations

OldHiddenNucleotides (dr.evolution.datatype.OldHiddenNucleotides)3 Parameter (dr.inference.model.Parameter)3 FrequencyModel (dr.oldevomodel.substmodel.FrequencyModel)2 CovarionGTR (dr.oldevomodel.substmodel.CovarionGTR)1 CovarionHKY (dr.oldevomodel.substmodel.CovarionHKY)1