Search in sources :

Example 1 with MsatBMA

use of dr.oldevomodel.substmodel.MsatBMA in project beast-mcmc by beast-dev.

the class MsatBMAParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    //get microsatellite data type
    Microsatellite dataType = (Microsatellite) xo.getChild(Microsatellite.class);
    //whether mutational bias is in logit space
    boolean logit = xo.getAttribute(LOGIT, true);
    XMLObject modelsXO = xo.getChild(MODELS);
    int modelCount = modelsXO.getChildCount();
    HashMap<Integer, Integer> modelBitIndMap = new HashMap<Integer, Integer>(modelCount);
    for (int i = 0; i < modelCount; i++) {
        XMLObject modelXO = (XMLObject) modelsXO.getChild(i);
        String bitVec = modelXO.getStringAttribute(BINARY);
        int bitVecVal = Integer.parseInt(bitVec, 2);
        int modelCode = modelXO.getIntegerAttribute(CODE);
        modelBitIndMap.put(bitVecVal, modelCode);
    }
    Parameter[][] paramModelMap = new Parameter[6][modelCount];
    XMLObject propRatesXO = xo.getChild(RATE_PROPS);
    ArrayList<Parameter> rateProps = processParameters(propRatesXO, paramModelMap, MsatBMA.PROP_INDEX);
    XMLObject quadRatesXO = xo.getChild(RATE_QUADS);
    ArrayList<Parameter> rateQuads = processParameters(quadRatesXO, paramModelMap, MsatBMA.QUAD_INDEX);
    XMLObject biasConstsXO = xo.getChild(BIAS_CONSTS);
    ArrayList<Parameter> biasConsts = processParameters(biasConstsXO, paramModelMap, MsatBMA.BIAS_CONST_INDEX);
    XMLObject biasLinsXO = xo.getChild(BIAS_LINS);
    ArrayList<Parameter> biasLins = processParameters(biasLinsXO, paramModelMap, MsatBMA.BIAS_LIN_INDEX);
    XMLObject geosXO = xo.getChild(GEOS);
    ArrayList<Parameter> geos = processParameters(geosXO, paramModelMap, MsatBMA.GEO_INDEX);
    XMLObject phaseProbXO = xo.getChild(PHASE_PROBS);
    ArrayList<Parameter> phaseProbs = processParameters(phaseProbXO, paramModelMap, MsatBMA.PHASE_PROB_INDEX);
    Parameter modelChoose = (Parameter) xo.getElementFirstChild(MODEL_CHOOSE);
    Parameter modelIndicator = (Parameter) xo.getElementFirstChild(MODEL_INDICATOR);
    printParameters(paramModelMap);
    return new MsatBMA(dataType, logit, rateProps, rateQuads, biasConsts, biasLins, geos, phaseProbs, paramModelMap, modelChoose, modelIndicator, modelBitIndMap);
}
Also used : Microsatellite(dr.evolution.datatype.Microsatellite) MsatBMA(dr.oldevomodel.substmodel.MsatBMA) HashMap(java.util.HashMap) Parameter(dr.inference.model.Parameter)

Aggregations

Microsatellite (dr.evolution.datatype.Microsatellite)1 Parameter (dr.inference.model.Parameter)1 MsatBMA (dr.oldevomodel.substmodel.MsatBMA)1 HashMap (java.util.HashMap)1