run_bam: Run bam model

View source: R/run_bam.R

run_bamR Documentation

Run bam model

Description

Creates a folder in a directory dir_bam to write BAM files including model-specific files (.dat, .tpl, and .cxx) a standard admb2r.cpp file stored in bamExtras, and a standard but customizable cleanup.bat file. Model-specific files are supplied by the user in any one of several different ways (see Arguments). It temporarily changes the working directory to dir_bam then calls a shell script to run the BAM model, and changes the working directory back to the previous path. The function invisibly returns the bam file objects (indicated by return_obj) in a list.

Usage

run_bam(
  CommonName = NULL,
  fileName = "bam",
  dir_bam = NULL,
  bam = NULL,
  dat_file = NULL,
  tpl_file = NULL,
  cxx_file = NULL,
  dat_obj = NULL,
  tpl_obj = NULL,
  cxx_obj = NULL,
  standardize = TRUE,
  subset_rdat = list(eq.series = 101, pr.series = 101),
  unlink_dir_bam = TRUE,
  admb_options = "-nox",
  admb2r_obj = admb2r.cpp,
  cleanup = list(del = c("*.r0*", "*.p0*", "*.b0*", "*.log", "*.rpt", "*.obj", "*.htp",
    "*.eva", "*.bar", "*.tds", "*.o", "tmp_admb", "variance", "*.dep", "*.hes", "*.tmp")),
  return_obj = "rdat"
)

Arguments

CommonName

Common name of species associated with dat, tpl, and cxx files

fileName

Name given to BAM files, not including file extensions.

dir_bam

Name of directory to write BAM files to, relative to the working directory.

bam

Output of bam2r.

dat_file

dat file path

tpl_file

tpl file path

cxx_file

cxx file path

dat_obj

dat file read in as a character vector with readLines(con=dat_file)

tpl_obj

tpl file read in as a character vector with readLines(con=tpl_file)

cxx_obj

cxx file read in as a character vector with readLines(con=cxx_file)

standardize

Should standardize_bam be run by the function before running the BAM

subset_rdat

list of rdat objects to subset and number of values to retain. This option can substantially decrease rdat file size, without affecting precision of reference point calculations.

unlink_dir_bam

Should dir_bam be deleted after this function is run?

admb_options

Character string pasted to fileName to build run_command when running BAM with shell(run_command). See ADMB reference card for more options. (i.e. run_command <- paste(fileName, admb_options))

admb2r_obj

Character string containing admb2r C++ code, which is written with base::writeLines to dir_bam

cleanup

List object written to cleanup.bat file in dir_bam.

return_obj

objects to return from the function. May include one or more of the following "dat", "tpl", "cxx", "rdat". character vector.

Value

See return_obj

Examples

## Not run: 
Run a bam model and assign rdat output to object
rdat_AtMe <- run_bam("AtlanticMenhaden")$rdat
rdat_BlSB <- run_bam("BlackSeaBass")$rdat
rdat_BlTi <- run_bam("BluelineTilefish")$rdat
rdat_Cobi <- run_bam("Cobia")$rdat
rdat_GagG <- run_bam("GagGrouper")$rdat
rdat_GrTr <- run_bam("GrayTriggerfish")$rdat
rdat_GrAm <- run_bam("GreaterAmberjack")$rdat
rdat_ReGr <- run_bam("RedGrouper")$rdat
rdat_RePo <- run_bam("RedPorgy")$rdat
rdat_ReSn <- run_bam("RedSnapper")$rdat
rdat_ScGr <- run_bam("ScampGrouper")$rdat
rdat_SnGr <- run_bam("SnowyGrouper")$rdat
rdat_Tile <- run_bam("Tilefish")$rdat
rdat_VeSn <- run_bam("VermilionSnapper")$rdat


## End(Not run)

nikolaifish/bamExtras documentation built on July 21, 2023, 8:26 a.m.