diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d3cb5d5e077498a2c198ea7bcb31b90e11fd34bf..0f03c1e8d005b5fc1e09acb1ae22cba62bf93300 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -125,15 +125,22 @@ process fastp { Here `file_id` can be anything from a simple identifier to a list of several variables. In which case the first item of the List should be usable as a file prefix. So you have to keep that in mind if you want to use it to define output file names (you can test for that with `file_id instanceof List`). +In some case, the `file_id` may be a Map to have a cleaner access to the `file_id` content by explicit keywords. If you want to use information within the `file_id` to name outputs in your `script` section, you can use the following snipet: ```Groovy script: - if (file_id instanceof List){ - file_prefix = file_id[0] - } else { - file_prefix = file_id + switch(file_id) { + case {it instanceof List}: + file_prefix = file_id[0] + break + case {it instanceof Map}: + file_prefix = file_id.values()[0] + break + default: + file_id + break } ``` diff --git a/src/nf_modules/bowtie2/main.nf b/src/nf_modules/bowtie2/main.nf index 2b0cf96320902da5aa8c78004c06f5db7de25939..20f66eb195bc4bf8e4ff581fc8cc872b340880cb 100644 --- a/src/nf_modules/bowtie2/main.nf +++ b/src/nf_modules/bowtie2/main.nf @@ -56,10 +56,16 @@ process mapping_fastq { index_id = ( index_file =~ /(.*)\.1\.bt2/)[0][1] } } - if (file_id instanceof List){ - file_prefix = file_id[0] - } else { - file_prefix = file_id + switch(file_id) { + case {it instanceof List}: + file_prefix = file_id[0] + break + case {it instanceof Map}: + file_prefix = file_id.values()[0] + break + default: + file_id + break } if (reads.size() == 2)