Skip to content

Commit 484bfed

Browse files
committed
Static types
1 parent fcf1b9b commit 484bfed

File tree

7 files changed

+100
-51
lines changed

7 files changed

+100
-51
lines changed

main.nf

Lines changed: 43 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,59 +4,75 @@
44
* Proof of concept of a RNAseq pipeline implemented with Nextflow
55
*/
66

7-
nextflow.preview.output = true
8-
9-
/*
10-
* Default pipeline parameters. They can be overriden on the command line eg.
11-
* given `params.reads` specify on the run command line `--reads some_value`.
12-
*/
13-
14-
params.reads = null
15-
params.transcriptome = null
16-
params.outdir = "results"
17-
params.multiqc = "$projectDir/multiqc"
7+
// enable v2 operators (required for static type checking)
8+
nextflow.preview.operators = true
189

10+
// enable static type checking
11+
nextflow.preview.typeChecking = true
1912

2013
// import modules
2114
include { RNASEQ } from './modules/rnaseq'
15+
include { FastqPair ; Sample } from './modules/rnaseq'
2216
include { MULTIQC } from './modules/multiqc'
2317

18+
/*
19+
* Pipeline parameters. They can be overridden on the command line, e.g.
20+
* `params.reads` can be specified as `--reads '...'`.
21+
*/
22+
params {
23+
// The input read-pair files
24+
reads: List<FastqPair>
25+
26+
// The input transcriptome file
27+
transcriptome: Path
28+
29+
// Directory containing multiqc configuration
30+
multiqc: Path = "${projectDir}/multiqc"
31+
}
32+
2433
/*
25-
* main script flow
34+
* Entry workflow
2635
*/
2736
workflow {
2837
main:
2938
log.info """\
3039
R N A S E Q - N F P I P E L I N E
3140
===================================
41+
reads : ${params.reads*.id.join(',')}
3242
transcriptome: ${params.transcriptome}
33-
reads : ${params.reads}
34-
outdir : ${params.outdir}
43+
outdir : ${workflow.outputDir}
3544
""".stripIndent()
3645

37-
inputs_ch = channel.fromPath(params.reads)
38-
.splitCsv()
39-
.map { id, fastq_1, fastq_2 ->
40-
tuple(id, file(fastq_1, checkIfExists: true), file(fastq_2, checkIfExists: true))
41-
}
42-
43-
samples_ch = RNASEQ( params.transcriptome, inputs_ch )
44-
.map { id, fastqc, quant ->
45-
[id: id, fastqc: fastqc, quant: quant]
46-
}
46+
(samples_ch, index) = RNASEQ( channel.fromList(params.reads), params.transcriptome )
4747

4848
multiqc_files_ch = samples_ch
4949
.flatMap { sample -> [sample.fastqc, sample.quant] }
5050
.collect()
51+
5152
multiqc_report = MULTIQC( multiqc_files_ch, params.multiqc )
5253

5354
publish:
55+
index = index
5456
samples = samples_ch
5557
multiqc_report = multiqc_report
58+
59+
onComplete:
60+
log.info(
61+
workflow.success
62+
? "\nDone! Open the following report in your browser --> ${workflow.outputDir}/multiqc_report.html\n"
63+
: "Oops .. something went wrong"
64+
)
5665
}
5766

