Skip to content

Commit

Permalink
Document emit option in process outputs (#4437)
Browse files Browse the repository at this point in the history

Signed-off-by: Marcel Ribeiro-Dantas <[email protected]>
Signed-off-by: Ben Sherman <[email protected]>
Co-authored-by: Paolo Di Tommaso <[email protected]>
Co-authored-by: Ben Sherman <[email protected]>
  • Loading branch information
3 people authored Nov 8, 2023
1 parent d9ee987 commit 13aa1b6
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
46 changes: 46 additions & 0 deletions docs/process.md
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,52 @@ output:

In this example, the process is normally expected to produce an `output.txt` file, but in the cases where the file is legitimately missing, the process does not fail. The output channel will only contain values for those processes that produce `output.txt`.

(process-multiple-outputs)=

### Multiple outputs

When a process declares multiple outputs, each output can be accessed by index. The following example prints the second process output (indexes start at zero):

```groovy
process FOO {
output:
path 'bye_file.txt'
path 'hi_file.txt'
"""
echo "bye" > bye_file.txt
echo "hi" > hi_file.txt
"""
}
workflow {
FOO()
FOO.out[1].view()
}
```

You can also use the `emit` option to assign a name to each output and access them by name:

```groovy
process FOO {
output:
path 'bye_file.txt', emit: bye_file
path 'hi_file.txt', emit: hi_file
"""
echo "bye" > bye_file.txt
echo "hi" > hi_file.txt
"""
}
workflow {
FOO()
FOO.out.hi_file.view()
}
```

See {ref}`workflow-process-invocation` for more details.

## When

The `when` block allows you to define a condition that must be satisfied in order to execute the process. The condition can be any expression that returns a boolean value.
Expand Down
4 changes: 4 additions & 0 deletions docs/workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ The `main:` label can be omitted if there are no `take:` or `emit:` blocks.
Workflows were introduced in DSL2. If you are still using DSL1, see the {ref}`dsl1-page` page to learn how to migrate your Nextflow pipelines to DSL2.
:::

(workflow-process-invocation)=

## Process invocation

A process can be invoked like a function in a workflow definition, passing the expected input channels like function arguments. For example:
Expand Down Expand Up @@ -142,6 +144,8 @@ workflow {
}
```

See {ref}`process-multiple-outputs` for more details.

### Process named stdout

The `emit` option can also be used to name a `stdout` output:
Expand Down

0 comments on commit 13aa1b6

Please sign in to comment.