Hi all - is it possible to provide args for a give...
# help
m
Hi all - is it possible to provide args for a given process at the workflow level? i.e. workflow level injection to overwrite module level
def args = task.ext.args ?: ''
for example, something similar to:
Copy code
include { RASUSA as LONG_RASUSA  } from '../../../modules/nf-core/rasusa'

workflow DOWNSAMPLING {

    take:
    long_reads_ch // channel: [ val(meta), long_reads ]

    main:

    LONG_RASUSA (
            long_reads_ch,
            100,
            args: "--seed 1"
        )
or
Copy code
include { RASUSA as LONG_RASUSA  } from '../../../modules/nf-core/rasusa'

def long_rasusa.ext.args = "--seed 1"

workflow DOWNSAMPLING {

    take:
    long_reads_ch // channel: [ val(meta), long_reads ]

    main:

    LONG_RASUSA (
            long_reads_ch,
            100
        )
I want to avoid using
conf/modules.config
or modifying/patching the underlying module
i
Is there any reason why you want to avoid
modules.config
? It is the file meant for this specific use
m
Because I want to create subworkflows that are preconfigured, portable and installable via nf-core tools without having to aggregate different sets of modules.jsons I am collaboratively building a set of large and complex pipelines. In effect, these pipelines will be aggregations of a mix of subworkflows. The necessity for this approach is largely borne of there not currently being a particularly clean way to run metapipelines (pipelines of pipelines) modules.json are a pipeline level argument injection file - I want a method of subworkflow level argument injection
If I were building a single pipeline I would just use the
modules.config
, but I want to maximise subworkflow portability, and not every nf-core *module*** is fit for my needs. Patching of modules is also a pipeline level function. I also don't want to clone modules for a given subworkflow to add a single argument
i
Subworkflows, got it. The way it is resolved in the nf-core components repository is to store each subworkflow in a separate directory that contains a connected
nextflow.config
included inside the subworkflow file. Cf. documentation here.
m
So subworkflow configs can inject module-level arguments similar to
modules.config?
Ah, yes sorry, I meant subworkflows, but as subworkflows have a
workflow
directive at the start I have added confusion in my choice of language 😛
OK fab
looks like subworkflows
nextflow.config
can indeed inject similarly to
modules.config
at the pipeline level
👀 1
thanks for your response @Igor Trujnara I appreciate it
a
But this is specifically for
nf-test
. I don't see how that would work for your actual pipeline subworkflow invokation.
m
I screenshotted more than I needed to there - the bit that I was capturing is the (subworkflow)
nextflow.config
including module level arguments in the same fashion as a
modules.config
In the example there, they are presumably being inherited from
modules.config
, but I presume they could just as easily be defined there rather than inherited
@Alexander Nater
a
Basically, you would have to manually add an
includeConfig
for every imported subworkflow to your main
nextflow.config
.
m
Ah yeah you would still have to aggregate all of the subworkflow configs
🥴
Copy code
process {
  withName: 'MODULEA' {
    ext.args = "--arg1 abc"
  }
}
Can you just add that atop the subworkflow I wonder
Copy code
include { RASUSA as LONG_RASUSA  } from '../../../modules/nf-core/rasusa'

process {
  withName: 'LONG_RASUSA' {
    ext.args = "--seed 1"
  }
}

workflow DOWNSAMPLING {

    take:
    long_reads_ch // channel: [ val(meta), long_reads ]

    main:

    LONG_RASUSA (
            long_reads_ch,
            100
        )
nop
Copy code
ERROR ~ Module compilation error
- file : /mnt/blockvolume/readqc/subworkflows/local/downsampling/main.nf
- cause: Process definition syntax error -- A string identifier must be provided after the `process` keyword @ line 4, column 8.
   process {
          ^

1 error


 -- Check script 'workflows/readqc.nf' at line: 11 or see '.nextflow.log' file for more details
a
I don't think you can add config blocks like this.
👍 1
m
I am also not sure that if you import a subworkflow config that the config is scoped to that subworkflow. i.e. if two different subworkflows use the same process name, the
ext.args
likely become global (and potentially clash) after being included in the top level config via
includeConfig
a
You can use name selectors including the workflow name to avoid this.
m
include { RASUSA as LONG_RASUSA } from '../../../modules/nf-core/rasusa' Do you mean like using (in the
nextflow.config
)
Copy code
process {
  withName: 'LONG_RASUSA' {
    ext.args = "--seed 1"
  }
}
instead of
Copy code
process {
  withName: 'RASUSA' {
    ext.args = "--seed 1"
  }
}
Copy code
include { RASUSA as SHORT_RASUSA  } from '../../../modules/nf-core/rasusa' 
include { RASUSA as LONG_RASUSA  } from '../../../modules/nf-core/rasusa'
or do you mean using the workflow name as in
Copy code
workflow DOWNSAMPLING {
a
I mean:
Copy code
process {
  withName: 'DOWNSAMPLING:LONG_RASUSA' {
    ext.args = "--seed 1"
  }
}
m
Ah gotcha
that makes sense
a
Sorry, typo, should be workflowname:process name of course.
👍 1
m
Well it seems thats the best available solution
thanks for taking the time @Alexander Nater 🙏
a
I don’t think there is really a good way to get around doing this by needing to wire up the subworkflow configs right now. (I know Ben was keen to try and move away from
task.ext.args
but not sure if a better solution has emerged yet). Given that a user of a subworkflow has to manually
include
the actual subworkflow I have never considered it particularly onerous that they should need to also
include
an associated config file. Something I would not though, is that I don’t think Alexander’s example will work quite as expected. AFAIK Nextflow expects process name selectors to be either the process name alone (no
:
), or to match the fully qualified name. If
DOWNSAMPLING
is intended to be used as a subworkflow to be included in other workflows then the fully qualified name may not match
DOWNSAMPLING:LONG_RASUSA
. Instead you should pattern match on the subworkflow name:
Copy code
process {
  withName: '(.*:)?DOWNSAMPLING:LONG_RASUSA' {
    ext.args = "--seed 1"
  }
}
This will then allow the config to match e.g.
MYPIPELINE:DOWNSAMPLING:LONG_RASUSA
Unfortunately this does not work if someone includes a subworkflow under an alias. e.g.
Copy code
include { DOWNSAMPLING as DS } from '../downsampling.nf'
This differs from the historic behaviour of processes where the config would be applied if it matched the original name as well as if it matched the alias.
m
Thanks for the detailed response, arthur - didn't know you could use that syntax upstream of the selector Very helpful info!