Skip to content

Commit a954937

Browse files
committed
Use typed process inputs and outputs
Signed-off-by: Ben Sherman <[email protected]>
1 parent 8253a58 commit a954937

File tree

6 files changed

+31
-17
lines changed

6 files changed

+31
-17
lines changed

lib/Sample.groovy

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
import java.nio.file.Path
3+
import nextflow.io.ValueObject
4+
import nextflow.util.KryoHelper
5+
6+
@ValueObject
7+
class Sample {
8+
String id
9+
List<Path> reads
10+
11+
static {
12+
KryoHelper.register(Sample)
13+
}
14+
}

main.nf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ include { MULTIQC } from './modules/multiqc'
5151
* main script flow
5252
*/
5353
workflow {
54-
read_pairs_ch = channel.fromFilePairs( params.reads, checkIfExists: true )
55-
RNASEQ( params.transcriptome, read_pairs_ch )
56-
MULTIQC( RNASEQ.out, params.multiqc )
54+
read_pairs_ch = channel.fromFilePairs( params.reads, checkIfExists: true ).map { args -> new Sample(*args) }
55+
RNASEQ( file(params.transcriptome), read_pairs_ch )
56+
MULTIQC( RNASEQ.out, file(params.multiqc) )
5757
}
5858

5959
/*

modules/fastqc/main.nf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
params.outdir = 'results'
22

33
process FASTQC {
4-
tag "FASTQC on $sample_id"
4+
tag "FASTQC on $sample.id"
55
conda 'fastqc=0.12.1'
66
publishDir params.outdir, mode:'copy'
77

88
input:
9-
tuple val(sample_id), path(reads)
9+
Sample sample
1010

1111
output:
12-
path "fastqc_${sample_id}_logs"
12+
Path logs = path("fastqc_${sample.id}_logs")
1313

1414
script:
1515
"""
16-
fastqc.sh "$sample_id" "$reads"
16+
fastqc.sh "$sample.id" "$sample.reads"
1717
"""
1818
}

modules/index/main.nf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ process INDEX {
44
conda 'salmon=1.10.2'
55

66
input:
7-
path transcriptome
7+
Path transcriptome
88

99
output:
10-
path 'index'
10+
Path index = path('index')
1111

1212
script:
1313
"""

modules/multiqc/main.nf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ process MULTIQC {
55
publishDir params.outdir, mode:'copy'
66

77
input:
8-
path('*')
9-
path(config)
8+
List<Path> logs
9+
Path config
1010

1111
output:
12-
path('multiqc_report.html')
12+
Path report = path('multiqc_report.html')
1313

1414
script:
1515
"""

modules/quant/main.nf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11

22
process QUANT {
3-
tag "$pair_id"
3+
tag "$pair.id"
44
conda 'salmon=1.10.2'
55

66
input:
7-
path index
8-
tuple val(pair_id), path(reads)
7+
Path index
8+
Sample pair
99

1010
output:
11-
path pair_id
11+
Path result = path(pair.id)
1212

1313
script:
1414
"""
15-
salmon quant --threads $task.cpus --libType=U -i $index -1 ${reads[0]} -2 ${reads[1]} -o $pair_id
15+
salmon quant --threads $task.cpus --libType=U -i $index -1 ${pair.reads[0]} -2 ${pair.reads[1]} -o $pair.id
1616
"""
1717
}

0 commit comments

Comments
 (0)