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);
}
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);
}
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;
}
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);
}
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);
}
Aggregations