I have a Nextflow workflow that's like this (reduced):
params.filter_pass = true
// ... more stuff
process concatenate_vcf {
cpus 6
input:
file(vcf_files) from source_vcf.collect()
file(tabix_files) from source_vcf_tbi.collect()
output:
file("assembled.vcf.gz") into decompose_ch
script:
"""
echo ${vcf_files} | tr " " "\n" > vcflist
bcftools merge \
-l vcflist \
-m none \
-f PASS,. \
--threads ${task.cpus} \
-O z \
-o assembled.vcf.gz
rm -f vcflist
"""
}
Now, I want to add the -f PASS,.
part of the command in the script in the bcftools merge
call only if params.filter_pass
is true.
In other words, the script would be executed like this, if params.filter_pass
is true (other lines removed for clarity):
bcftools merge \
-l vcflist \
-m none \
-f PASS,. \
--threads ${task.cpus} \
-O z \
-o assembled.vcf.gz
and if it instead params.filter_pass
is false:
bcftools merge \
-l vcflist \
-m none \
--threads ${task.cpus} \
-O z \
-o assembled.vcf.gz
I know I can use conditional scripts but that would mean replicating the whole script stanza just to change one parameter.
Is this use case possible with Nextflow?