Search in sources :

Example 6 with TreeTraitProvider

use of dr.evolution.tree.TreeTraitProvider in project beast-mcmc by beast-dev.

the class AncestralTraitParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    String traitName = xo.getAttribute(TRAIT_NAME, STATES);
    String name = xo.getAttribute(NAME, traitName);
    Tree tree = (Tree) xo.getChild(Tree.class);
    TreeTraitProvider treeTraitProvider = (TreeTraitProvider) xo.getChild(TreeTraitProvider.class);
    TaxonList taxa = null;
    if (xo.hasChildNamed(MRCA)) {
        taxa = (TaxonList) xo.getElementFirstChild(MRCA);
    }
    TreeTrait trait = treeTraitProvider.getTreeTrait(traitName);
    if (trait == null) {
        throw new XMLParseException("A trait called, " + traitName + ", was not available from the TreeTraitProvider supplied to " + getParserName() + (xo.hasId() ? ", with ID " + xo.getId() : ""));
    }
    try {
        return new AncestralTrait(name, trait, tree, taxa);
    } catch (TreeUtils.MissingTaxonException mte) {
        throw new XMLParseException("Taxon, " + mte + ", in " + getParserName() + "was not found in the tree.");
    }
}
Also used : TreeTraitProvider(dr.evolution.tree.TreeTraitProvider) TaxonList(dr.evolution.util.TaxonList) Tree(dr.evolution.tree.Tree) AncestralTrait(dr.evomodel.tree.AncestralTrait) TreeTrait(dr.evolution.tree.TreeTrait) TreeUtils(dr.evolution.tree.TreeUtils)

Aggregations

TreeTraitProvider (dr.evolution.tree.TreeTraitProvider)6 TreeModel (dr.evomodel.tree.TreeModel)4 TreeTrait (dr.evolution.tree.TreeTrait)3 DataType (dr.evolution.datatype.DataType)2 Tree (dr.evolution.tree.Tree)2 Parameter (dr.inference.model.Parameter)2 NumberFormat (java.text.NumberFormat)2 AncestralSequenceTrait (dr.app.bss.test.AncestralSequenceTrait)1 PatternList (dr.evolution.alignment.PatternList)1 ImportException (dr.evolution.io.Importer.ImportException)1 NewickImporter (dr.evolution.io.NewickImporter)1 NodeRef (dr.evolution.tree.NodeRef)1 TreeUtils (dr.evolution.tree.TreeUtils)1 TaxonList (dr.evolution.util.TaxonList)1 BranchRateModel (dr.evomodel.branchratemodel.BranchRateModel)1 DefaultBranchRateModel (dr.evomodel.branchratemodel.DefaultBranchRateModel)1 DiscreteTraitBranchRateModel (dr.evomodel.branchratemodel.DiscreteTraitBranchRateModel)1 MultivariateDiffusionModel (dr.evomodel.continuous.MultivariateDiffusionModel)1 AncestralTrait (dr.evomodel.tree.AncestralTrait)1 ProcessSimulation (dr.evomodel.treedatalikelihood.ProcessSimulation)1