Skip to content

Commit b112542

Browse files
committed
Apply suggestions from review
Signed-off-by: Ben Sherman <bentshermann@gmail.com>
1 parent 03862ed commit b112542

3 files changed

Lines changed: 54 additions & 110 deletions

File tree

docs/modules/developing-modules.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ Registry modules follow a standard directory structure:
3838
modules/
3939
└── myorg/
4040
└── my-module/
41-
├── .module-info # Integrity checksum (generated at install/creation)
42-
├── README.md # Documentation (required for publishing)
43-
├── main.nf # Module script (required)
44-
├── meta.yml # Module spec (required for publishing)
45-
├── resources/ # Optional: module resources
46-
└── templates/ # Optional: process script templates
41+
├── .module-info # Integrity checksum
42+
├── README.md # Documentation
43+
├── main.nf # Module script
44+
├── meta.yml # Module spec
45+
├── resources/ # Optional: Module resources
46+
└── templates/ # Optional: Process script templates
4747
```
4848

4949
Local modules that are not intended for publishing do not need to follow this structure, although it is recommended as a best practice.

docs/modules/using-modules.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ Local modules must be included by relative path:
9191
include { FASTQC } from './modules/local/fastqc'
9292
```
9393

94+
See {ref}`syntax-include` for a full description of the include syntax.
95+
9496
## Running modules directly
9597

9698
For ad-hoc tasks or testing, run a module directly without creating a wrapper workflow:

docs/workflow.md

Lines changed: 46 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,8 @@ A *named workflow* is a workflow that can be called by other workflows:
346346

347347
```nextflow
348348
workflow my_workflow {
349-
hello()
350-
bye( hello.out.collect() )
349+
ch_hello = hello()
350+
bye( ch_hello.collect() )
351351
}
352352
353353
workflow {
@@ -368,8 +368,8 @@ workflow my_workflow {
368368
data2
369369
370370
main:
371-
hello(data1, data2)
372-
bye(hello.out)
371+
ch_hello = hello(data1, data2)
372+
bye(hello)
373373
}
374374
```
375375

@@ -385,31 +385,34 @@ The `emit:` section declares the outputs of a named workflow:
385385

386386
```nextflow
387387
workflow my_workflow {
388+
take:
389+
data
390+
388391
main:
389-
hello(data)
390-
bye(hello.out)
392+
ch_bye = bye(hello(data))
391393
392394
emit:
393-
bye.out
395+
ch_bye
394396
}
395397
```
396398

397-
When calling the workflow, the output can be accessed using the `out` property, i.e. `my_workflow.out`.
398-
399399
If an output is assigned to a name, the name can be used to reference the output from the calling workflow. For example:
400400

401401
```nextflow
402402
workflow my_workflow {
403403
main:
404-
hello(data)
405-
bye(hello.out)
404+
ch_hello = hello(data)
405+
ch_bye = bye(ch_hello)
406406
407407
emit:
408-
my_data = bye.out
408+
my_data = ch_bye
409409
}
410-
```
411410
412-
The result of the above workflow can be accessed using `my_workflow.out.my_data`.
411+
workflow {
412+
result = my_workflow()
413+
result.my_data.view()
414+
}
415+
```
413416

414417
:::{note}
415418
Every output must be assigned to a name when multiple outputs are declared.
@@ -421,9 +424,7 @@ Every output must be assigned to a name when multiple outputs are declared.
421424

422425
Workflows consist of *dataflow* logic, in which processes are connected to each other through *dataflow channels* and *dataflow values*.
423426

424-
(dataflow-type-channel)=
425-
426-
### Channels
427+
### Channels and values
427428

428429
A *dataflow channel* (or simply *channel*) is an asynchronous sequence of values.
429430

@@ -439,7 +440,21 @@ channel emits 2
439440
channel emits 3
440441
```
441442

442-
**Factories**
443+
A *dataflow value* is an asynchronous value.
444+
445+
Dataflow values can be created using the {ref}`channel.value <channel-value>` factory, and they are created by processes (under {ref}`certain conditions <process-out-singleton>`).
446+
447+
A dataflow value cannot be accessed directly, but only through an operator or process. For example:
448+
449+
```nextflow
450+
channel.value(1).view { v -> "dataflow value is ${v}" }
451+
```
452+
453+
```console
454+
dataflow value is 1
455+
```
456+
457+
### Factories
443458

444459
A channel can be created by factories in the `channel` namespace. For example, the `channel.fromPath()` factory creates a channel from a file name or glob pattern, similar to the `files()` function:
445460

@@ -449,7 +464,7 @@ channel.fromPath('input/*.txt').view()
449464

450465
See {ref}`channel-factory` for the full list of channel factories.
451466

452-
**Operators**
467+
### Operators
453468

454469
Channel operators, or *operators* for short, are functions that consume and produce channels. Because channels are asynchronous, operators are necessary to manipulate the values in a channel. Operators are particularly useful for implementing glue logic between processes.
455470

@@ -473,27 +488,7 @@ Commonly used operators include:
473488

474489
- {ref}`operator-view`: print each channel value to standard output
475490

