use of dr.evomodel.treedatalikelihood.continuous.TreeTipGradient in project beast-mcmc by beast-dev.
the class FullyConjugateTreeTipsPotentialDerivativeParser method parseXMLObject.
@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
// String name = xo.hasId() ? xo.getId() : FULLY_CONJUGATE_TREE_TIPS_POTENTIAL_DERIVATIVE2;
String traitName = xo.getAttribute(TRAIT_NAME, DEFAULT_TRAIT_NAME);
// Object co = xo.getChild(0);
final FullyConjugateMultivariateTraitLikelihood fcTreeLikelihood = (FullyConjugateMultivariateTraitLikelihood) xo.getChild(FullyConjugateMultivariateTraitLikelihood.class);
final TreeDataLikelihood treeDataLikelihood = (TreeDataLikelihood) xo.getChild(TreeDataLikelihood.class);
Parameter mask = null;
if (xo.hasChildNamed(MASKING)) {
mask = (Parameter) xo.getElementFirstChild(MASKING);
}
if (fcTreeLikelihood != null) {
return new FullyConjugateTreeTipsPotentialDerivative(fcTreeLikelihood, mask);
} else if (treeDataLikelihood != null) {
DataLikelihoodDelegate delegate = treeDataLikelihood.getDataLikelihoodDelegate();
if (!(delegate instanceof ContinuousDataLikelihoodDelegate)) {
throw new XMLParseException("May not provide a sequence data likelihood to compute tip trait gradient");
}
final ContinuousDataLikelihoodDelegate continuousData = (ContinuousDataLikelihoodDelegate) delegate;
return new TreeTipGradient(traitName, treeDataLikelihood, continuousData, mask);
} else {
throw new XMLParseException("Must provide a tree likelihood");
}
}
Aggregations