How should I do:
...
if ($(params.aligner) == "bowtie") {
align_bowtie2(get_fq_info.out.fq_info)
}
else {
align_bwa(get_fq_info.out.fq_info)
}
...
You can move that into your workflow definition. There's an example in the docs of how best to use workflow parameters:
A workflow component can access any variable and parameter defined in the outer scope:
params.data = '/some/data/file' workflow my_pipeline { if( params.data ) bar(params.data) else bar(foo()) }
Your example workflow would look like:
workflow {
fq_info = get_fq_info.out.fq_info
if( params.aligner == "bowtie" ) {
align_bowtie2( fq_info )
}
else {
align_bwa( fq_info )
}
...
}
```
Is this inside the main.nf
file or inside the process.nf
file? Anyway, the param.anything
variable should already be available in the nextflow
context when executed, thus, you could simply do:
if (params.aligner == "bowtie") {
align_bowtie2(get_fq_info.out.fq_info)
} else {
align_bwa(get_fq_info.out.fq_info)
}
Check out this main.nf
of a nextflow pipeline of mine, it contains some working if/else snippets.
Here it is another StackOverflow question on conditional nextflow pipelines that might help.
Hope it helps.