Skip to content

Commit

Permalink
Minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
vdauwera committed Jan 9, 2025
1 parent 463eb12 commit 0ff8e97
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
6 changes: 4 additions & 2 deletions docs/hello_nextflow/01_hello_world.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Part 1: Hello World

A "Hello World!" is a minimalist example that is meant to demonstrate the basic syntax and structure of a programming language or software framework. The example typically consists of printing the phrase "Hello, World!" to the output device, such as the console or terminal, or writing it to a file.

In this first part of the Hello Nextflow training course, we ease into the topic with a very simple domain-agnostic Hello World example, which we'll progressively build up to demonstrate the usage of foundational Nextflow logic and components.

!!! note

A "Hello World!" is a minimalist example that is meant to demonstrate the basic syntax and structure of a programming language or software framework. The example typically consists of printing the phrase "Hello, World!" to the output device, such as the console or terminal, or writing it to a file.

---

## 0. Warmup: Run Hello World directly
Expand Down
13 changes: 8 additions & 5 deletions docs/hello_nextflow/02_hello_channels.md
Original file line number Diff line number Diff line change
Expand Up @@ -841,11 +841,14 @@ After flatten: Bonjour
After flatten: Holà
```

You see that we get a single `Before splitCsv:` statement; at that point the channel contains one item, the original file path.
Next, we get a single `After splitCsv:` statement; at that point the channel still contains only one item, an array containing the three values.
Then we get three separate `After flatten:` statements, one for each greeting, which are now individual items in the channel.
Looking at the output of the `view()` statements, we see the following:

- A single `Before splitCsv:` statement: at that point the channel contains one item, the original file path.
- A single `After splitCsv:` statement: at that point the channel still contains only one item, an array containing the three values.
- Three separate `After flatten:` statements: one for each greeting, which are now individual items in the channel.

We can also look at the output files, which show that each greeting was correctly extracted and processed through the workflow.

Looking at the outputs, we see that each greeting was correctly extracted and processed through the workflow.
We've achieved the same result as previously, but now we have a lot more flexibility to add more elements to the channel of greetings we want to process by modifying an input file, without modifying any code.

!!! note
Expand All @@ -862,4 +865,4 @@ More generally, you have a basic understanding of how Nextflow uses channels to
### What's next?

Take a break!
When you're ready, move on to Part 3 to learn how to add more steps to your workflow.
When you're ready, move on to Part 3 to learn how to add more steps to your workflow and do some slightly more interesting plumbing.
17 changes: 9 additions & 8 deletions docs/hello_nextflow/03_hello_plumbing.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

Most real-world workflows involve more than one step.
In this training module, you'll learn how to connect processes together in a multi-step workflow.
You will learn basic plumbing logic for making data flow from one process to the next, collecting outputs from multiple process calls, passing more than one input through a channel, emitting multiple outputs, and using simple conditionals.
You will learn basic plumbing logic for making data flow from one process to the next, collecting outputs from multiple process calls, passing more than one input through a channel and handling multiple outputs.

Building on the domain-agnostic Hello World example from earlier in the course, we're going to make the following changes to our workflow:

- Add a second step that converts the greeting to uppercase, using the classic UNIX text replacement command `tr '[a-z]' '[A-Z]'`;
- Add a third step that collects all the transformed greetings together back into a single file;
- Refine the third step to handle processing subsequent batches without overwriting results;
- Log some simple statistics about the batches that we process.
- Output some simple statistics about the greetings that we process.

---

Expand Down Expand Up @@ -394,8 +394,6 @@ Yes, once again the answer to our problem is an operator, the aptly-named [`coll
This time it's going to look a bit different because we're not adding it in the context of a channel factory.
Instead, we append it to `convertToUpper.out`, which becomes `convertToUpper.out.collect()`, in the process call.

We'll also include a couple of `view()` statements to visualize the before and after states of the channel contents.

In the workflow block, make the following code changes:

_Before:_
Expand All @@ -418,7 +416,7 @@ _After:_
}
```

The `view()` statements can go anywhere you want.
Notice that we also included a couple of `view()` statements to visualize the before and after states of the channel contents. The `view()` statements can go anywhere you want; we put them after the call for readability.

### 2.7. Run the workflow again with `-resume`

Expand All @@ -441,8 +439,10 @@ Before collect: /workspace/gitpod/hello-nextflow/work/89/b627e818957935446948652
After collect: [/workspace/gitpod/hello-nextflow/work/5e/59bb64da77666f94fb25fb64f7ce10/UPPER-Holà-output.txt, /workspace/gitpod/hello-nextflow/work/06/dc3c59e025d435209e9aa55f90094b/UPPER-Hello-output.txt, /workspace/gitpod/hello-nextflow/work/89/b627e818957935446948652e8727e6/UPPER-Bonjour-output.txt]
```

You see that we get three `Before collect:` statements, one for each greeting; at that point the file paths are individual items in the channel.
Then we get a single `After collect:` statement; the three file paths are packaged into a single item.
Looking at the output of the `view()` statements, we see the following:

- Three `Before collect:` statements, one for each greeting: at that point the file paths are individual items in the channel.
- A single `After collect:` statement: the three file paths are now packaged into a single item.

Have a look at the contents of the final output file too:

Expand Down Expand Up @@ -591,7 +591,7 @@ Let's try running this with a batch name on the command line.
nextflow run hello-plumbing.nf -resume --batch trio
```

It runs successfully and produces the desired output!
It runs successfully and produces the desired output:

```console title="bash"
cat results/COLLECTED-trio-output.txt
Expand Down Expand Up @@ -627,6 +627,7 @@ Since our workflow is very simple, we're going to contrive an example of a secon

First we need to get that count.
Conveniently, Nextflow lets us add arbitrary code in the `script:` block of the process definition, which comes in really handy for doing things like this.

In this case, we can use the built-in `size()` function to get the number of files in the `input_files` array.

In the process block, make the following code change:
Expand Down

0 comments on commit 0ff8e97

Please sign in to comment.