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
@@ -346,8 +346,8 @@ A *named workflow* is a workflow that can be called by other workflows:
346
346
347
347
```nextflow
348
348
workflow my_workflow {
349
-
hello()
350
-
bye( hello.out.collect() )
349
+
ch_hello = hello()
350
+
bye( ch_hello.collect() )
351
351
}
352
352
353
353
workflow {
@@ -368,8 +368,8 @@ workflow my_workflow {
368
368
data2
369
369
370
370
main:
371
-
hello(data1, data2)
372
-
bye(hello.out)
371
+
ch_hello = hello(data1, data2)
372
+
bye(hello)
373
373
}
374
374
```
375
375
@@ -385,31 +385,34 @@ The `emit:` section declares the outputs of a named workflow:
385
385
386
386
```nextflow
387
387
workflow my_workflow {
388
+
take:
389
+
data
390
+
388
391
main:
389
-
hello(data)
390
-
bye(hello.out)
392
+
ch_bye = bye(hello(data))
391
393
392
394
emit:
393
-
bye.out
395
+
ch_bye
394
396
}
395
397
```
396
398
397
-
When calling the workflow, the output can be accessed using the `out` property, i.e. `my_workflow.out`.
398
-
399
399
If an output is assigned to a name, the name can be used to reference the output from the calling workflow. For example:
400
400
401
401
```nextflow
402
402
workflow my_workflow {
403
403
main:
404
-
hello(data)
405
-
bye(hello.out)
404
+
ch_hello = hello(data)
405
+
ch_bye = bye(ch_hello)
406
406
407
407
emit:
408
-
my_data = bye.out
408
+
my_data = ch_bye
409
409
}
410
-
```
411
410
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
+
```
413
416
414
417
:::{note}
415
418
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.
421
424
422
425
Workflows consist of *dataflow* logic, in which processes are connected to each other through *dataflow channels* and *dataflow values*.
423
426
424
-
(dataflow-type-channel)=
425
-
426
-
### Channels
427
+
### Channels and values
427
428
428
429
A *dataflow channel* (or simply *channel*) is an asynchronous sequence of values.
429
430
@@ -439,7 +440,21 @@ channel emits 2
439
440
channel emits 3
440
441
```
441
442
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
443
458
444
459
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:
See {ref}`channel-factory` for the full list of channel factories.
451
466
452
-
**Operators**
467
+
### Operators
453
468
454
469
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.
455
470
@@ -473,27 +488,7 @@ Commonly used operators include:
473
488
474
489
- {ref}`operator-view`: print each channel value to standard output
475
490
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.
497
492
498
493
(workflow-process-invocation)=
499
494
@@ -540,10 +535,9 @@ workflow {
540
535
}
541
536
```
542
537
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:
544
539
545
540
```nextflow
546
-
// workflow `hello_bye` is defined in `./modules/hello_bye/main.nf`
547
541
include { hello_bye as hello_bye1 } from './modules/hello_bye'
548
542
include { hello_bye as hello_bye2 } from './modules/hello_bye'
549
543
@@ -623,103 +617,51 @@ workflow {
623
617
Process named outputs are defined using the `emit` option on a process output. See {ref}`naming process outputs <process-naming-outputs>` for more information.
624
618
:::
625
619
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
-
630
620
Workflows can be composed in the same way:
631
621
632
622
```nextflow
633
623
workflow flow1 {
634
624
take:
635
625
data
636
626
637
-
main:
638
-
tick(data)
639
-
tack(tick.out)
640
-
641
627
emit:
642
-
tack.out
628
+
tack(tick(data))
643
629
}
644
630
645
631
workflow flow2 {
646
632
take:
647
633
data
648
634
649
-
main:
650
-
tick(data)
651
-
tock(tick.out)
652
-
653
635
emit:
654
-
tock.out
636
+
tock(tick(data))
655
637
}
656
638
657
639
workflow {
658
640
data = channel.fromPath('/some/path/*.txt')
659
-
flow1(data)
660
-
flow2(flow1.out)
641
+
flow2(flow1(data))
661
642
}
662
643
```
663
644
664
-
:::{note}
665
645
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
-
:::
667
646
668
647
:::{tip}
669
648
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.
670
649
:::
671
650
672
651
(workflow-special-operators)=
673
652
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 `&`)
677
654
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.
680
657
:::
681
658
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:
705
660
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).
707
663
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):
0 commit comments