-
Notifications
You must be signed in to change notification settings - Fork 2
/
initialize.slim
45 lines (41 loc) · 1.46 KB
/
initialize.slim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
initialize() {
if (!exists("JSON_FILE")) {
stop("must define JSON_FILE");
}
if (!exists("DRY_RUN")) {
defineConstant("DRY_RUN", 0);
}
defineConstant("SCALING_FACTOR", 10.0);
defineConstant("MUTATION_RATE", 0);
defineConstant("RECOMBINATION_RATE", 0);
defineConstant("CONTIG_LENGTH", 100);
defineConstant("TREES_FILE", "/tmp/slim_out.trees");
initializeTreeSeq();
initializeMutationRate(SCALING_FACTOR * MUTATION_RATE);
initializeMutationType("m1", 0.5, "f", 0.0);
initializeGenomicElementType("g1", m1, 1.0);
initializeGenomicElement(g1, 0, CONTIG_LENGTH - 1);
initializeRecombinationRate((1 - (1 - 2 * RECOMBINATION_RATE)^SCALING_FACTOR) / 2);
source("demes.slim");
}
1 {
model = demes_load(JSON_FILE, scaling_factor=SCALING_FACTOR, burn_in=10.0);
demes_schedule_events(model);
g_end = model.getValue("end_time");
sim.rescheduleScriptBlock(s1, g_end, g_end);
if (DRY_RUN) {
// Just print out the script blocks that are scheduled and then exit.
for (sb in sortBy(sim.scriptBlocks, "start")) {
if (sb.type != "initialize" & sb != self) {
print_scriptblock(sb);
}
}
sim.scriptBlocks.active = F;
sim.simulationFinished();
}
}
// Output the tree sequence file at the end of the simulation.
s1 late() {
dbg(self); // Print the current script block as it's executed.
sim.treeSeqOutput(TREES_FILE);
}