Hi everyone, I would like to write a Nextflow pipe...
# nostupidquestions
a
Hi everyone, I would like to write a Nextflow pipeline that calls
modules/nf-core/samtools/view
twice: - The 1st time within some subworkflow, using parameters, e.g.,
-F 2304
- The 2nd time within a different subworkflow, using parameters, e.g.,
-f 2304
However, I cannot configure the module to use either parameters, because I cannot scope process configurations to a specific subworkflow. If I extended my global
nextflow.config
with
Copy code
process {
    withName: 'SAMTOOLS_VIEW' {
        ext.args   = { "-F 2304" }
    }
}
then
samtools view
always runs with the
-F 2304
argument. What's the Nextflow way of achieving this? Shall I patch
modules/nf-core/samtools/view
?
m
Copy code
include { SAMTOOLS_VIEW as SAMTOOLS_VIEW_1                   } from '../../modules/nf-core/samtools/view'
include { SAMTOOLS_VIEW as SAMTOOLS_VIEW_2                   } from '../../modules/nf-core/samtools/view'
Copy code
process {
    withName: 'SAMTOOLS_VIEW_1' {
        ext.args   = { "-F 2304" }
    }
    withName: 'SAMTOOLS_VIEW_2' {
        ext.args   = { "-f 2304" }
    }
}
But I would do this only when using samtools view twice in the same subworkflow
in your case I would do something more like
Copy code
process {
    withName: '.*:SUBWORKFLOW1:SAMTOOLS_VIEW' {
        ext.args   = { "-F 2304" }
    }
    withName: '*:SUBWORKFLOW2:AMTOOLS_VIEW' {
        ext.args   = { "-f 2304" }
    }
}
much simpler
a
Ah, I forgot that I can include modules
as
. Your second solution looks great for my use case, thank you @Maxime Garcia 🙂
m
Yeah I figured both so solution might be a good fit