11#! /usr/bin/env nextflow
22/*
33 * This is free and unencumbered software released into the public domain.
4- *
4+ *
55 * Anyone is free to copy, modify, publish, use, compile, sell, or
66 * distribute this software, either in source code form or as a compiled
77 * binary, for any purpose, commercial or non-commercial, and by any
88 * means.
9- *
9+ *
1010 * In jurisdictions that recognize copyright laws, the author or authors
1111 * of this software dedicate any and all copyright interest in the
1212 * software to the public domain. We make this dedication for the benefit
1313 * of the public at large and to the detriment of our heirs and
1414 * successors. We intend this dedication to be an overt act of
1515 * relinquishment in perpetuity of all present and future rights to this
1616 * software under copyright law.
17- *
17+ *
1818 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1919 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2020 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
2121 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
2222 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
2323 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2424 * OTHER DEALINGS IN THE SOFTWARE.
25- *
25+ *
2626 * For more information, please refer to <http://unlicense.org/>
2727 */
28-
29-
30- /*
28+
29+
30+ /*
3131 * Proof of concept of a RNAseq pipeline implemented with Nextflow
32- *
32+ *
3333 * Authors:
3434 * - Paolo Di Tommaso <[email protected] > 35- * - Emilio Palumbo <[email protected] > 36- * - Evan Floden <[email protected] > 37- */
35+ * - Emilio Palumbo <[email protected] > 36+ * - Evan Floden <[email protected] > 37+ */
38+
3839
39-
4040params. reads = " $baseDir /data/ggal/*_{1,2}.fq"
4141params. transcriptome = " $baseDir /data/ggal/ggal_1_48850000_49020000.Ggal71.500bpflank.fa"
4242params. outdir = " ."
4343params. multiqc = " $baseDir /multiqc"
4444
45- log . info """ \
46- R N A S E Q - N F P I P E L I N E
47- ===================================
48- transcriptome: ${ params.transcriptome }
49- reads : ${ params.reads }
50- outdir : ${ params.outdir }
51- """
52- .stripIndent()
45+ workflow {
46+ log . info """ \
47+ R N A S E Q - N F P I P E L I N E
48+ ===================================
49+ transcriptome : ${ params.transcriptome }
50+ reads : ${ params.reads }
51+ outdir : ${ params.outdir }
52+ """ . stripIndent()
5353
54+ read_pairs_ch = channel. fromFilePairs( params. reads )
5455
55- transcriptome_file = file(params. transcriptome)
56- multiqc_file = file(params. multiqc)
57-
56+ index_ch = index( file(params. transcriptome) )
57+ fastqc_ch = fastqc( read_pairs_ch )
58+ quant_ch = quant( index_ch, read_pairs_ch )
59+
60+ multiqc_files_ch = quant_ch. mix(fastqc_ch). collect()
61+ multiqc( multiqc_files_ch, file(params. multiqc) )
62+ }
5863
59- Channel
60- .fromFilePairs( params. reads )
61- .ifEmpty { error " Cannot find any reads matching: ${ params.reads} " }
62- .into { read_pairs_ch; read_pairs2_ch }
63-
6464
6565process index {
6666 tag " $transcriptome_file . simpleName "
67-
67+
6868 input:
69- file transcriptome from transcriptome_file
70-
69+ path transcriptome
70+
7171 output:
72- file ' index' into index_ch
72+ path ' index'
7373
74- script:
74+ script:
7575 """
7676 salmon index --threads $task . cpus -t $transcriptome -i index
7777 """
7878}
79-
80-
81- process quant {
82- tag " $p air_id "
83-
79+
80+
81+ process fastqc {
82+ tag " FASTQC on $s ample_id "
83+
8484 input:
85- file index from index_ch
86- set pair_id, file(reads) from read_pairs_ch
87-
85+ tuple val(sample_id), path(reads)
86+
8887 output:
89- file(pair_id) into quant_ch
90-
88+ path( " fastqc_ ${ sample_id } _logs " )
89+
9190 script:
9291 """
93- salmon quant --threads $task . cpus --libType=U -i index -1 ${ reads[0]} -2 ${ reads[1]} -o $pair_id
92+ mkdir fastqc_${ sample_id} _logs
93+ fastqc -o fastqc_${ sample_id} _logs -f fastq -q ${ reads}
9494 """
9595}
96-
97- process fastqc {
98- tag " FASTQC on $sample_id "
96+
97+
98+ process quant {
99+ tag " $pair_id "
99100
100101 input:
101- set sample_id, file(reads) from read_pairs2_ch
102+ path index
103+ tuple val(pair_id), path(reads)
102104
103105 output:
104- file(" fastqc_${ sample_id} _logs" ) into fastqc_ch
105-
106+ path(pair_id)
106107
107108 script:
108109 """
109- mkdir fastqc_${ sample_id} _logs
110- fastqc -o fastqc_${ sample_id} _logs -f fastq -q ${ reads}
111- """
112- }
113-
114-
110+ salmon quant --threads $task . cpus --libType=U -i index -1 ${ reads[0]} -2 ${ reads[1]} -o $pair_id
111+ """
112+ }
113+
114+
115115process multiqc {
116116 publishDir params. outdir, mode:' copy'
117-
117+
118118 input:
119- file (' *' ) from quant_ch . mix(fastqc_ch) . collect( )
120- file (config) from multiqc_file
121-
119+ path (' *' )
120+ path (config)
121+
122122 output:
123- file (' multiqc_report.html' )
124-
123+ path (' multiqc_report.html' )
124+
125125 script:
126126 """
127127 cp $config /* .
128128 echo "custom_logo: \$ PWD/logo.png" >> multiqc_config.yaml
129- multiqc .
129+ multiqc .
130130 """
131131}
132-
133- workflow. onComplete {
134- println ( workflow. success ? " \n Done! Open the following report in your browser --> $params . outdir /multiqc_report.html\n " : " Oops .. something went wrong" )
135- }
0 commit comments