-
Notifications
You must be signed in to change notification settings - Fork 717
Closed
Description
I was thinking to make a module to use with a yaml parser, and thought a closure might be a way to provide configurable data structure checking, but it appears to prevent using -resume
.
CSV Example:
test.csv
:
message,file
hello,hello.txt
world,world.txt
main.nf
:
#! /usr/bin/env nextflow
nextflow.enable.dsl = 2
params.samplesheet = ''
params.csv_transform = {
csvfile -> csvfile.splitCsv(
header: ['message', 'file'], skip: 1
)
.collect {
// Do whatever validations and transformations here.
record -> [ record.message, file(record.file) ]
}
}
workflow {
CHECK_INPUTCSV (
Channel.fromPath( params.samplesheet ),
Channel.value( params.csv_transform )
)
WRITE_MESSAGE ( CHECK_INPUTCSV.out.flatMap() )
}
process CHECK_INPUTCSV { // reusable module to validate files
input:
path csv_file
val validate_csv
output:
val result
exec:
result = validate_csv.call(csv_file)
}
process WRITE_MESSAGE {
input:
tuple val(message), path(filename)
output:
path(filename)
script:
"""
echo "$message" > $filename
"""
}
output:
$ nextflow run main.nf --samplesheet test.csv
N E X T F L O W ~ version 21.10.6
Launching `main.nf` [insane_heisenberg] - revision: f0e983da63
executor > local (3)
[96/6324c4] process > CHECK_INPUTCSV (1) [100%] 1 of 1 ✔
[50/072495] process > WRITE_MESSAGE (2) [100%] 2 of 2 ✔
WARN: Cannot serialize context map. Cause: null -- Resume will not work on this process
I guess it's better to just code the validation into the workflow, but I was curious if closures were ok as process input too.
Metadata
Metadata
Assignees
Labels
No labels