Skip to content

Commit 91b5e41

Browse files
committed
Add emits to outputs of processes with multiple outputs
1 parent 6a222dc commit 91b5e41

File tree

19 files changed

+41
-39
lines changed

19 files changed

+41
-39
lines changed

docs/hello_nextflow/04_hello_genomics.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,8 @@ process GATK_HAPLOTYPECALLER {
309309
path interval_list
310310
311311
output:
312-
path "${input_bam}.vcf"
313-
path "${input_bam}.vcf.idx"
312+
path "${input_bam}.vcf" , emit: vcf
313+
path "${input_bam}.vcf.idx" , emit: idx
314314
315315
"""
316316
gatk HaplotypeCaller \
@@ -322,6 +322,8 @@ process GATK_HAPLOTYPECALLER {
322322
}
323323
```
324324

325+
You'll notice that we've introduced some new syntax here (`emit:`) to uniquely name each of our output channels, and the reasons for this will become clear soon.
326+
325327
This command takes quite a few more inputs, because GATK needs more information to perform the analysis compared to a simple indexing job.
326328
But you'll note that there are even more inputs defined in the inputs block than are listed in the GATK command. Why is that?
327329

docs/hello_nextflow/05_hello_operators.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,14 +454,14 @@ Good news: we can do that using the `collect()` channel operator. Let's add the
454454

455455
```groovy title="hello-operators.nf" linenums="118"
456456
// Collect variant calling outputs across samples
457-
all_gvcfs_ch = GATK_HAPLOTYPECALLER.out[0].collect()
458-
all_idxs_ch = GATK_HAPLOTYPECALLER.out[1].collect()
457+
all_gvcfs_ch = GATK_HAPLOTYPECALLER.out.vcf.collect()
458+
all_idxs_ch = GATK_HAPLOTYPECALLER.out.idx.collect()
459459
```
460460

461461
Does that seem a bit complicated? Let's break this down and translate it into plain language.
462462

463463
1. We're taking the output channel from the `GATK_HAPLOTYPECALLER` process, referred to using the `.out` property.
464-
2. Each 'element' coming out of the channel is a pair of files: the GVCF and its index file, in that order because that's the order they're listed in the process output block. Conveniently, we can pick out the GVCFs on one hand by adding `[0]` and the index files on the other by adding `[1]` after the `.out` property.
464+
2. Each 'element' coming out of the channel is a pair of files: the GVCF and its index file, in that order because that's the order they're listed in the process output block. Conveniently, because in the last session we named the outputs of this process (using `emit:`), we can pick out the GVCFs on one hand by adding `.vcf` and the index files on the other by adding `.idx` after the `.out` property. If we had not named those outputs, we would have had to refer to them by `.out[0]` and `.out[1]`, respectively.
465465
3. We append the `collect()` channel operator to bundle all the GVCF files together into a single element in a new channel called `all_gvcfs_ch`, and do the same with the index files to form the new channel called `all_idxs_ch`.
466466

467467
!!!tip

docs/hello_nextflow/07_hello_modules.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ process GATK_HAPLOTYPECALLER {
292292
path interval_list
293293
294294
output:
295-
path "${input_bam}.g.vcf"
296-
path "${input_bam}.g.vcf.idx"
295+
path "${input_bam}.g.vcf" , emit: vcf
296+
path "${input_bam}.g.vcf.idx" , emit: idx
297297
298298
"""
299299
gatk HaplotypeCaller \

hello-nextflow/hello-config/main.nf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ process GATK_HAPLOTYPECALLER {
5353
path interval_list
5454

5555
output:
56-
path "${input_bam}.g.vcf"
57-
path "${input_bam}.g.vcf.idx"
56+
path "${input_bam}.g.vcf" , emit: vcf
57+
path "${input_bam}.g.vcf.idx" , emit: idx
5858

5959
"""
6060
gatk HaplotypeCaller \

hello-nextflow/hello-modules/main.nf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ process GATK_HAPLOTYPECALLER {
3939
path interval_list
4040

4141
output:
42-
path "${input_bam}.g.vcf"
43-
path "${input_bam}.g.vcf.idx"
42+
path "${input_bam}.g.vcf" , emit: vcf
43+
path "${input_bam}.g.vcf.idx" , emit: idx
4444

4545
"""
4646
gatk HaplotypeCaller \

hello-nextflow/hello-nf-test/modules/local/gatk/haplotypecaller/main.nf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ process GATK_HAPLOTYPECALLER {
1818
path interval_list
1919

2020
output:
21-
path "${input_bam}.g.vcf"
22-
path "${input_bam}.g.vcf.idx"
21+
path "${input_bam}.g.vcf" , emit: vcf
22+
path "${input_bam}.g.vcf.idx" , emit: idx
2323

2424
"""
2525
gatk HaplotypeCaller \

hello-nextflow/hello-nf-test/modules/local/gatk/jointgenotyping/main.nf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ process GATK_JOINTGENOTYPING {
1818
path ref_dict
1919

2020
output:
21-
path "${cohort_name}.joint.vcf"
22-
path "${cohort_name}.joint.vcf.idx"
21+
path "${cohort_name}.joint.vcf" , emit: vcf
22+
path "${cohort_name}.joint.vcf.idx" , emit: idx
2323

2424
script:
2525
def gvcfs_line = all_gvcfs.collect { gvcf -> "-V ${gvcf}" }.join(' ')

hello-nextflow/hello-operators.nf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ process GATK_HAPLOTYPECALLER {
5050
path interval_list
5151

5252
output:
53-
path "${input_bam}.vcf"
54-
path "${input_bam}.vcf.idx"
53+
path "${input_bam}.vcf" , emit: vcf
54+
path "${input_bam}.vcf.idx" , emit: idx
5555

5656
"""
5757
gatk HaplotypeCaller \

hello-nextflow/solutions/hello-config/final-main.nf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ process GATK_HAPLOTYPECALLER {
3939
path interval_list
4040

4141
output:
42-
path "${input_bam}.g.vcf"
43-
path "${input_bam}.g.vcf.idx"
42+
path "${input_bam}.g.vcf" , emit: vcf
43+
path "${input_bam}.g.vcf.idx" , emit: idx
4444

4545
"""
4646
gatk HaplotypeCaller \

hello-nextflow/solutions/hello-genomics/hello-genomics-2.nf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ process GATK_HAPLOTYPECALLER {
5151
path interval_list
5252

5353
output:
54-
path "${input_bam}.vcf"
55-
path "${input_bam}.vcf.idx"
54+
path "${input_bam}.vcf" , emit: vcf
55+
path "${input_bam}.vcf.idx" , emit: idx
5656

5757
"""
5858
gatk HaplotypeCaller \

0 commit comments

Comments
 (0)