-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.nf
executable file
·197 lines (140 loc) · 5.64 KB
/
main.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
192
193
194
195
196
197
#!/usr/bin/env nextflow
nextflow.enable.dsl=2
/* ========================================================================================
INPUT FILES
======================================================================================== */
params.input = null
input_files = file(params.input)
/* ========================================================================================
OUTPUT DIRECTORY
======================================================================================== */
params.outdir = false
if(params.outdir){
outdir = params.outdir
} else {
outdir = '.'
}
/* ========================================================================================
SKIP STEPS
======================================================================================== */
params.skip_fastq_screen = false
params.skip_trim_galore = false
/* ========================================================================================
DEFAULT PARAMETERS
======================================================================================== */
params.fastqc_args = ''
params.fastq_screen_args = ''
params.trim_galore_args = ''
params.multiqc_args = ''
fastqc_args = params.fastqc_args
fastq_screen_args = params.fastq_screen_args
trim_galore_args = params.trim_galore_args
multiqc_args = params.multiqc_args
// Force to input files to be single-end
params.single_end = false
// Sequencing method
params.seq_method = ''
// FastQ Screen config file directory
params.fastq_screen_conf = "/cluster/work/nme/software/config/fastq_screen.conf"
// FastQ Screen bisulfite parameter
params.bisulfite = false
bisulfite = params.bisulfite
// Trim Galore clip parameter
params.clip_r1 = false
params.clip_r2 = false
clip_r1 = params.clip_r1
clip_r2 = params.clip_r2
/* ========================================================================================
TRIM GALORE PARAMETERS
======================================================================================== */
// PBAT
if(params.seq_method == 'PBAT'){
clip_r1 = 9
clip_r2 = clip_r1
bisulfite = true
trim_galore_args += " --clip_r1 $clip_r1 "
}
// RRBS
if(params.seq_method == 'RRBS'){
bisulfite = true
trim_galore_args += " --rrbs "
}
// SINGLE-CELL
if(params.seq_method == 'Single-cell'){
clip_r1 = 6
clip_r2 = clip_r1
bisulfite = false
trim_galore_args += " --clip_r1 $clip_r1 "
}
/* ========================================================================================
FASTQ SCREEN PARAMETERS
======================================================================================== */
// BISULFITE
if (params.bisulfite){
fastq_screen_args += " --bisulfite "
} else {
if (bisulfite){
fastq_screen_args += " --bisulfite "
}
}
/* ========================================================================================
FILES CHANNEL
======================================================================================== */
include { makeFilesChannel; getFileBaseNames } from './modules/files.mod.nf'
file_ch = makeFilesChannel(input_files)
/* ========================================================================================
WORKFLOW
======================================================================================== */
include { FASTQC } from './modules/fastqc.mod.nf'
include { FASTQC as FASTQC2 } from './modules/fastqc.mod.nf'
include { FASTQ_SCREEN } from './modules/fastq_screen.mod.nf' params(fastq_screen_conf: params.fastq_screen_conf)
include { TRIM_GALORE } from './modules/trim_galore.mod.nf' params(clip_r2: clip_r2)
include { MULTIQC } from './modules/multiqc.mod.nf'
workflow {
main:
if (!params.skip_fastq_screen){
if (!params.skip_trim_galore){
FASTQC (file_ch, outdir, fastqc_args)
FASTQ_SCREEN (file_ch, outdir, fastq_screen_args)
TRIM_GALORE (file_ch, outdir, trim_galore_args)
FASTQC2 (TRIM_GALORE.out.reads, outdir, fastqc_args)
} else {
FASTQC (file_ch, outdir, fastqc_args)
FASTQ_SCREEN (file_ch, outdir, fastq_screen_args)
}
} else {
if (!params.skip_trim_galore){
FASTQC (file_ch, outdir, fastqc_args)
TRIM_GALORE (file_ch, outdir, trim_galore_args)
FASTQC2 (TRIM_GALORE.out.reads, outdir, fastqc_args)
} else {
FASTQC (file_ch, outdir, fastqc_args)
}
}
/* ========================================================================================
Reports
======================================================================================== */
if (!params.skip_fastq_screen){
if (!params.skip_trim_galore){
multiqc_ch = FASTQC.out.report.mix(
TRIM_GALORE.out.report,
FASTQ_SCREEN.out.report.ifEmpty([]),
FASTQC2.out.report.ifEmpty([])
).collect()
} else {
multiqc_ch = FASTQC.out.report.mix(
FASTQ_SCREEN.out.report.ifEmpty([])
).collect()
}
} else {
if (!params.skip_trim_galore){
multiqc_ch = FASTQC.out.report.mix(
TRIM_GALORE.out.report,
FASTQC2.out.report.ifEmpty([])
).collect()
} else {
multiqc_ch = FASTQC.out.report.collect()
}
}
MULTIQC (multiqc_ch, outdir, multiqc_args)
}