67+
/*
68+
* Pipeline outputs. By default they will be saved to the 'results' directory.
69+
*/
5870
output {
59-
samples {
71+
index: Path {
72+
path '.'
73+
}
74+
75+
samples: Channel<Sample> {
6076
path { sample ->
6177
sample.fastqc >> "fastqc/${sample.id}"
6278
sample.quant >> "quant/${sample.id}"
@@ -67,6 +83,7 @@ output {
6783
}
6884
}
6985

70-
multiqc_report {
86+
multiqc_report: Path {
87+
path '.'
7188
}
7289
}

modules/fastqc/main.nf

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ process FASTQC {
44
conda 'bioconda::fastqc=0.12.1'
55

66
input:
7-
tuple val(id), path(fastq_1), path(fastq_2)
7+
id : String
8+
fastq_1 : Path
9+
fastq_2 : Path
810

911
output:
10-
tuple val(id), path("fastqc_${id}_logs")
12+
id : String = id
13+
fastqc : Path = file("fastqc_${id}_logs")
1114

1215
script:
1316
"""

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 'bioconda::salmon=1.10.3'
55

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

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

1212
script:
1313
"""

modules/multiqc/main.nf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ process MULTIQC {
33
conda 'bioconda::multiqc=1.27.1'
44

55
input:
6-
path '*'
7-
path config
6+
inputs : Bag<Path>
7+
config : Path
88

99
output:
10-
path 'multiqc_report.html', emit: report
10+
file('multiqc_report.html')
1111

1212
script:
1313
"""

modules/quant/main.nf

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ process QUANT {
44
conda 'bioconda::salmon=1.10.3'
55

66
input:
7-
path index
8-
tuple val(id), path(fastq_1), path(fastq_2)
7+
id : String
8+
fastq_1 : Path
9+
fastq_2 : Path
10+
index : Path
911

1012
output:
11-
tuple val(id), path("quant_${id}")
13+
id : String = id
14+
quant : Path = file("quant_${id}")
1215

1316
script:
1417
"""

modules/rnaseq.nf

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,28 @@ include { FASTQC } from './fastqc'
55

66
workflow RNASEQ {
77
take:
8-
transcriptome
9-
samples_ch
8+
reads : Channel<FastqPair>
9+
transcriptome : Path
1010

1111
main:
1212
index = INDEX(transcriptome)
13-
fastqc_ch = FASTQC(samples_ch)
14-
quant_ch = QUANT(index, samples_ch)
15-
samples_ch = fastqc_ch.join(quant_ch)
13+
fastqc_ch = reads.map(FASTQC)
14+
quant_ch = reads.map(QUANT, index: index)
15+
samples_ch = fastqc_ch.join(quant_ch, 'id')
1616

1717
emit:
18-
samples_ch
19-
}
18+
samples : Channel<Sample> = samples_ch
19+
index : Path = index
20+
}
21+
22+
record FastqPair {
23+
id : String
24+
fastq_1 : Path
25+
fastq_2 : Path
26+
}
27+
28+
record Sample {
29+
id : String
30+
fastqc : Path
31+
quant : Path
32+
}

nextflow_schema.json

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,27 @@
1111
"fa_icon": "fas fa-terminal",
1212
"description": "Define where the pipeline should find input data and save output data.",
1313
"properties": {
14-
"outdir": {
15-
"type": "string",
16-
"format": "directory-path",
17-
"description": "The output directory where the results will be saved. You have to use absolute paths to storage on Cloud infrastructure.",
18-
"fa_icon": "fas fa-folder-open",
19-
"default": "results"
20-
},
2114
"reads": {
22-
"type": "string",
15+
"type": "array",
16+
"items": {
17+
"type": "object",
18+
"properties": {
19+
"id": {
20+
"type": "string"
21+
},
22+
"fastq_1": {
23+
"type": "string",
24+
"format": "file-path",
25+
"exists": true
26+
},
27+
"fastq_2": {
28+
"type": "string",
29+
"format": "file-path",
30+
"exists": true
31+
}
32+
},
33+
"required": ["id", "fastq_1", "fastq_2"]
34+
},
2335
"description": "The input read-pair files",
2436
"fa_icon": "fas fa-folder-open",
2537
"default": "${projectDir}/data/ggal/ggal_gut_{1,2}.fq"
@@ -32,6 +44,7 @@
3244
},
3345
"multiqc": {
3446
"type": "string",
47+
"description": "Directory containing multiqc configuration",
3548
"fa_icon": "fas fa-folder-open",
3649
"default": "${projectDir}/multiqc"
3750
}

0 commit comments

Comments
 (0)