|
1 | 1 | # Part 4: Make an nf-core module |
2 | 2 |
|
3 | | -In this fourth part of the Hello nf-core training course, we show you how to create an nf-core module by learning the key conventions that make modules portable and maintainable. |
| 3 | +In this fourth part of the Hello nf-core training course, we show you how to create an nf-core module by applying the key conventions that make modules portable and maintainable. |
4 | 4 |
|
5 | 5 | The nf-core project provides a command (`nf-core modules create`) that generates properly structured module templates automatically. |
6 | | -However, for teaching purposes, we're going to **learn by doing**: transforming the local `cowpy` module in your `core-hello` pipeline into an nf-core-style module step-by-step. |
7 | | -This hands-on approach will help you understand the patterns deeply, making you better equipped to work with nf-core modules in practice. |
| 6 | +However, for teaching purposes, we're going to start by doing it manually: transforming the local `cowpy` module in your `core-hello` pipeline into an nf-core-style module step-by-step. |
| 7 | +After that, we'll show you how to use the template-based module creation to work more efficiently in the future. |
8 | 8 |
|
9 | 9 | We'll apply three essential nf-core patterns incrementally: |
10 | 10 |
|
11 | 11 | 1. **Metadata tuples**: Accept and propagate sample metadata through the workflow |
12 | | -2. **`ext.args`**: Simplify the module interface by handling optional arguments via configuration |
| 12 | +2. **`ext.args`**: Keep the module interface minimal by handling optional tool arguments via configuration rather than as inputs |
13 | 13 | 3. **`ext.prefix`**: Standardize output file naming with configurable prefixes |
14 | 14 |
|
15 | 15 | Once you understand these patterns, we'll show you how to use the official nf-core tooling to create modules efficiently. |
@@ -164,15 +164,20 @@ executor > local (8) |
164 | 164 |
|
165 | 165 | Now let's address another nf-core pattern: simplifying module interfaces by using `ext.args` for optional command-line arguments. |
166 | 166 |
|
167 | | -Currently, our `cowpy` module requires the `character` parameter to be passed as a separate input. While this works, nf-core modules use a different approach for **tool configuration arguments**: instead of adding input parameters for every tool option, they use `ext.args` to pass these via configuration. This keeps the module interface focused on essential data (files, metadata, and any mandatory per-sample parameters), while tool configuration options are handled through `ext.args`. |
| 167 | +Currently, our `cowpy` module requires the `character` parameter to be passed as an input via the process `input:` block. |
| 168 | +This works, but it forces us to provide a value for `character` every time we call the process, even if we're happy with a default. |
| 169 | +For tools with many optional parameters, having to provide values for all of them gets annoying fast. |
| 170 | + |
| 171 | +nf-core modules use a different approach for **tool configuration arguments**: instead of declaring inputs for every tool option, they use `ext.args` to pass these via configuration. |
| 172 | +This keeps the module interface focused on essential data (files, metadata, and any mandatory per-sample parameters), while tool configuration options are handled through `ext.args`. |
168 | 173 |
|
169 | 174 | #### 1.2.1. Understanding ext.args |
170 | 175 |
|
171 | | -The `task.ext.args` pattern is an nf-core convention for passing command-line arguments to tools through configuration rather than as process inputs. Instead of adding input parameters for tool options, nf-core modules accept arguments through the `ext.args` configuration directive. |
| 176 | +The `task.ext.args` pattern is an nf-core convention for passing command-line arguments to tools through configuration rather than as process inputs. |
172 | 177 |
|
173 | | -!!! note "ext.args can be dynamic" |
| 178 | +!!! note "ext.args can do more" |
174 | 179 |
|
175 | | - While `ext.args` is configured outside the module, it can access metadata to provide sample-specific values using closures. For example: `ext.args = { meta.single_end ? '--single' : '--paired' }` |
| 180 | + The `ext.args` system has powerful additional capabilities not covered here, including switching argument values dynamically based on metadata. See the [nf-core module specifications](https://nf-co.re/docs/guidelines/components/modules) for more details. |
176 | 181 |
|
177 | 182 | Benefits of this approach: |
178 | 183 |
|
|
0 commit comments