|
1 | | -#!/usr/bin/env nextflow |
| 1 | +#!/usr/bin/env nextflow |
2 | 2 |
|
3 | 3 | /* |
4 | 4 | * Proof of concept of a RNAseq pipeline implemented with Nextflow |
5 | 5 | */ |
6 | | - |
| 6 | +nextflow.preview.types = true |
7 | 7 |
|
8 | 8 | /* |
9 | | - * Default pipeline parameters. They can be overriden on the command line eg. |
10 | | - * given `params.foo` specify on the run command line `--foo some_value`. |
| 9 | + * Default pipeline parameters. They can be overridden on the command line, e.g. |
| 10 | + * `params.reads` can be specified on the command line as `--reads some_value`. |
11 | 11 | */ |
12 | | - |
13 | | -params.reads = "$baseDir/data/ggal/ggal_gut_{1,2}.fq" |
14 | | -params.transcriptome = "$baseDir/data/ggal/ggal_1_48850000_49020000.Ggal71.500bpflank.fa" |
15 | | -params.outdir = "results" |
16 | | -params.multiqc = "$baseDir/multiqc" |
| 12 | +params.reads = "${projectDir}/data/ggal/ggal_gut_{1,2}.fq" |
| 13 | +params.transcriptome = "${projectDir}/data/ggal/ggal_1_48850000_49020000.Ggal71.500bpflank.fa" |
| 14 | +params.multiqc = "${projectDir}/multiqc" |
17 | 15 |
|
18 | 16 |
|
19 | | -// import modules |
20 | 17 | include { RNASEQ } from './modules/rnaseq' |
| 18 | +include { FastqPair ; Sample } from './modules/rnaseq' |
21 | 19 | include { MULTIQC } from './modules/multiqc' |
22 | 20 |
|
23 | | -/* |
24 | | - * main script flow |
25 | | - */ |
26 | 21 | workflow { |
| 22 | + main: |
| 23 | + log.info """\ |
| 24 | + R N A S E Q - N F P I P E L I N E |
| 25 | + =================================== |
| 26 | + transcriptome: ${params.transcriptome} |
| 27 | + reads : ${params.reads} |
| 28 | + outdir : ${workflow.outputDir} |
| 29 | + """.stripIndent() |
| 30 | + |
| 31 | + let (index, samples) = params.reads |
| 32 | + |> Channel.fromFilePairs( checkIfExists: true ) // Channel<(String,List<Path>)> |
| 33 | + |> map { (id, reads) -> |
| 34 | + new FastqPair(id, reads[0], reads[1]) |
| 35 | + } // Channel<FastqPair> |
| 36 | + |> RNASEQ( file(params.transcriptome) ) // NamedTuple(index: Path, samples: Channel<Sample>) |
| 37 | + |
| 38 | + let summary = samples |
| 39 | + |> flatMap { s -> [ s.fastqc, s.quant ] } // Channel<Path> |
| 40 | + |> collect // Bag<Path> (future) |
| 41 | + |> MULTIQC( file(params.multiqc) ) // Path (future) |
| 42 | + |
| 43 | + workflow.onComplete { |
| 44 | + log.info ( workflow.success |
| 45 | + ? "\nDone! Open the following report in your browser --> ${workflow.outputDir}/multiqc_report.html\n" |
| 46 | + : "Oops .. something went wrong" ) |
| 47 | + } |
| 48 | + |
| 49 | + publish: |
| 50 | + index >> 'index' |
| 51 | + samples >> 'samples' |
| 52 | + summary >> 'summary' |
| 53 | +} |
| 54 | + |
| 55 | +output { |
| 56 | + index: Path { |
| 57 | + path '.' |
| 58 | + } |
| 59 | + |
| 60 | + samples: Sample { |
| 61 | + path { sample -> sample.id } |
| 62 | + index { |
| 63 | + path 'samples.json' |
| 64 | + } |
| 65 | + } |
27 | 66 |
|
28 | | -log.info """\ |
29 | | - R N A S E Q - N F P I P E L I N E |
30 | | - =================================== |
31 | | - transcriptome: ${params.transcriptome} |
32 | | - reads : ${params.reads} |
33 | | - outdir : ${params.outdir} |
34 | | - """ |
35 | | - |
36 | | - read_pairs_ch = channel.fromFilePairs( params.reads, checkIfExists: true ) |
37 | | - RNASEQ( params.transcriptome, read_pairs_ch ) |
38 | | - MULTIQC( RNASEQ.out, params.multiqc ) |
| 67 | + summary: Path { |
| 68 | + path '.' |
| 69 | + } |
39 | 70 | } |
0 commit comments