Chapter 4: Generating boilerplate files

This chapter explains how to generate an nf-core module template and what each file contains.

Preparation

Fork and clone the nf-core/modules GitHub repository to your working environment, then create a new branch for your module:

git switch master ## ensure you have the latest state of the repository
git switch -c <MY_NEW_MODULE_BRANCH>

Generate the boilerplate files

From the root of the repository, run:

nf-core modules create <toolname>/<subcommand>

Naming conventions

  • All parts of the module name must be lowercase, alphanumeric, with no punctuation or special characters.
  • Single-command tools use the tool name only. For a tool executed with fastp -i <input> -o <output>, run nf-core modules create fastp.
  • Tools with subcommands use <tool>/<subcommand>, even if you only plan to wrap one subcommand. For samtools view, run nf-core modules create samtools/view.
  • For a third level of subcommand, append it to the subcommand name. For samtools view flagstats, run nf-core modules create samtools/viewflagstat.

For example, to create a module for the tool drep with the subcommand compare:

nf-core modules create drep/compare

Prompts from nf-core modules create

The command tries to pre-fill the boilerplate. It searches Bioconda and biocontainers for the latest version of your tool and adds the container definitions automatically.

You will then be prompted for:

  • Your GitHub username.
  • A process resource label. These standardised tags map to default memory, CPU, and wall time. Choose the label that best matches your tool’s typical requirements. The defaults for each label are defined in the pipeline template base.config. Pipelines can override these values.
  • Whether the module should use a meta map. Answer yes in most cases. Meta maps carry sample metadata alongside files, which pipelines use to drive downstream processing decisions.
Tip

You can pass any of these values as command-line flags to skip the prompts.

Output

After the command completes, you will see the following files and directories:

modules/nf-core/drep/compare/
├── environment.yml
├── main.nf
├── meta.yml
└── tests
    └── main.nf.test

If you later create a second subcommand (dereplicate), the directory structure becomes:

modules/nf-core/drep/
├── compare
│   ├── environment.yml
│   ├── main.nf
│   ├── meta.yml
│   └── tests
│       └── main.nf.test
└── dereplicate
    ├── environment.yml
    ├── main.nf
    ├── meta.yml
    └── tests
        └── main.nf.test

The next chapter walks through each generated file and explains what to change.