Skip to content

Commit 4e25b43

Browse files
Update yfs to use outputs
Signed-off-by: Christopher Hakkaart <chris.hakkaart@seqera.io>
1 parent 2db01e6 commit 4e25b43

File tree

1 file changed

+42
-18
lines changed

1 file changed

+42
-18
lines changed

docs/your-first-script.md

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This guide details fundamental skills to run a basic Nextflow pipeline. It inclu
1212

1313
You will need the following to get started:
1414

15-
- Nextflow: See {ref}`install-page` for installation instructions.
15+
- Nextflow version 25.10 or later. See {ref}`install-page` for installation instructions. If you have an older version, see {ref}`updating-nextflow` to update.
1616

1717
## Run a pipeline
1818

@@ -25,11 +25,9 @@ params.str = "Hello world!"
2525
2626
// split process
2727
process split {
28-
publishDir "results/lower"
29-
3028
input:
3129
val x
32-
30+
3331
output:
3432
path 'chunk_*'
3533
@@ -41,7 +39,6 @@ process split {
4139
4240
// convert_to_upper process
4341
process convert_to_upper {
44-
publishDir "results/upper"
4542
tag "$y"
4643
4744
input:
@@ -58,9 +55,23 @@ process convert_to_upper {
5855
5956
// Workflow block
6057
workflow {
61-
ch_str = channel.of(params.str) // Create a channel using parameter input
62-
ch_chunks = split(ch_str) // Split string into chunks and create a named channel
63-
convert_to_upper(ch_chunks.flatten()) // Convert lowercase letters to uppercase letters
58+
main:
59+
ch_str = channel.of(params.str) // Create a channel using parameter input
60+
ch_chunks = split(ch_str) // Split string into chunks and create a named channel
61+
ch_upper = convert_to_upper(ch_chunks.flatten()) // Convert lowercase letters to uppercase letters
62+
63+
publish:
64+
lower = ch_chunks.flatten()
65+
upper = ch_upper
66+
}
67+
68+
output {
69+
lower {
70+
path 'lower'
71+
}
72+
upper {
73+
path 'upper'
74+
}
6475
}
6576
```
6677

@@ -71,12 +82,17 @@ This script defines two processes:
7182

7283
The `split` output is emitted as a single element. The `flatten` operator splits this combined element so that each file is treated as a sole element.
7384

74-
The outputs from both processes are published in subdirectories (`lower` and `upper`) in the `results` directory.
85+
The workflow block is organized into two sections:
86+
87+
- `main:`: defines the workflow logic and how processes are connected via channels
88+
- `publish:`: declares which channels should be published as workflow outputs
89+
90+
The `output` block (outside the workflow) defines where and how each output should be published. In this example, the outputs from both processes are published in subdirectories (`lower` and `upper`) in the default `results` out directory.
7591

7692
To run your pipeline:
7793

78-
1. Create a new file named `main.nf` in your current directory
79-
2. Copy and save the above pipeline to your new file
94+
1. Create a new file named `main.nf` in your current directory.
95+
2. Copy and save the above pipeline to your new file.
8096
3. Run your pipeline using the following command:
8197

8298
```{code-block}
@@ -87,7 +103,7 @@ To run your pipeline:
87103
You will see output similar to the following:
88104
89105
```console
90-
N E X T F L O W ~ version 24.10.3
106+
N E X T F L O W ~ version 25.10.0
91107
92108
Launching `main.nf` [big_wegener] DSL2 - revision: 13a41a8946
93109
@@ -98,6 +114,15 @@ executor > local (3)
98114

99115
Nextflow creates a `work` directory to store files used during a pipeline run. Each execution of a process is run as a separate task. The `split` process is run as one task and the `convert_to_upper` process is run as two tasks. The hexadecimal string, for example, `82/457482`, is the beginning of a unique hash. It is a prefix used to identify the task directory where the script was executed.
100116

117+
When the pipeline completes, you can view the output files in the `results` directory:
118+
119+
```{code-block} bash
120+
:class: copyable
121+
ls -R results/
122+
```
123+
124+
You will see the published output files organized in the `lower` and `upper` subdirectories.
125+
101126
:::{tip}
102127
Run your pipeline with `-ansi-log false` to see each task printed on a separate line:
103128

@@ -109,7 +134,7 @@ nextflow run main.nf -ansi-log false
109134
You will see output similar to the following:
110135

111136
```console
112-
N E X T F L O W ~ version 24.10.3
137+
N E X T F L O W ~ version 25.10.0
113138
Launching `main.nf` [peaceful_watson] DSL2 - revision: 13a41a8946
114139
[43/f1f8b5] Submitted process > split (1)
115140
[a2/5aa4b1] Submitted process > convert_to_upper (chunk_ab)
@@ -126,13 +151,12 @@ Nextflow tracks task executions in a task cache, a key-value store of previously
126151

127152
You can enable resumability using the `-resume` flag when running a pipeline. To modify and resume your pipeline:
128153

129-
1. Open `main.nf`
154+
1. Open `main.nf`.
130155
2. Replace the `convert_to_upper` process with the following:
131156

132157
```{code-block} groovy
133158
:class: copyable
134159
process convert_to_upper {
135-
publishDir "results/upper"
136160
tag "$y"
137161
138162
input:
@@ -148,7 +172,7 @@ You can enable resumability using the `-resume` flag when running a pipeline. To
148172
}
149173
```
150174
151-
3. Save your changes
175+
3. Save your changes.
152176
4. Run your updated pipeline using the following command:
153177
154178
```{code-block} bash
@@ -159,7 +183,7 @@ You can enable resumability using the `-resume` flag when running a pipeline. To
159183
You will see output similar to the following:
160184
161185
```console
162-
N E X T F L O W ~ version 24.10.3
186+
N E X T F L O W ~ version 25.10.0
163187
164188
Launching `main.nf` [furious_curie] DSL2 - revision: 5490f13c43
165189
@@ -190,7 +214,7 @@ You can configure the `str` parameter in your pipeline. To modify your `str` par
190214
You will see output similar to the following:
191215
192216
```console
193-
N E X T F L O W ~ version 24.10.3
217+
N E X T F L O W ~ version 25.10.0
194218
195219
Launching `main.nf` [distracted_kalam] DSL2 - revision: 082867d4d6
196220

0 commit comments

Comments
 (0)