You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/your-first-script.md
+42-18Lines changed: 42 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ This guide details fundamental skills to run a basic Nextflow pipeline. It inclu
12
12
13
13
You will need the following to get started:
14
14
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.
16
16
17
17
## Run a pipeline
18
18
@@ -25,11 +25,9 @@ params.str = "Hello world!"
25
25
26
26
// split process
27
27
process split {
28
-
publishDir "results/lower"
29
-
30
28
input:
31
29
val x
32
-
30
+
33
31
output:
34
32
path 'chunk_*'
35
33
@@ -41,7 +39,6 @@ process split {
41
39
42
40
// convert_to_upper process
43
41
process convert_to_upper {
44
-
publishDir "results/upper"
45
42
tag "$y"
46
43
47
44
input:
@@ -58,9 +55,23 @@ process convert_to_upper {
58
55
59
56
// Workflow block
60
57
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
+
}
64
75
}
65
76
```
66
77
@@ -71,12 +82,17 @@ This script defines two processes:
71
82
72
83
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.
73
84
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.
75
91
76
92
To run your pipeline:
77
93
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.
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.
100
116
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
+
101
126
:::{tip}
102
127
Run your pipeline with `-ansi-log false` to see each task printed on a separate line:
103
128
@@ -109,7 +134,7 @@ nextflow run main.nf -ansi-log false
0 commit comments