dot-setPattern: Replace a pattern with a new within all parameter files of a...

Description Usage Arguments Author(s) Examples

Description

This function scans all the files within a FATE simulation folder to find a specific pattern and replace it with a new one

Usage

1
2
3
4
5
6
.setPattern(
  name.simulation,
  opt.name.file = NULL,
  pattern.tofind,
  pattern.toreplace
)

Arguments

name.simulation

a string corresponding to the main directory or simulation name of the FATE simulation

opt.name.file

(optional)
a string corresponding to the complete or partial name of the file in which to search and change the pattern

pattern.tofind

a string corresponding to the pattern to find

pattern.toreplace

a string corresponding to the pattern to replace

Author(s)

Maya Guéguen

Examples

 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
## Create a skeleton folder with the default name ('FATE_simulation')
if (dir.exists("FATE_simulation")) unlink("FATE_simulation", recursive = TRUE)
PRE_FATE.skeletonDirectory()

## Create a Global_parameters file
PRE_FATE.params_globalParameters(name.simulation = "FATE_simulation"
                                 , required.no_PFG = 6
                                 , required.no_strata = 5
                                 , required.simul_duration = 100
                                 , required.seeding_duration = c(10,50)
                                 , required.seeding_timestep = 1
                                 , required.seeding_input = 100
                                 , required.max_abund_low = 30000
                                 , required.max_abund_medium = 50000
                                 , required.max_abund_high = 90000)
                                 
                                 
## Change number of PFG
readLines("FATE_simulation/DATA/GLOBAL_PARAMETERS/Global_parameters_V1.txt")

.setPattern(name.simul = "FATE_simulation"
            , opt.name.file = "Global_parameters_V1.txt"
            , pattern.tofind = "NO_PFG 6"
            , pattern.toreplace = "NO_PFG 14")
          
readLines("FATE_simulation/DATA/GLOBAL_PARAMETERS/Global_parameters_V1.txt")


## ----------------------------------------------------------------------------------------- ##
                                
## Load example data

MayaGueguen/RFate documentation built on Oct. 17, 2020, 8:06 a.m.