use of dr.evomodel.branchratemodel.BranchSpecificFixedEffects in project beast-mcmc by beast-dev.
the class LocationScaleGradientParser method parseTreeDataLikelihood.
private GradientWrtParameterProvider parseTreeDataLikelihood(XMLObject xo, TreeDataLikelihood treeDataLikelihood, String traitName, boolean useHessian) throws XMLParseException {
BranchRateModel branchRateModel = treeDataLikelihood.getBranchRateModel();
DataLikelihoodDelegate delegate = treeDataLikelihood.getDataLikelihoodDelegate();
if (delegate instanceof ContinuousDataLikelihoodDelegate) {
throw new XMLParseException("Not yet implemented! ");
} else if (delegate instanceof BeagleDataLikelihoodDelegate) {
BeagleDataLikelihoodDelegate beagleData = (BeagleDataLikelihoodDelegate) delegate;
BranchModel branchModel = beagleData.getBranchModel();
if (branchRateModel instanceof DefaultBranchRateModel || branchRateModel instanceof ArbitraryBranchRates) {
if (xo.hasChildNamed(LOCATION)) {
BranchSpecificFixedEffects location = parseLocation(xo);
return new LocationGradient(traitName, treeDataLikelihood, beagleData, location, useHessian);
} else if (xo.hasChildNamed(SCALE)) {
Parameter scale = (Parameter) xo.getElementFirstChild(SCALE);
return new ScaleGradient(traitName, treeDataLikelihood, beagleData, scale, useHessian);
} else {
throw new XMLParseException("Poorly formed");
}
} else if (branchModel instanceof ArbitrarySubstitutionParameterBranchModel) {
BranchParameter branchParameter = (BranchParameter) xo.getChild(BranchParameter.class);
if (xo.hasChildNamed(LOCATION)) {
BranchSpecificFixedEffects location = parseLocation(xo);
return new BranchSubstitutionParameterLocationGradient(traitName, treeDataLikelihood, beagleData, branchParameter, useHessian, location);
} else if (xo.hasChildNamed(SCALE)) {
Parameter scale = (Parameter) xo.getElementFirstChild(SCALE);
return new BranchSubstitutionParameterScaleGradient(traitName, treeDataLikelihood, beagleData, branchParameter, scale, useHessian);
} else {
throw new XMLParseException("Not yet implemented.");
}
} else {
throw new XMLParseException("Only implemented for an arbitrary rates model");
}
} else {
throw new XMLParseException("Unknown likelihood delegate type");
}
}
use of dr.evomodel.branchratemodel.BranchSpecificFixedEffects in project beast-mcmc by beast-dev.
the class LocationScaleGradientParser method parseLocation.
private BranchSpecificFixedEffects parseLocation(XMLObject xo) throws XMLParseException {
Object locationObject = xo.getElementFirstChild(LOCATION);
BranchSpecificFixedEffects location;
if (locationObject instanceof Parameter) {
location = new BranchSpecificFixedEffects.None((Parameter) xo.getElementFirstChild(LOCATION));
} else if (locationObject instanceof BranchSpecificFixedEffects) {
location = (BranchSpecificFixedEffects) locationObject;
} else if (locationObject instanceof ArbitraryBranchRates.BranchRateTransform.LocationScaleLogNormal) {
location = ((ArbitraryBranchRates.BranchRateTransform.LocationScaleLogNormal) locationObject).getLocationObject();
} else {
throw new XMLParseException("Poorly formed");
}
return location;
}
use of dr.evomodel.branchratemodel.BranchSpecificFixedEffects in project beast-mcmc by beast-dev.
the class ArbitraryBranchRatesParser method parseTransform.
static ArbitraryBranchRates.BranchRateTransform parseTransform(XMLObject xo) throws XMLParseException {
boolean reciprocal = xo.getAttribute(RECIPROCAL, false);
Logger.getLogger("dr.evomodel").info(" reciprocal = " + reciprocal);
boolean exp = xo.getAttribute(EXP, false);
boolean multiplier = xo.getAttribute(MULTIPLIER, false);
BranchSpecificFixedEffects locationParameter = null;
if (xo.hasChildNamed(LOCATION)) {
Object locationObject = xo.getElementFirstChild(LOCATION);
if (locationObject instanceof BranchSpecificFixedEffects) {
locationParameter = (BranchSpecificFixedEffects) locationObject;
} else {
locationParameter = new BranchSpecificFixedEffects.None((Parameter) locationObject);
}
}
Parameter scaleParameter = null;
if (xo.hasChildNamed(SCALE)) {
scaleParameter = (Parameter) xo.getElementFirstChild(SCALE);
}
return make(reciprocal, exp, multiplier, locationParameter, scaleParameter);
}
Aggregations