Define task.ext.args per subworkflow

Hi, I am new around here! :waving_hand:

I am developing a pipeline that uses the nf-core module star_align. According to the code, I can provide extra arguments through the task.ext.args process property. According to the documentation, one way of doing this is to provide them on my modules.config file, for instance:

process {
    withName: 'STAR_ALIGN' {
        ext.args = [
            '--quantMode', 'GeneCounts',
            '--readFilesCommand', 'gunzip -c',
            '--outSAMtype', 'BAM SortedByCoordinate',
        ]
    }
}

This approach, however, provides the same argument for every single execution of the STAR_ALIGN process. My question is: what if I want to execute the STAR_ALIGN process again but with different arguments?

  • Update 1:

Maybe it is worth mentioning that I am calling the STAR_ALIGN multiple times on my pipeline, and every execution is wrapped around its own subworkflow process. So, if there is a way to provide the task.ext.args per subworkflow, it would work.

Hi André

There are two ways in which you might solve this issue:

Option 1 - Full Names
If your example, you’re providing the process name STAR_ALIGN to the withName selector. To differentiate between STAR_ALIGN processes inside different subworkflows, you can use the full qualified name:

process {
    withName: 'MY_SUBWORKFLOW:STAR_ALIGN' {
        ext.args = [
            '--quantMode', 'GeneCounts',
            '--readFilesCommand', 'gunzip -c',
            '--outSAMtype', 'BAM SortedByCoordinate',
        ]
    }
    withName: 'ANOTHER_SUBWORKFLOW:BAR:STAR_ALIGN' {
        ext.args = ['--quantMode', 'TranscriptomeSAM']
    }
}

Option 2 - Uniquely Named Imports
Alternatively, you can import one or more of the STAR_ALIGN processes using a unique name, and use that new name in the withName selector:

include { STAR_ALIGN as STAR_PER_GENE } from './modules/local/star'
include { STAR_ALIGN as STAR_TRANSCRIPTS } from './modules/local/star'

and then

process {
    withName: 'STAR_PER_GENE' {
        ext.args = [
            '--quantMode', 'GeneCounts',
            '--readFilesCommand', 'gunzip -c',
            '--outSAMtype', 'BAM SortedByCoordinate',
        ]
    }
    withName: 'STAR_TRANSCRIPTS' {
        ext.args = ['--quantMode', 'TranscriptomeSAM']
    }
}
3 Likes

Amazing, working as described! Thank you :folded_hands:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.