Skip to content

Commit

Permalink
Make sure sequence length and recombination rate are passed to SLiMgui
Browse files Browse the repository at this point in the history
  • Loading branch information
bodkan committed Oct 8, 2024
1 parent 675835e commit 29951c8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions R/slim.R
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,19 @@ slim <- function(
gsub("required_arg\\(\"PATH\"\\)", sprintf("defineConstant(\"PATH\", \"%s\")", results_path), .) %>%
gsub("optional_arg\\(\"BURNIN_LENGTH\", 0\\)", sprintf("defineConstant(\"BURNIN_LENGTH\", %s)", burnin), .)

# check if the SLiM code was customized by the user
init_start <- grep("default slendr neutral initialization -- start", script_contents)
init_end <- grep("default slendr neutral initialization -- end", script_contents)
if (init_start == init_end - 1) {
script_contents[init_start] <- paste0(
script_contents[init_start], "\n",
"initialize() {\n",
sprintf(" defineConstant(\"SEQUENCE_LENGTH\", %s);", sequence_length), "\n",
sprintf(" defineConstant(\"RECOMBINATION_RATE\", %s);", recombination_rate), "\n",
"}"
)
}

cat(script_contents, file = modif_path, sep = "\n")
system(sprintf("%s %s", binary, modif_path))
} else {
Expand Down

0 comments on commit 29951c8

Please sign in to comment.