Skip to content

Commit 753cedd

Browse files
Minor fixes to Part 3
1 parent f8c4bcb commit 753cedd

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

docs/hello_nextflow/03_hello_workflow.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ If that worked for you, you're ready to learn how to assemble a multi-step workf
6262
We're going to add a step to convert the greeting to uppercase.
6363
To that end, we need to do three things:
6464

65-
- Define the command we'lre going to use to do the uppercase conversion.
65+
- Define the command we're going to use to do the uppercase conversion.
6666
- Write a new process that wraps the uppercasing command.
67-
- Add the new process to the workflow and set it up to take the output of the `sayHello()` process as input.
67+
- Call the new process in the workflow block and set it up to take the output of the `sayHello()` process as input.
6868

6969
### 1.1. Define the uppercasing command and test it in the terminal
7070

71-
To do the conversion of the greetings to uppercase, we're going to a classic UNIX tool called `tr` for 'text replacement', with the following syntax:
71+
To do the conversion of the greetings to uppercase, we're going to use a classic UNIX tool called `tr` for 'text replacement', with the following syntax:
7272

7373
```bash title="Syntax"
7474
tr '[a-z]' '[A-Z]'
@@ -338,7 +338,7 @@ Nextflow doesn't mind, so it doesn't matter.
338338
This is where things could get a little tricky, because we need to be able to handle an arbitrary number of input files.
339339
Specifically, we can't write the command up front, so we need to tell Nextflow how to compose it at runtime based on what inputs flow into the process.
340340

341-
In other words, if we have an input channel containing the item `[file1.txt, file2.txt, file3.txt]`, we need Nextflow to turn that into `cat file1.txt file2.txt file3.txt`.
341+
In other words, if we have an input channel containing the element `[file1.txt, file2.txt, file3.txt]`, we need Nextflow to turn that into `cat file1.txt file2.txt file3.txt`.
342342

343343
Fortunately, Nextflow is quite happy to do that for us if we simply write `cat ${input_files}` in the script command.
344344

@@ -368,7 +368,7 @@ In theory this should handle any arbitrary number of input files.
368368

369369
Some command-line tools require providing an argument (like `-input`) for each input file.
370370
In that case, we would have to do a little bit of extra work to compose the command.
371-
You can see an example of this in the 'Nextflow for Genomics' training course.
371+
You can see an example of this in the [Nextflow for Genomics](https://training.nextflow.io/latest/nf4_science/genomics/) training course.
372372

373373
<!--[ADD LINK to note above] -->
374374

@@ -427,13 +427,13 @@ We were only expecting one, but there are three.
427427

428428
And have a look at the contents of the final output file too:
429429

430-
```console title="COLLECTED-output.txt"
430+
```console title="results/COLLECTED-output.txt"
431431
Holà
432432
```
433433

434434
Oh no. The collection step was run individually on each greeting, which is NOT what we wanted.
435435

436-
We need to do something to tell Nextflow explicitly that we want that third step to run on all the items in the channel output by `convertToUpper()`.
436+
We need to do something to tell Nextflow explicitly that we want that third step to run on all the elements in the channel output by `convertToUpper()`.
437437

438438
### 2.3. Use an operator to collect the greetings into a single input
439439

@@ -521,22 +521,22 @@ This time the third step was only called once!
521521
Looking at the output of the `view()` statements, we see the following:
522522

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

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

528-
```console title="COLLECTED-output.txt"
528+
```console title="results/COLLECTED-output.txt"
529529
BONJOUR
530530
HELLO
531531
HOLà
532532
```
533533

534-
This time we have all three greetings in the final output file. Success!
534+
This time we have all three greetings in the final output file. Success! Remove the optional view calls to make the next outputs less verbose.
535535

536536
!!! note
537537

538538
If you run this several times without `-resume`, you will see that the order of the greetings changes from one run to the next.
539-
This shows you that the order in which items flow through the pipeline is not guaranteed to be consistent.
539+
This shows you that the order in which elements flow through process calls is not guaranteed to be consistent, unless you make use of fair threading (check the [fair](https://www.nextflow.io/docs/latest/reference/process.html#fair) directive).
540540

541541
### Takeaway
542542

@@ -742,14 +742,14 @@ Conveniently, Nextflow lets us add arbitrary code in the `script:` block of the
742742

743743
That means we can use the built-in `size()` function to get the number of files in the `input_files` array.
744744

745-
In the process block, make the following code change:
745+
In the `collectGreetings` process block, make the following code change:
746746

747747
_Before:_
748748

749749
```groovy title="hello-workflow.nf" linenums="55"
750750
script:
751751
"""
752-
cat ${input_files} > 'COLLECTED-${batch_id}-output.txt'
752+
cat ${input_files} > 'COLLECTED-${batch_name}-output.txt'
753753
"""
754754
```
755755

@@ -759,7 +759,7 @@ _After:_
759759
script:
760760
count_greetings = input_files.size()
761761
"""
762-
cat ${input_files} > 'COLLECTED-${batch_id}-output.txt'
762+
cat ${input_files} > 'COLLECTED-${batch_name}-output.txt'
763763
"""
764764
```
765765

@@ -777,14 +777,14 @@ _Before:_
777777

778778
```groovy title="hello-workflow.nf" linenums="52"
779779
output:
780-
path "COLLECTED-${batch_id}-output.txt"
780+
path "COLLECTED-${batch_name}-output.txt"
781781
```
782782

783783
_After:_
784784

785785
```groovy title="hello-workflow.nf" linenums="52"
786786
output:
787-
path "COLLECTED-${batch_id}-output.txt" , emit: outfile
787+
path "COLLECTED-${batch_name}-output.txt" , emit: outfile
788788
val count_greetings , emit: count
789789
```
790790

@@ -793,7 +793,7 @@ But as the saying goes, why not both?
793793

794794
### 4.2. Report the output at the end of the workflow
795795

796-
Now that we have two outputs coming out of the `collectGreetings` process, the `collectGreetings.out` output channel contains two 'tracks':
796+
Now that we have two outputs coming out of the `collectGreetings` process, the `collectGreetings.out` output multi-channel contains two channels:
797797

798798
- `collectGreetings.out.outfile` contains the final output file
799799
- `collectGreetings.out.count` contains the count of greetings

0 commit comments

Comments
 (0)