|
| 1 | +--- |
| 2 | +title: "Chapter 3: What is an nf-core module?" |
| 3 | +subtitle: "What defines an nf-core module" |
| 4 | +shortTitle: "Chapter 3: What is a module?" |
| 5 | +--- |
| 6 | + |
| 7 | +An nf-core module is an opinionated, open-source Nextflow wrapper around a single command-line tool or script. The [central community repository](https://github.com/nf-core/modules) holds more than [1800 modules](https://nf-co.re/modules) that you can reuse in your own pipelines. |
| 8 | + |
| 9 | +This page describes what an nf-core module is and what distinguishes it from a standard Nextflow process. |
| 10 | + |
| 11 | +## Contents of an nf-core module |
| 12 | + |
| 13 | +An nf-core module usually wraps one tool command, or one tool with a single subcommand. |
| 14 | + |
| 15 | +:::info{collapse title="Comparison with Nextflow modules"} |
| 16 | +A Nextflow process or module has no restrictions on the number of tools or subcommands it can execute. |
| 17 | + |
| 18 | +An nf-core module aims for a single analysis command per module. |
| 19 | +This atomic design supports lego-block construction of pipelines and makes modules easier to understand, share, and test, although it is not always the most resource-efficient approach. |
| 20 | +::: |
| 21 | + |
| 22 | +Each nf-core module follows strict [specifications](../../../specifications/components/overview) agreed by community consensus. The specifications cover: |
| 23 | + |
| 24 | +- [Naming](../../../specifications/components/modules/naming-conventions) and [formatting](../../../specifications/components/modules/formatting) conventions. |
| 25 | +- [Software environments](../../../specifications/components/modules/software-requirements). |
| 26 | +- [Standardised tags](../../../specifications/components/modules/testing#tags). |
| 27 | +- [Input and output channels](../../../specifications/components/modules/input-output-options). |
| 28 | +- [Tool parameters](../../../specifications/components/modules/module-parameters) configurable by pipeline developers. |
| 29 | +- Use of [meta maps](../../../specifications/components/modules/general#use-of-meta-maps). |
| 30 | +- Use of [stubs](../../../specifications/components/modules/general#stubs). |
| 31 | + |
| 32 | +The specifications also expand the minimum required single file from a single Nextflow `.nf` script to five required files. |
| 33 | +This reflects the nf-core focus on standardisation, reproducibility, and high-quality documentation. |
| 34 | + |
| 35 | +A complete nf-core module directory can contain up to six files: |
| 36 | + |
| 37 | +```tree |
| 38 | +├── environment.yml |
| 39 | +├── main.nf |
| 40 | +├── meta.yml |
| 41 | +└── tests/ |
| 42 | + ├── main.nf.test |
| 43 | + ├── main.nf.test.snap |
| 44 | + └── nextflow.config ## optional! |
| 45 | +``` |
| 46 | + |
| 47 | +These files fall into three categories: |
| 48 | + |
| 49 | +- Module execution |
| 50 | +- Module documentation |
| 51 | +- Module testing |
| 52 | + |
| 53 | +The following diagram shows how these files relate to each other: |
| 54 | + |
| 55 | +<img width=80% alt="Diagram showing how the execution, documentation, and testing files in an nf-core module relate to each other." src="/images/developing/tutorials/writing-nfcore-modules/nf-core-module-file-relationship.png"> |
| 56 | + |
| 57 | +_Schematic diagram showing the relationship between the three main categories of files in an nf-core module._ |
| 58 | + |
| 59 | +- `main.nf` defines the Nextflow process that the module executes. |
| 60 | +- `environment.yml` is a Conda environment file loaded by `main.nf`. It specifies the software dependencies used when a pipeline runs with `-profile conda`. |
| 61 | +- `meta.yml` documents the contents of `main.nf`, including tool metadata and input and output specifications. |
| 62 | +- `main.nf.test` describes an nf-test unit test for the `main.nf` process. |
| 63 | +- `main.nf.test.snap` is a snapshot file generated by nf-test. It compares the output of one test run with another to confirm reproducibility. |
| 64 | +- `nextflow.config` is an optional Nextflow configuration file used when `main.nf.test` executes. |
| 65 | + |
| 66 | +Writing an nf-core module means creating these files and populating them with content that follows the nf-core specifications. |
| 67 | + |
| 68 | +The [next chapter](./4-boilerplate) goes into more detail about the contents of each file. |
0 commit comments