Newer
Older
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
#!/usr/bin/env nextflow
nextflow.enable.dsl=2
//syntax extension DSL2
/*
========================================================================================================================
Orelob
========================================================================================================================
bolero pipeline :
* Pipeline dedicated to transcription terminaison analysis of Hepatitis B Virus from nanopore seq
* Preprocessing, filtration, alignment, quantification.
****************************************************************
Help Message Definition
****************************************************************
*/
def helpMessage() {
log.info"""
Usage:
The typical command for running the pipeline is as follows:
nextflow ./src/orelob.nf -c ./src/nextflow.config -profile singularity
Nextflow parameters:
-profile [str] Configuration profile to use.
Available: docker, singularity, podman, psmn, ccin2p3
Mandatory arguments:
--input [path] Path to the folder containing fast5 files.
If skip basecalling option enabled, path to fastq files folder.
--adapt [file] Sequence of 3'RACE adapter.
--gsp [file] Sequence of gene-specific primer used in 3'RACE amplification step.
References:
--genome [file] Path to the fasta file containing the genome.
--gtf [file] Path to the gtf file containing the genome annotation.
Nanopore basecalling:
--skipBC [boolean] Skip basecalling step. If true, give fastq folder as input. Default: true.
--flowcell [str] Nanopore flowcell. Default = FLO-MIN106.
--kit [str] Nanopore kit. Default = SQK-PBK004.
--gpu_mode [boolean] Guppy basecaller configuration. Default: false.
"gpu" mode is dedicated to NVIDIA Cuda compatible system according to Guppy specifications.
Nanopore barcoding:
--kit_barcoding Nanopore barcoding kit.
--config_file Nanopore configuration file.
GPU basecalling parameters:
--min_qscore [float] Minimum quality score threshold, default = 7.0.
--gpu_runners_per_device [int] Number of runner per device, default = 32 (refer to guppy manual).
--num_callers [int] Number of callers, default = 16 (refer to guppy manual).
--chunks_per_runner [int] Number of chunks per runner, default = 512 (refer to guppy manual).
--chunk_size [int] Chunck size, default = 1900 (refer to guppy manual).
Help:
--help | --h Display this help message.
""".stripIndent()
}
// Show help message
params.help = ""
params.h = ""
if (params.help || params.h) {
helpMessage()
exit 0
}
/*
****************************************************************
Default Parameters
****************************************************************
*/
/* Params in */
params.skipBC = true
params.gpu_mode = false
params.adapt = ""
params.gsp = ""
params.genome = "/home/xavier/Data/Genome/202201_Full-length_HBV_GTFv3/20230516_HBV_FL_preCore_reference.fasta"
params.gtf = "/home/xavier/Data/Genome/202201_Full-length_HBV_GTFv3/20230516_GTF_preCore_FL_HBV_XGR.gtf"
params.flowcell = "FLO-MIN106"
params.kit = "SQK-PBK004"
params.min_qscore = 7.0
params.gpu_runners_per_device = 32
params.num_callers = 16
params.chunks_per_runner = 512
params.chunk_size = 1900
params.config_file = ""
params.kit_barcoding = ""
/* Params out */
params.basecalling_out = "01_basecalling/"
params.barcoding_out = "02_barcoding/"
params.fastq_out = "03_fastq/"
params.seqkit_grep_out = "03_fastq/"
params.porechop_out = "03_fastq/"
params.cutadapt_out = "04_cutadapt/"
params.minimap2_genome_out = "05_minimap2/"
params.filtered_bam_out = "05_minimap2/"
params.start_position_counts_out = "06_start_positions/"
params.nanosplicer_out = "07_nanosplicer/"
params.rna_count_out = "08_RNA_count/"
params.rna_qc_out = "09_quality_control/"
/*
****************************************************************
Logs
****************************************************************
*/
log.info "fast5/q folder : ${params.input}"
log.info "3'RACE adapter sequence : ${params.adapt}"
log.info "Gene specific primer : ${params.gsp}"
if(!params.skipBC) log.info "Guppy basecalling calculation using GPU mode : ${params.gpu_mode}."
log.info "Genome file : ${params.genome}"
log.info "Genome annotation file : ${params.gtf}"
/*
****************************************************************
Channel definitions
****************************************************************
*/
Channel
.of( params.input )
.ifEmpty { error "No fast5/q folder defined." }
.set { input }
Channel
.fromPath( params.genome )
.ifEmpty { error "No genome defined, a fasta file containing the full length preC RNA from HBV genome." }
.set { genome }
Channel
.fromPath( params.gtf )
.ifEmpty { error "No annotation defined, a gtf file describing transcripts and splice variants." }
.set { gtf }
Channel
.fromPath(params.input+'*/', type: 'dir')
.map(it -> [it.baseName, it])
.set{barcodes}
/*
****************************************************************
Imports
****************************************************************
*/
if(!params.skipBC) {
/* Hardware configuration, if Nvidia CUDA compatible graphic card is installed, use guppy-gpu, else guppy-cpu (much slower)*/
if(params.gpu_mode) {
include { basecall_fast5_gpu } from "./nf_modules/ont-guppy/main.nf"
include { barcoding_gpu } from "./nf_modules/ont-guppy/main.nf"
}
else {
include { basecall_fast5_cpu } from "./nf_modules/ont-guppy/main.nf"
include { barcoding_cpu } from "./nf_modules/ont-guppy/main.nf"
}
}
include { barcoding_cpu } from "./nf_modules/ont-guppy/main.nf"
include { control_basecalling } from "./nf_modules/pycoqc/main.nf"
include { control_bam } from "./nf_modules/pycoqc/main.nf"
include { concatenate } from "./nf_modules/seqkit/main.nf"
include { cut_5pRACE } from "./nf_modules/cutadapt/main.nf"
include { hbv_genome } from "./nf_modules/minimap2/main.nf"
include { seqkit_grep } from "./nf_modules/seqkit/main.nf"
include { sort_bam } from './nf_modules/samtools/main.nf' addParams(sort_bam_out: params.minimap2_genome_out)
include { index_bam } from './nf_modules/samtools/main.nf' addParams(index_bam_out: params.minimap2_genome_out)
include { sort_index_bam } from './nf_modules/samtools/main.nf' addParams(indexed_bam_out: params.minimap2_genome_out)
include { filter_as } from './nf_modules/samtools/main.nf'
include { start_position_counts } from "./nf_modules/samtools/main.nf"
include { start_position_individuals } from "./nf_modules/start_positions/main.nf"
include { jwr_checker } from "./nf_modules/nanosplicer/main.nf"
include { junctions_nanosplicer } from "./nf_modules/junction_nanosplicer/main.nf"
include { rna_count } from "./nf_modules/rna_count/main.nf"
include { porechop } from "./nf_modules/porechop/main.nf"
include { trimmming_pychopper } from "./nf_modules/pychopper/main.nf"
/*
****************************************************************
Workflow
****************************************************************
*/
workflow {
if(params.skipBC) { // we take fastq files as input and skip basecalling
concatenate(barcodes)
}
else { // we take fast5 files as input and proceed to basecalling with guppy
if(params.gpu_mode) {
basecall_fast5_gpu(input)
if(params.kit_barcoding != ""){
barcoding_gpu(basecall_fast5_gpu.out.pass)
barcoding_gpu.out.barcodes
.flatten()
.map{it -> [it.name, it]}
.set{tuples_barcode}
concatenate(tuples_barcode)
}
else{
basecall_fast5_gpu.out.pass
.map{it -> ["Sample", it]}
.set{tuple_sample}
concatenate(tuple_sample)
}
}
else {
basecall_fast5_cpu(input)
if(params.kit_barcoding != ""){
barcoding_cpu(basecall_fast5_cpu.out.pass)
barcoding_cpu.out.barcodes
.flatten()
.map{it -> [it.name, it]}
.set{tuples_barcode}
concatenate(tuples_barcode)
}
else{
basecall_fast5_cpu.out.pass
.map{it -> ["Sample", it]}
.set{tuple_sample}
concatenate(tuple_sample)
}
}
}
//####################### PREPROCESSING #######################
//Filtration (seqkit_grep looks for the 5'RACE and the gsp patterns in the reads to keep only mature ARNs)
seqkit_grep(concatenate.out.merged_fastq, params.adapt, params.gsp)
//Trimming with porechop
porechop(seqkit_grep.out.filtered_fastq)
//Trimming with pychopper
//trimmming_pychopper(seqkit_grep.out.filtered_fastq)
//Cut of the 5'RACE sequence
cut_5pRACE(porechop.out.porechoped_fastq, params.adapt)
//cut_5pRACE(trimmming_pychopper.out.pychoped_fastq, params.adapt)
//cut_5pRACE(seqkit_grep.out.filtered_fastq, params.adapt)
//########################## MAPPING ##########################
hbv_genome(cut_5pRACE.out.fastq_cutadapt, genome.collect())
//Filter
filter_as(hbv_genome.out.bam)
//Index
sort_index_bam(filter_as.out.filtered_bam)
//Quality control
if(params.skipBC == false) {
if(params.gpu_mode) {
control_bam(basecall_fast5_gpu.out.sequencing_summary.collect(), sort_index_bam.out.indexed_bam)
}
else {
control_bam(basecall_fast5_cpu.out.sequencing_summary.collect(), sort_index_bam.out.indexed_bam)
}
}
//###################### START POSITIONS #######################
//Identification of start positions
start_position_counts(sort_index_bam.out.indexed_bam)
//Identification of RNA
start_position_individuals(start_position_counts.out.count)
//#################### VARIANTS D'EPISSAGE ####################
//Identification of splicing junction sites
jwr_checker(sort_index_bam.out.indexed_bam)
start_position_individuals.out.classification_of_reads
.combine(jwr_checker.out.nanosplicer_jwr, by: 0)
.set{files_for_nanosplicer}
//Identification of variants
junctions_nanosplicer(files_for_nanosplicer)
//#################### VARIANTS D'EPISSAGE ####################
junctions_nanosplicer.out.identified_SPvariants
.combine(start_position_individuals.out.classification_of_reads, by: 0)
.set{files_for_rna_count}
//Variants count
rna_count(files_for_rna_count)
}
// End message:
workflow.onComplete {
println ( workflow.success ? """
DUPFinder tools execution summary
---------------------------
Completed at : ${workflow.complete}
Duration : ${workflow.duration}
Success : ${workflow.success}
workDir : ${workflow.workDir}
exit status : ${workflow.exitStatus}
""" : """
Failed: ${workflow.errorReport}
exit status : ${workflow.exitStatus}
"""
)
}