-
Notifications
You must be signed in to change notification settings - Fork 0
/
trimmomatic_fastqc_star_stringtie_sorghum_paired-end.nf
156 lines (123 loc) · 3.99 KB
/
trimmomatic_fastqc_star_stringtie_sorghum_paired-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
#!/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
.fromFilePairs( params.reads, flat: true )
.ifEmpty { error "Cannot find any reads matching: ${params.reads}" }
.set { read_pairs }
Channel
.fromFilePairs( params.reads, flat: true )
.ifEmpty { error "Cannot find any reads matching: ${params.reads}" }
.set { fastqc_read_pairs }
/*
* Step 1. Clean the reads
*/
process cleanReads {
publishDir "$baseDir/data/reads/"
input:
set dataset_id, file(forward), file(reverse) from read_pairs
output:
set dataset_id, file("${dataset_id}_R1.TRIMMED.PAIRED.fq.gz"), file("${dataset_id}_R2.TRIMMED.PAIRED.fq.gz") into fastqc_paired_fastq
set dataset_id, file("${dataset_id}_R1.TRIMMED.UNPAIRED.fq.gz"), file("${dataset_id}_R2.TRIMMED.UNPAIRED.fq.gz") into unpaired_fastq
clusterOptions = { "--account=icbrbi --qos=icbrbi --time=4:00:00 --mem-per-cpu=3gb --cpus-per-task=1" }
module 'trimmomatic'
script:
"""
trimmomatic \
PE \
-trimlog /dev/null \
-threads ${task.cpus} \
$forward $reverse \
${dataset_id}_R1.TRIMMED.PAIRED.fq.gz ${dataset_id}_R1.TRIMMED.UNPAIRED.fq.gz \
${dataset_id}_R2.TRIMMED.PAIRED.fq.gz ${dataset_id}_R2.TRIMMED.UNPAIRED.fq.gz \
ILLUMINACLIP:/apps/trimmomatic/0.36/adapters/TruSeq3-PE-2.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"
input:
set dataset_id, file(r1), file(r2) from fastqc_paired_fastq
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 $r2
"""
}
/*
* Index Genome using STAR
*/
process indexReference {
publishDir "$baseDir/data/references/"
input:
file genome_gtf
file genome_fna
clusterOptions = {--account=icbrbi --qos=icbrbi --time=4:00:00 --mem-per-cpu=2gb --cpus-per-task=2}
module 'star'
script:
"""
STAR --runThreadN 2
--runMode genomeGenerate
--genomeDir ${baseDir}/data/references/
--genomeFastaFiles ${genome_fna}
--sjdbGTFfile ${genome_gtf}
--sjdbOverhang 100
"""
}
/*
* Align reads using STAR
*/
process alignReads {
publishDir "$baseDir/data/alignments/"
input:
set dataset_id, file(r1), file(r2) from fastqc_paired_fastq
output:
set dataset_id, file(bam_file) from bam_files
clusterOptions = {--account=icbrbi --qos=icbrbi --time=4:00:00 --mem-per-cpu=2gb --cpus-per-task=2}
module 'star'
script:
"""
STAR --runThreadN 2
--genomeDir ${baseDir}/data/references/
--genomeFastaFiles ${genome_fna}
--readFilesIn $r1 $r2
"""
}
/*
* Assembles the transcript using "stringtie"
* and publish the transcript output files into the `results` folder
*/
process makeTranscript {
input:
set dataset_id, file(bam_file) from bam_files
output:
set '*' into transcripts
clusterOptions = { "--account=icbrbi --qos=icbrbi --time=4:00:00 --mem-per-cpu=3gb --cpus-per-task=1 --no-requeue" }
module 'stringtie'
"""
stringtie -e -B -p ${task.cpus} -j 2 -o ${dataset_id}_transcripts.gtf -G ${genome_gtf} ${bam_file}
# mkdir ${baseDir}/results/${dataset_id}
# mv ${baseDir}/results/*.ctab ${baseDir}/results/${dataset_id}/
# mv ${baseDir}/results/*.gtf ${baseDir}/results/${dataset_id}/
"""
}