Is it possible to create a variable in a process whose scope is bounded by that process? #4261
-
Hello, I have an example process (defined below), and it works correctly. e.g., I would like to make the variable I would appreciate any input on best practices for addressing this type of challenge. Thanks! //THIS WORKS
process FASTQC_SINGLE {
tag "FASTQC on ${reads.getName().split("\\.")[0]}"
container 'fastqc-multiqc:1.0.1'
publishDir params.outdir, mode:'copy'
input:
path reads
output:
path "fastqc_${reads.getName().split("\\.")[0]}_logs"
script:
def file_name_prefix = reads.getName().split("\\.")[0]
"""
mkdir fastqc_${file_name_prefix}_logs
fastqc -o fastqc_${file_name_prefix}_logs -f fastq -q ${reads}
"""
} //THIS DOES NOT WORK (BUT READS BETTER)
process FASTQC_SINGLE {
tag "FASTQC on ${file_name_prefix}"
container 'fastqc-multiqc:1.0.1'
publishDir params.outdir, mode:'copy'
input:
path reads
def file_name_prefix = reads.getName().split("\\.")[0]
output:
path "fastqc_${file_name_prefix}_logs"
script:
"""
mkdir fastqc_${file_name_prefix}_logs
fastqc -o fastqc_${file_name_prefix}_logs -f fastq -q ${reads}
"""
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
As far as I know, it is not possible to declare a local variable that is accessible to directives and outputs. But, the process syntax has a lot of grey area and there might be some hack that works. I would love to be proven wrong and turn it into a best practice 😄 |
Beta Was this translation helpful? Give feedback.
-
The correct syntax is the first one. |
Beta Was this translation helpful? Give feedback.
As far as I know, it is not possible to declare a local variable that is accessible to directives and outputs. But, the process syntax has a lot of grey area and there might be some hack that works. I would love to be proven wrong and turn it into a best practice 😄