Update modules to use topic channels
In this tutorial, we will go through the steps needed to update existing nf-core modules to use the new topic channels feature for version outputs. This will be the main way to update most modules, the only exceptions being modules that use template scripts. Take a look at the template migration chapter for more information on how to update those modules.
Prerequisites
- nf-core tools version 3.5.0 or higher
- A clone of the
nf-core/modulesrepository - Nextflow version 25.04.0 or higher
Updating standard modules
To update a module to use topic channels for version outputs:
-
Open the modules
main.nffile. -
Identify the code that looks similar to the following:
main.nf cat <<-END_VERSIONS > versions.yml "${task.process}": <tool1>: \$(tool1 --version) <tool2>: \$(tool2 --version) END_VERSIONS -
Remove the
versions.ymlfile from theoutputblock. -
Add the following outputs for each tool in the module:
tuple val("${task.process}"), val('<tool1>'), eval('tool1 --version'), emit: versions_tool1, topic: versionsUpdate
<tool1>andtool1 --versionwith the tool name and version command. Repeat this for each tool used in the module. -
Run
nf-core modules lint <module_name> --fixto automatically update themeta.ymlfile with the new topic outputs. -
Add a
typeanddescriptionfield for each field in the versions output. Use the following template:meta.yml versions_<tool>: - - ${task.process}: type: string description: The process the versions were collected from - <tool>: type: string description: The tool name - <versions_command>: type: string description: The version of the toolUpdate
<tool>,<versions_command>to the output channel values. -
Add the topics block to the
meta.ymlfile. Ideally, underneath the outputs section:
topics:
- versions:
- - process:
type: string
description: The process the versions were collected from
- tool:
type: string
description: The tool name
- version:
type: string
description: The version of the tool- Update the
main.nf.testfile to check for the new version outputs.
- If the test runs on all process output (
snapshot(process.out).match()), do nothing. - If the test checks for specific outputs, update it to check for the new version outputs.
process.out.versionsshould be changed toprocess.out.findAll { key, val -> key.startsWith('versions') }.
-
Run the tests to regenerate the snapshots:
nf-core modules test <module_name> --update -
Check that the snapshot is correct and that all versions are being captured correctly. If not, return to step 3 and update any incorrect information in the module.
-
Commit and push your changes to your fork.
-
Open a pull request to the main
nf-core/modulesrepository.
Template migration
Modules that use template scripts for version outputs will need to be updated slightly differently:
-
Open the modules
main.nffile. -
Update the
path "versions.yml", emit: versionsline to the following:main.nf path "versions.yml", emit: versions, topic: versions -
Add the following lines to the
meta.ymlfile underneath the outputs section:meta.yml versions: - versions.yml: type: file description: YAML file containing versions of tools used in the module -
Commit and push your changes to your fork.
-
Open a pull request to the main
nf-core/modulesrepository.