Search in sources :

Example 16 with FrequencyModel

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

the class NewMicrosatelliteModelParser method parseXMLObject.

//AbstractXMLObjectParser implementation
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    //get msat data type
    System.out.println("Using watkins' model");
    Microsatellite msat = (Microsatellite) xo.getChild(Microsatellite.class);
    //get FrequencyModel
    FrequencyModel freqModel = null;
    if (xo.hasChildNamed(FrequencyModelParser.FREQUENCIES)) {
        freqModel = (FrequencyModel) xo.getElementFirstChild(FrequencyModelParser.FREQUENCIES);
    }
    return new NewMicrosatelliteModel(msat, freqModel);
}
Also used : FrequencyModel(dr.oldevomodel.substmodel.FrequencyModel) Microsatellite(dr.evolution.datatype.Microsatellite) NewMicrosatelliteModel(dr.oldevomodel.substmodel.NewMicrosatelliteModel)

Example 17 with FrequencyModel

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

the class NtdBMAParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    Variable kappa = (Variable) xo.getElementFirstChild(KAPPA);
    Variable tn = (Variable) xo.getElementFirstChild(TN);
    Variable ac = (Variable) xo.getElementFirstChild(AC);
    Variable at = (Variable) xo.getElementFirstChild(AT);
    Variable gc = (Variable) xo.getElementFirstChild(GC);
    Variable gt = (Variable) xo.getElementFirstChild(GT);
    Variable modelChoose = (Variable) xo.getElementFirstChild(MODEL_CHOOSE);
    XMLObject cxo = xo.getChild(FREQUENCIES);
    FrequencyModel freqModel = (FrequencyModel) cxo.getChild(FrequencyModel.class);
    return new NtdBMA(kappa, tn, ac, at, gc, gt, modelChoose, freqModel);
}
Also used : FrequencyModel(dr.oldevomodel.substmodel.FrequencyModel) Variable(dr.inference.model.Variable) NtdBMA(dr.oldevomodel.substmodel.NtdBMA)

Example 18 with FrequencyModel

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

the class PCACodonModelParser method createNewFreqModel.

// read frequencies from XML and return FrequencyModel object
private FrequencyModel createNewFreqModel(DataType codons, AbstractPCARateMatrix type) throws XMLParseException {
    double[] freqs = type.getFrequencies();
    double sum = 0;
    for (int j = 0; j < freqs.length; j++) {
        sum += freqs[j];
    }
    if (Math.abs(sum - 1.0) > 1e-8) {
        throw new XMLParseException("Frequencies do not sum to 1 (they sum to " + sum + ")");
    }
    FrequencyModel fm = new FrequencyModel(codons, freqs);
    Logger.getLogger("dr.evomodel").info("Using frequencies from data file");
    return fm;
}
Also used : FrequencyModel(dr.oldevomodel.substmodel.FrequencyModel)

Example 19 with FrequencyModel

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

the class SubstitutionEpochModelParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    DataType dataType = null;
    FrequencyModel freqModel = null;
    List<SubstitutionModel> modelList = new ArrayList<SubstitutionModel>();
    XMLObject cxo = xo.getChild(MODELS);
    for (int i = 0; i < cxo.getChildCount(); i++) {
        SubstitutionModel model = (SubstitutionModel) cxo.getChild(i);
        if (dataType == null) {
            dataType = model.getDataType();
        } else if (dataType != model.getDataType())
            throw new XMLParseException("Substitution models across epoches must use the same data type.");
        if (freqModel == null) {
            freqModel = model.getFrequencyModel();
        } else if (freqModel != model.getFrequencyModel())
            throw new XMLParseException("Substitution models across epoches must currently use the same frequency model.\nHarass Marc to fix this.");
        modelList.add(model);
    }
    Parameter transitionTimes = (Parameter) xo.getChild(Parameter.class);
    if (transitionTimes.getDimension() != modelList.size() - 1) {
        throw new XMLParseException("# of transition times must equal # of substitution models - 1\n" + transitionTimes.getDimension() + "\n" + modelList.size());
    }
    return new SubstitutionEpochModel(SUBSTITUTION_EPOCH_MODEL, modelList, transitionTimes, dataType, freqModel);
}
Also used : FrequencyModel(dr.oldevomodel.substmodel.FrequencyModel) ArrayList(java.util.ArrayList) DataType(dr.evolution.datatype.DataType) Parameter(dr.inference.model.Parameter) SubstitutionEpochModel(dr.oldevomodel.substmodel.SubstitutionEpochModel) AbstractSubstitutionModel(dr.oldevomodel.substmodel.AbstractSubstitutionModel) SubstitutionModel(dr.oldevomodel.substmodel.SubstitutionModel)

Example 20 with FrequencyModel

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

the class TN93Parser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    Variable kappa1Param = (Variable) xo.getElementFirstChild(KAPPA1);
    Variable kappa2Param = (Variable) xo.getElementFirstChild(KAPPA2);
    FrequencyModel freqModel = (FrequencyModel) xo.getElementFirstChild(FREQUENCIES);
    Logger.getLogger("dr.evomodel").info("Creating TN93 substitution model. Initial kappa = " + kappa1Param.getValue(0) + "," + kappa2Param.getValue(0));
    return new TN93(kappa1Param, kappa2Param, freqModel);
}
Also used : FrequencyModel(dr.oldevomodel.substmodel.FrequencyModel) Variable(dr.inference.model.Variable) TN93(dr.oldevomodel.substmodel.TN93)

Aggregations

FrequencyModel (dr.oldevomodel.substmodel.FrequencyModel)59 Parameter (dr.inference.model.Parameter)44 GammaSiteModel (dr.oldevomodel.sitemodel.GammaSiteModel)20 HKY (dr.oldevomodel.substmodel.HKY)18 SitePatterns (dr.evolution.alignment.SitePatterns)16 TreeLikelihood (dr.oldevomodel.treelikelihood.TreeLikelihood)16 DataType (dr.evolution.datatype.DataType)11 GeneralSubstitutionModel (dr.oldevomodel.substmodel.GeneralSubstitutionModel)6 ExchangeOperator (dr.evomodel.operators.ExchangeOperator)5 SubtreeSlideOperator (dr.evomodel.operators.SubtreeSlideOperator)5 WilsonBalding (dr.evomodel.operators.WilsonBalding)5 ArrayLogFormatter (dr.inference.loggers.ArrayLogFormatter)5 MCLogger (dr.inference.loggers.MCLogger)5 TabDelimitedFormatter (dr.inference.loggers.TabDelimitedFormatter)5 MCMC (dr.inference.mcmc.MCMC)5 MCMCOptions (dr.inference.mcmc.MCMCOptions)5 ArrayTraceList (dr.inference.trace.ArrayTraceList)5 Trace (dr.inference.trace.Trace)5 TraceCorrelation (dr.inference.trace.TraceCorrelation)5 GTR (dr.oldevomodel.substmodel.GTR)5