writeTargets: Write updated targets out to file from 'SYSargsList'

View source: R/sysargslist_utilities.R

writeTargetsR Documentation

Write updated targets out to file from SYSargsList

Description

Convenience write function for generating targets files containing the paths to files generated by input processes. These processes can be commandline- or R-based software. Typically, the paths to the inputs are stored in the targets infile targetsWF(sysargs) for SYSargsList objects. Note: by default the function cannot overwrite any existing files. If a file exists then the user has to explicitly remove it or set overwrite=TRUE.

Usage

writeTargets(sysargs, step, file = "default", silent = FALSE, overwrite = FALSE)

Arguments

sysargs

Object of class SYSargsList.

step

character with the step name. To check all the names, please use stepName(sysargs).

file

Name and path of the output file. If set to "default" then the name of the output file will have the pattern 'targets_<stepName>.txt'.

silent

If set to TRUE, all messages returned by the function will be suppressed.

overwrite

If set to TRUE, existing files of same name will be overwritten.

Value

Writes tabular targes files containing the header/comment lines from stepsWF(sysargs)[[step]][["targetsheader"]] and the columns from targetsWF(sysargs)[[step]].

Author(s)

Daniela Cassol

Examples

## Construct SYSargsList object from Rmd file
sal <- SPRproject(overwrite=TRUE)
targetspath <- system.file("extdata/cwl/example/targets_example.txt", package="systemPipeR")

## Constructor and `appendStep<-`
appendStep(sal) <- SYSargsList(step_name = "echo", 
                               targets=targetspath, dir=TRUE,
                               wf_file="example/workflow_example.cwl", input_file="example/example.yml", 
                               dir_path = system.file("extdata/cwl", package="systemPipeR"),
                               inputvars = c(Message = "_STRING_", SampleName = "_SAMPLE_"))
appendStep(sal) <- LineWise(code = {
                            hello <- lapply(getColumn(sal, step=1, 'outfiles'), function(x) yaml::read_yaml(x))
                            }, 
                            step_name = "R_read", 
                            dependency = "echo")
writeTargets(sal, "echo")

tgirke/systemPipeR documentation built on Sept. 24, 2024, 9:48 a.m.