use of dr.xml.XMLObject in project beast-mcmc by beast-dev.
the class MulSpeciesTreePriorParser method parseXMLObject.
@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
final XMLObject mxo = xo.getChild(MODEL);
final SpeciationModel sppm = (SpeciationModel) mxo.getChild(SpeciationModel.class);
final XMLObject mulsptxo = xo.getChild(MUL_SPECIES_TREE);
final MulSpeciesTreeModel mulspt = (MulSpeciesTreeModel) mulsptxo.getChild(MulSpeciesTreeModel.class);
return new MulSpeciesTreePrior(sppm, mulspt);
}
use of dr.xml.XMLObject in project beast-mcmc by beast-dev.
the class BeagleBranchLikelihoodParser method parseXMLObject.
@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
TreeModel treeModel = (TreeModel) xo.getChild(TreeModel.class);
// if(xo.hasChildNamed(TreeModel.TREE_MODEL)) {
//
// treeModel = (TreeModel) xo.getChild(TreeModel.class);
// }
Parameter zParameter = (Parameter) xo.getElementFirstChild(DirichletProcessPriorParser.CATEGORIES);
List<Likelihood> likelihoods = new ArrayList<Likelihood>();
XMLObject cxo = (XMLObject) xo.getChild(UNIQUE_LIKELIHOODS);
for (int i = 0; i < cxo.getChildCount(); i++) {
Likelihood likelihood = (Likelihood) cxo.getChild(i);
likelihoods.add(likelihood);
}
return null;
// new BeagleBranchLikelihood(
// // treeModel, likelihoods, zParameter
// );
}
use of dr.xml.XMLObject in project beast-mcmc by beast-dev.
the class LineageSpecificBranchModelParser method parseXMLObject.
@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
TreeModel treeModel = (TreeModel) xo.getChild(TreeModel.class);
FrequencyModel rootFrequencyModel = (FrequencyModel) xo.getChild(FrequencyModel.class);
List<SubstitutionModel> substitutionModels = new ArrayList<SubstitutionModel>();
XMLObject cxo = xo.getChild(MODELS);
for (int i = 0; i < cxo.getChildCount(); i++) {
SubstitutionModel substModel = (SubstitutionModel) cxo.getChild(i);
substitutionModels.add(substModel);
}
// END: models loop
// TODO: check if categories numbering starts from zero
Parameter categories = (Parameter) xo.getElementFirstChild(CATEGORIES);
return new // provider,
LineageSpecificBranchModel(// provider,
treeModel, // provider,
rootFrequencyModel, // provider,
substitutionModels, categories);
}
use of dr.xml.XMLObject in project beast-mcmc by beast-dev.
the class ConjugateRootTraitPrior method parseConjugateRootTraitPrior.
public static ConjugateRootTraitPrior parseConjugateRootTraitPrior(XMLObject xo, final int dim) throws XMLParseException {
XMLObject cxo = xo.getChild(CONJUGATE_ROOT_PRIOR);
Parameter meanParameter = (Parameter) cxo.getChild(MultivariateDistributionLikelihood.MVN_MEAN).getChild(Parameter.class);
if (meanParameter.getDimension() != dim) {
throw new XMLParseException("Root prior mean dimension (" + meanParameter.getDimension() + ") does not match trait diffusion dimension (" + dim + ")");
}
Parameter sampleSizeParameter = (Parameter) cxo.getChild(PRIOR_SAMPLE_SIZE).getChild(Parameter.class);
return new ConjugateRootTraitPrior(meanParameter, sampleSizeParameter);
}
use of dr.xml.XMLObject in project beast-mcmc by beast-dev.
the class BranchAssignmentModelParser method parseXMLObject.
@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
Logger.getLogger("dr.evomodel").info("\nUsing branch assignment branch model.");
TreeModel treeModel = (TreeModel) xo.getChild(TreeModel.class);
String annotation = xo.getStringAttribute(ANNOTATION);
LinkedHashMap<Integer, SubstitutionModel> modelIndexMap = new LinkedHashMap<Integer, SubstitutionModel>();
for (int i = 0; i < xo.getChildCount(); i++) {
if (xo.getChild(i) instanceof XMLObject) {
XMLObject xoc = (XMLObject) xo.getChild(i);
if (xoc.getName().equals(ASSIGNMENT)) {
Integer index = null;
if (xoc.hasAttribute(ANNOTATION_VALUE)) {
index = xoc.getIntegerAttribute(ANNOTATION_VALUE);
}
SubstitutionModel model = (SubstitutionModel) xoc.getChild(SubstitutionModel.class);
modelIndexMap.put(index, model);
}
}
}
SubstitutionModel baseModel = (SubstitutionModel) xo.getElementFirstChild(BASE_MODEL);
return new BranchAssignmentModel(treeModel, annotation, modelIndexMap, baseModel);
}
Aggregations