use of dr.evomodel.bigfasttree.constrainedtree.CladeNodeModel in project beast-mcmc by beast-dev.
the class ApproximatePoissonTreeLikelihoodParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
int sequenceLength = xo.getIntegerAttribute("sequenceLength");
TreeModel treeModel = (TreeModel) xo.getChild(TreeModel.class);
BranchLengthProvider branchLengthProvider;
if (xo.getElementFirstChild(DATA) instanceof Tree) {
Tree dataTree = (Tree) xo.getElementFirstChild(DATA);
CladeNodeModel cladeNodeModel = null;
try {
cladeNodeModel = new CladeNodeModel(dataTree, treeModel);
} catch (TreeUtils.MissingTaxonException e) {
e.printStackTrace();
}
branchLengthProvider = new ConstrainedTreeBranchLengthProvider(cladeNodeModel);
} else if (xo.getElementFirstChild(DATA) instanceof CladeNodeModel) {
CladeNodeModel cladeNodeModel = (CladeNodeModel) xo.getElementFirstChild(DATA);
branchLengthProvider = new ConstrainedTreeBranchLengthProvider(cladeNodeModel);
} else {
DistanceMatrix dataMatrix = (DistanceMatrix) xo.getElementFirstChild(DATA);
branchLengthProvider = new RzhetskyNeiBranchLengthProvider(dataMatrix, treeModel);
}
BranchRateModel branchRateModel = (BranchRateModel) xo.getChild(BranchRateModel.class);
return new ApproximatePoissonTreeLikelihood(TREE_LIKELIHOOD, sequenceLength, treeModel, branchRateModel, branchLengthProvider);
}
use of dr.evomodel.bigfasttree.constrainedtree.CladeNodeModel in project beast-mcmc by beast-dev.
the class CladeAwareSubtreeLeapOperatorParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
AdaptationMode mode = AdaptationMode.parseMode(xo);
CladeNodeModel cladeModel = (CladeNodeModel) xo.getChild(CladeNodeModel.class);
final double weight = xo.getDoubleAttribute(MCMCOperator.WEIGHT);
final double size = xo.getAttribute(SIZE, Double.NaN);
final double targetAcceptance = xo.getAttribute(TARGET_ACCEPTANCE, 0.234);
CladeAwareSubtreeLeap.DistanceKernelType distanceKernel = CladeAwareSubtreeLeap.DistanceKernelType.NORMAL;
if (size <= 0.0) {
throw new XMLParseException("The SubTreeLeap size attribute must be positive and non-zero.");
}
if (targetAcceptance <= 0.0 || targetAcceptance >= 1.0) {
throw new XMLParseException("Target acceptance probability has to lie in (0, 1)");
}
final boolean slideOnly = xo.getAttribute(SLIDE_ONLY, false);
return new CladeAwareSubtreeLeap(cladeModel, weight, size, distanceKernel, mode, targetAcceptance, slideOnly);
}
use of dr.evomodel.bigfasttree.constrainedtree.CladeNodeModel in project beast-mcmc by beast-dev.
the class CladeNodeModelParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
Tree cladeTree = (Tree) xo.getElementFirstChild(CLADE_TREE);
TreeModel treeModel = (TreeModel) xo.getChild(TreeModel.class);
try {
return new CladeNodeModel(CLADE_MODEL, cladeTree, treeModel);
} catch (TreeUtils.MissingTaxonException e) {
e.printStackTrace();
throw new XMLParseException("tree and clade much match");
}
}
use of dr.evomodel.bigfasttree.constrainedtree.CladeNodeModel in project beast-mcmc by beast-dev.
the class CladeAwareSubtreeLeapTest method setUp.
public void setUp() throws Exception {
super.setUp();
MathUtils.setSeed(112432);
NewickImporter importer = new NewickImporter("(((0:1.0,(1:1.0,2:1.0)n6:1.0)n7:1.0,3:2.0)n8:1.0,(4:3.0,5:1.0)n9:1.0)n10;");
NewickImporter constraintsImporter = new NewickImporter("((0:1.0,1:1.0,2:1.0,3:1.0):1.0,4:1.0,5:0.1);");
Tree rawTree = importer.importTree(null);
Tree constraintsTree = constraintsImporter.importTree(null);
tree = new BigFastTreeModel(rawTree);
cladeNodeModel = new CladeNodeModel(constraintsTree, tree);
operator = new CladeAwareSubtreeLeap(cladeNodeModel, 100);
}
use of dr.evomodel.bigfasttree.constrainedtree.CladeNodeModel in project beast-mcmc by beast-dev.
the class ApproximatePoissonTreeLikelihoodTest method setUp.
public void setUp() throws Exception {
super.setUp();
branchRateModel = new StrictClockBranchRates(new Parameter.Default(1.0));
NewickImporter importer = new NewickImporter("((1:1.0,2:1.0,3:1.0):1.0,4:1.0);");
NewickImporter importer2 = new NewickImporter("(((1:1.0,2:1.0):0.1,3:1.1):1.0,4:1.0);");
tree = importer.importTree(null);
treeModel = new BigFastTreeModel(importer2.importTree(null));
cladeModel = new CladeNodeModel(tree, treeModel);
BranchLengthProvider constrainedBranchLengthProvider = new ConstrainedTreeBranchLengthProvider(cladeModel);
approximatePoissonTreeLikelihood = new ApproximatePoissonTreeLikelihood("approximateTreeLikelihood", 1, treeModel, branchRateModel, constrainedBranchLengthProvider);
expectedLL = 0;
double[] expectations = { 1d, 1d, 1.1, 2d, 0.1 };
// time
double[] mutations = { 1d, 1d, 1.0, 2d, 0 };
for (int i = 0; i < expectations.length; i++) {
PoissonDistribution p = new PoissonDistribution(expectations[i]);
expectedLL += p.logPdf(mutations[i]);
}
approximatePoissonTreeLikelihood.getLogLikelihood();
}
Aggregations