Search in sources :

Example 1 with XMLObject

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);
}
Also used : MulSpeciesTreePrior(dr.evomodel.alloppnet.speciation.MulSpeciesTreePrior) XMLObject(dr.xml.XMLObject) MulSpeciesTreeModel(dr.evomodel.alloppnet.speciation.MulSpeciesTreeModel) SpeciationModel(dr.evomodel.speciation.SpeciationModel)

Example 2 with XMLObject

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
// );
}
Also used : TreeModel(dr.evomodel.tree.TreeModel) Likelihood(dr.inference.model.Likelihood) ArrayList(java.util.ArrayList) Parameter(dr.inference.model.Parameter) XMLObject(dr.xml.XMLObject)

Example 3 with XMLObject

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);
}
Also used : FrequencyModel(dr.evomodel.substmodel.FrequencyModel) TreeModel(dr.evomodel.tree.TreeModel) ArrayList(java.util.ArrayList) XMLObject(dr.xml.XMLObject) Parameter(dr.inference.model.Parameter) SubstitutionModel(dr.evomodel.substmodel.SubstitutionModel)

Example 4 with XMLObject

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);
}
Also used : XMLObject(dr.xml.XMLObject) Parameter(dr.inference.model.Parameter) XMLParseException(dr.xml.XMLParseException)

Example 5 with XMLObject

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);
}
Also used : TreeModel(dr.evomodel.tree.TreeModel) BranchAssignmentModel(dr.evomodel.branchmodel.BranchAssignmentModel) XMLObject(dr.xml.XMLObject) SubstitutionModel(dr.evomodel.substmodel.SubstitutionModel) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

XMLObject (dr.xml.XMLObject)13 Parameter (dr.inference.model.Parameter)7 SubstitutionModel (dr.evomodel.substmodel.SubstitutionModel)6 TreeModel (dr.evomodel.tree.TreeModel)6 ArrayList (java.util.ArrayList)5 XMLParseException (dr.xml.XMLParseException)4 DataType (dr.evolution.datatype.DataType)2 GammaSiteRateModel (dr.evomodel.siteratemodel.GammaSiteRateModel)2 FrequencyModel (dr.evomodel.substmodel.FrequencyModel)2 Partition (dr.app.beagle.tools.Partition)1 Sequence (dr.evolution.sequence.Sequence)1 MutableTreeModel (dr.evolution.tree.MutableTreeModel)1 Units (dr.evolution.util.Units)1 AlloppNetworkPriorModel (dr.evomodel.alloppnet.speciation.AlloppNetworkPriorModel)1 MulSpeciesTreeModel (dr.evomodel.alloppnet.speciation.MulSpeciesTreeModel)1 MulSpeciesTreePrior (dr.evomodel.alloppnet.speciation.MulSpeciesTreePrior)1 BranchAssignmentModel (dr.evomodel.branchmodel.BranchAssignmentModel)1 BranchModel (dr.evomodel.branchmodel.BranchModel)1 EpochBranchModel (dr.evomodel.branchmodel.EpochBranchModel)1 HomogeneousBranchModel (dr.evomodel.branchmodel.HomogeneousBranchModel)1