// Minimal example: Conditional simulation with tree sequence recording
initialize() {
initializeMutationRate(0);
initializeMutationType("m1", 0.0, "f", 0.0);// introduced mutation
initializeGenomicElementType("g1", m1, 1.0);
initializeGenomicElement(g1, 0, 99999);
initializeRecombinationRate(1e-8);
initializeTreeSeq();
}
1 early() {
// save this run's identifier, used to save and restore
defineConstant("simID", getSeed());
sim.addSubpop("p1", 500);
}
1000 late() {
// save the state of the simulation
sim.treeSeqOutput(tempdir() + "slim_" + simID + ".trees");
// introduce the sweep mutation
target = sample(p1.genomes, 1);
target.addNewDrawnMutation(m1, 10000);
}
1000:100000 late() {
rInd= sample(p1.individuals, 10);
sim.treeSeqRememberIndividuals(rInd);
if (sim.countOfMutationsOfType(m1) == 0)
{
fixed = (sum(sim.substitutions.mutationType == m1) == 1);
if (fixed)
{
cat(simID + ": FIXED\n");
sim.simulationFinished();
}
else
{
cat(simID + ": LOST at " +sim.cycle+" - RESTARTING\n");
// go back to tick 1000
sim.readFromPopulationFile(tempdir() + "slim_" + simID + ".trees");
// start a newly seeded run
setSeed(rdunif(1, 0, asInteger(2^62) - 1));
// re-introduce the sweep mutation
target = sample(p1.genomes, 1);
target.addNewDrawnMutation(m1, 10000);
}
}
}
--
SLiM forward genetic simulation: http://messerlab.org/slim/
---
You received this message because you are subscribed to the Google Groups "slim-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to slim-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/slim-discuss/e7eb6a08-50da-4d7b-a0ba-8469ce2f3312n%40googlegroups.com.