476-
See {ref}`operator-page` for the full set of operators.
477-
478-
(dataflow-type-value)=
479-
480-
### Values
481-
482-
A *dataflow value* is an asynchronous value.
483-
484-
Dataflow values can be created using the {ref}`channel.value <channel-value>` factory, and they are created by processes (under {ref}`certain conditions <process-out-singleton>`).
485-
486-
A dataflow value cannot be accessed directly, but only through an operator or process. For example:
487-
488-
```nextflow
489-
channel.value(1).view { v -> "dataflow value is ${v}" }
490-
```
491-
492-
```console
493-
dataflow value is 1
494-
```
495-
496-
See {ref}`stdlib-types-value` for the set of available methods for dataflow values.
491+
See {ref}`operator-page` for the full set of operators. See {ref}`stdlib-types-value` for the set of available methods for dataflow values.
497492

498493
(workflow-process-invocation)=
499494

@@ -540,10 +535,9 @@ workflow {
540535
}
541536
```
542537

543-
Processes and workflows can only be called by workflows. A given process or workflow can only be called once in a given workflow. To use a process or workflow multiple times in the same workflow, include it from another script with multiple aliases:
538+
Processes and workflows can only be called by workflows. A given process or workflow can only be called once in a given workflow. To use a process or workflow multiple times in the same workflow, {ref}`include <syntax-include>` it from another script with multiple aliases:
544539

545540
```nextflow
546-
// workflow `hello_bye` is defined in `./modules/hello_bye/main.nf`
547541
include { hello_bye as hello_bye1 } from './modules/hello_bye'
548542
include { hello_bye as hello_bye2 } from './modules/hello_bye'
549543
@@ -623,103 +617,51 @@ workflow {
623617
Process named outputs are defined using the `emit` option on a process output. See {ref}`naming process outputs <process-naming-outputs>` for more information.
624618
:::
625619

626-
:::{note}
627-
Process and workflow outputs can also be accessed by index (e.g., `hello.out[0]`, `hello.out[1]`, etc.). As a best practice, multiple outputs should be accessed by name.
628-
:::
629-
630620
Workflows can be composed in the same way:
631621

632622
```nextflow
633623
workflow flow1 {
634624
take:
635625
data
636626
637-
main:
638-
tick(data)
639-
tack(tick.out)
640-
641627
emit:
642-
tack.out
628+
tack(tick(data))
643629
}
644630
645631
workflow flow2 {
646632
take:
647633
data
648634
649-
main:
650-
tick(data)
651-
tock(tick.out)
652-
653635
emit:
654-
tock.out
636+
tock(tick(data))
655637
}
656638
657639
workflow {
658640
data = channel.fromPath('/some/path/*.txt')
659-
flow1(data)
660-
flow2(flow1.out)
641+
flow2(flow1(data))
661642
}
662643
```
663644

664-
:::{note}
665645
The same process can be called in different workflows without using an alias, like `tick` in the above example, which is used in both `flow1` and `flow2`. The workflow call stack determines the *fully qualified process name*, which is used to distinguish the different process calls, i.e. `flow1:tick` and `flow2:tick` in the above example.
666-
:::
667646

668647
:::{tip}
669648
The fully qualified process name can be used as a {ref}`process selector <config-process-selectors>` in a Nextflow configuration file, and it takes priority over the simple process name.
670649
:::
671650

672651
(workflow-special-operators)=
673652

674-
### Special operators
675-
676-
The following operators have a special meaning when used in a workflow with process and workflow calls.
653+
### Special operators (`|` and `&`)
677654

678-
:::{note}
679-
As a best practice, avoid these operators when {ref}`type checking <preparing-static-types>` is enabled. Using these operators will prevent the type checker from validating your code.
655+
:::{deprecated} 26.04.0
656+
These operators are not supported when {ref}`static typing <preparing-static-types>` is enabled. Use standard method calls and assignments instead.
680657
:::
681658

682-
**Pipe `|`**
683-
684-
The `|` *pipe* operator can be used to chain processes, operators, and workflows:
685-
686-
```nextflow
687-
process greet {
688-
input:
689-
val data
690-
691-
output:
692-
val result
693-
694-
exec:
695-
result = "$data world"
696-
}
697-
698-
workflow {
699-
channel.of('Hello', 'Hola', 'Ciao')
700-
| greet
701-
| map { v -> v.toUpperCase() }
702-
| view
703-
}
704-
```
659+
The following operators have a special meaning when used with process and workflow calls in a workflow:
705660

706-
The above snippet defines a process named `greet` and invokes it with the input channel. The result is then piped to the {ref}`operator-map` operator, which converts each string to uppercase, and finally to the {ref}`operator-view` operator which prints it.
661+
- The `|` *pipe* operator can be used to chain processes, operators, and workflows.
662+
- The `&` *and* operator can be used to call multiple processes in parallel with the same channel(s).
707663

708-
The same code can also be written as:
709-
710-
```nextflow
711-
workflow {
712-
ch_input = channel.of('Hello', 'Hola', 'Ciao')
713-
ch_greet = greet(ch_input)
714-
ch_greet
715-
.map { v -> v.toUpperCase() }
716-
.view()
717-
}
718-
```
719-
720-
**And `&`**
721-
722-
The `&` *and* operator can be used to call multiple processes in parallel with the same channel(s):
664+
For example:
723665

724666
```nextflow
725667
process greet {

0 commit comments

Comments
 (0)