use of bacter.model.ACGCoalescent in project bacter by tgvaughan.
the class AddRemoveConversionTest method testProbability.
/**
* Tests whether probability of proposing a conversion lines up with
* conversion probability found in ACGCoalescent.
* @throws java.lang.Exception
*/
@Test
public void testProbability() throws Exception {
ConstantPopulation popFunc = new ConstantPopulation();
popFunc.initByName("popSize", new RealParameter("1.0"));
Locus locus = new Locus("locus", 10000);
TaxonSet taxonSet = getTaxonSet(10);
SimulatedACG acg = new SimulatedACG();
acg.initByName("rho", 1.0 / locus.getSiteCount(), "delta", 50.0, "locus", locus, "taxonset", taxonSet, "populationModel", popFunc);
RealParameter rho = new RealParameter(Double.toString(1.0 / locus.getSiteCount()));
RealParameter delta = new RealParameter("50.0");
AddRemoveConversion operator = new AddRemoveConversion();
operator.initByName("weight", 1.0, "acg", acg, "delta", delta, "populationModel", popFunc);
ACGCoalescent coal = new ACGCoalescent();
coal.initByName("tree", acg, "populationModel", popFunc, "rho", rho, "delta", delta);
double logP1 = 0.0;
double logP2 = 0.0;
for (Conversion conv : acg.getConversions(locus)) {
logP1 += operator.getConversionProb(conv);
logP2 += coal.calculateConversionLogP(conv);
}
System.out.println("logP1 = " + logP1);
System.out.println("logP2 = " + logP2);
assertTrue(Math.abs(logP1 - logP2) < 1e-10);
}
use of bacter.model.ACGCoalescent in project bacter by tgvaughan.
the class CustomConnectors method applyRestrictions.
public static void applyRestrictions(BeautiDoc doc) {
for (BEASTInterface p : doc.getPartitions("Tree")) {
ACGLikelihood acgLikelihood = (ACGLikelihood) p;
SimulatedACG acg = (SimulatedACG) ((ACGLikelihood) p).treeInput.get();
ACGCoalescent coalescent = null;
for (BEASTInterface output : acg.getOutputs()) {
if (output instanceof ACGCoalescent) {
coalescent = (ACGCoalescent) output;
break;
}
}
if (coalescent == null)
continue;
acg.setWholeLocusMode(coalescent.wholeLocusConversionsInput.get());
}
}
Aggregations