This function print the equivalent `slimr` code to the console where it can easily be copied and pasted into an R script.

as_slimr_code(code_txt)

Arguments

code_txt

SLiM code as a character vector.

Value

`slimr` code as a character vector, invisibly

Examples

as_slimr_code(slim_recipes$`5.3.4`)
#> slim_script(
#> 
#>     slim_block(initialize(),  {
#>         initializeMutationRate(1e-07)
#>         initializeMutationType("m1", 0.5, "f", asFloat(0))
#>         initializeMutationType("m2", 0.5, "f", 0.3)
#>         initializeGenomicElementType("g1", m1, asFloat(1))
#>         initializeGenomicElement(g1, 0, 99999)
#>         initializeRecombinationRate(1e-08)
#>     }),
#> 
#>     slim_block(1, late(),  {
#>         mSide = 10
#>         for (i in 1:(mSide * mSide)) sim.addSubpop(i, 500)
#>         subpops = sim.subpopulations
#>         for (x in 1:mSide) for (y in 1:mSide) {
#>             destID = (x - 1) + (y - 1) * mSide + 1
#>             ds = subpops[destID - 1]
#>             if (x > 1) ds.setMigrationRates(destID - 1, runif(1, asFloat(0), 0.05))
#>             if (x < mSide) ds.setMigrationRates(destID + 1, runif(1, asFloat(0), 0.05))
#>             if (y > 1) ds.setMigrationRates(destID - mSide, runif(1, asFloat(0), 0.05))
#>             if (y < mSide) ds.setMigrationRates(destID + mSide, runif(1, asFloat(0), 0.05))
#>             xd = ((x - 1)/(mSide - 1)) * 0.9 + 0.05
#>             yd = ((y - 1)/(mSide - 1)) * 0.9 + 0.05
#>             ds.configureDisplay(c(xd, yd), 0.4)
#>         }
#>         subpops[sample(0:99, 25)] %.% setSubpopulationSize(0)
#>         target_subpop = sample(sim.subpopulations, 1)
#>         sample(target_subpop.genomes, 10) %.% addNewDrawnMutation(m2, 20000)
#>     }),
#> 
#>     slim_block(10000, late(),  {
#>         sim.outputFixedMutations()
#>     })
#> )