-
Notifications
You must be signed in to change notification settings - Fork 0
/
trimmomatic_fastqc_star_stringtie_single-end.nf
191 lines (152 loc) · 4.34 KB
/
trimmomatic_fastqc_star_stringtie_single-end.nf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#!/usr/bin/env nextflow
/*
* Defines pipeline parameters in order to specify the refence genomes
* and read pairs by using the command line options
*/
params.reads = "$baseDir/data/reads/*fq.gz"
params.genome = "$baseDir/data/references/GCF_000003195.3_Sorghum_bicolor_NCBIv3_genomic.fna"
params.gtf = "$baseDir/data/references/GCF_000003195.3_Sorghum_bicolor_NCBIv3_genomic.gtf"
/*
* The reference genome file
*/
genome_gtf = file(params.gtf)
genome_fna = file(params.genome)
Channel
.fromPath( params.reads )
.ifEmpty { error "Cannot find any reads matching: ${params.reads}" }
.map { file -> tuple(file.simpleName, file) }
.into { reads; fastqc_reads }
/*
* QC raw reads
*/
process preFastqc {
publishDir "results/fastqc/pre/"
input:
set val(dataset_id), file(r1) from fastqc_reads
output:
file "*_fastqc.{zip,html}" into raw_fastqc_results
clusterOptions = { "--account=icbrbi --qos=icbrbi --time=4:00:00 --mem-per-cpu=2gb --cpus-per-task=1" }
module 'fastqc'
script:
"""
fastqc -q ${r1}
"""
}
/*
* Clean the reads
*/
process cleanReads {
publishDir "$baseDir/results/reads/"
input:
set val(dataset_id), file(forward) from reads
output:
set dataset_id, file("${dataset_id}.TRIMMED.fq.gz") into trimmed_reads
file("${dataset_id}.TRIMMED.fq.gz") into trimmed_reads_2
clusterOptions = { "--account=icbrbi --qos=icbrbi --time=4:00:00 --mem-per-cpu=3gb --cpus-per-task=1" }
module 'trimmomatic'
script:
"""
trimmomatic \
SE \
-trimlog /dev/null \
-threads ${task.cpus} \
${forward} ${dataset_id}.TRIMMED.fq.gz \
ILLUMINACLIP:/apps/trimmomatic/0.36/adapters/TruSeq3-SE.fa:2:30:10:2:true \
LEADING:3 \
TRAILING:3 \
SLIDINGWINDOW:4:15 \
MAXINFO:40:0.3 \
MINLEN:40
"""
}
/*
* QC trimmed reads
*/
process postFastqc {
publishDir "results/fastqc/post/"
input:
set val(dataset_id), file(r1) from trimmed_reads
output:
file "*_fastqc.{zip,html}" into trimmed_fastqc_results
clusterOptions = { "--account=icbrbi --qos=icbrbi --time=4:00:00 --mem-per-cpu=2gb --cpus-per-task=1" }
module 'fastqc'
script:
"""
fastqc -q ${r1}
"""
}
/*
* Index Genome using STAR
*/
process indexReference {
publishDir "$baseDir/data/references/"
input:
file genome_gtf from genome_gtf
file genome_fna from genome_fna
output:
file '*' into indexed
clusterOptions = { "--account=icbrbi --qos=icbrbi --time=5:00:00 --mem-per-cpu=5gb --cpus-per-task=4" }
module 'star'
script:
"""
STAR --runThreadN 4 \
--runMode genomeGenerate \
--genomeDir ${baseDir}/data/references/ \
--genomeFastaFiles ${genome_fna} \
--sjdbGTFfile ${genome_gtf} \
--sjdbOverhang 100
"""
}
/*
* Align reads using STAR
*/
process alignReads {
publishDir "$baseDir/results/alignments/"
input:
file '*' from indexed
file r1 from trimmed_reads_2
output:
file "*.bam" into bam_files
clusterOptions = { "--account=icbrbi --qos=icbrbi --time=4:00:00 --mem-per-cpu=10gb --cpus-per-task=4" }
module 'star'
script:
"""
STAR --runThreadN 4 \
--readFilesCommand zcat \
--genomeDir ${baseDir}/data/references/ \
--genomeFastaFiles ${genome_fna} \
--readFilesIn ${r1} \
--outFileNamePrefix ${r1.simpleName}. \
--outSAMattributes Standard \
--outSAMtype BAM SortedByCoordinate
"""
}
/*
* Assembles the transcript using "stringtie"
* and publish the transcript output files into the `results` folder
*/
process makeTranscript {
input:
file(bam_file) from bam_files
output:
file '*' into transcripts
clusterOptions = { "--account=icbrbi --qos=icbrbi --time=4:00:00 --mem-per-cpu=3gb --cpus-per-task=2 --no-requeue" }
module 'stringtie'
"""
stringtie -e -B -p ${task.cpus} -j 2 -o ${bam_file.simpleName}_transcripts.gtf -G ${genome_gtf} ${bam_file}
"""
}
workflow.onComplete {
def subject = 'My pipeline execution'
def recipient = 'lboat@ufl.edu'
['mail', '-s', subject, recipient].execute() << """
Pipeline execution summary
---------------------------
Completed at: ${workflow.complete}
Duration : ${workflow.duration}
Success : ${workflow.success}
workDir : ${workflow.workDir}
exit status : ${workflow.exitStatus}
Error report: ${workflow.errorReport ?: '-'}
"""
}