forked from oliverSI/GATK4_Best_Practice
-
Notifications
You must be signed in to change notification settings - Fork 15
/
main.nf
701 lines (569 loc) · 20.6 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
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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
#!/usr/bin/env nextflow
VERSION="0.2"
log.info "===================================================================="
log.info "GATK4 Best Practice Nextflow Pipeline (v${VERSION}) "
log.info "===================================================================="
params.help = ""
if (params.help) {
log.info " "
log.info "USAGE: "
log.info " "
log.info "nextflow run oliverSI/GATK4_Best_Practice --fastq1 read_R1.fastq.gz --fastq2 read_R2.fastq.gz"
log.info " "
log.info "Mandatory arguments:"
log.info " --fastq1 FILE Fastq(.gz) file for read1"
log.info " --fastq2 FILE Fastq(.gz) file for read2"
log.info " "
log.info "Optional arguments:"
log.info " --outdir DIR Output directory(default: ./Results)"
log.info " --samplename STRING Sample name(dafault: fastq1 basename)"
log.info " --rg STRING Read group tag(dafault: fastq1 basename)"
log.info " "
log.info "===================================================================="
exit 1
}
// Validate inputs
params.fasta = params.genome ? params.genomes[ params.genome ].fasta ?: false : false
if (params.fasta) {
Channel.fromPath(params.fasta)
.ifEmpty { exit 1, "fasta annotation file not found: ${params.fasta}" }
.into { fasta_scatter_intervals; fasta_bwa; fasta_baserecalibrator; fasta_haplotypecaller; fasta_genotypeVcfs; fasta_variantrecalibrator_snps; fasta_variantrecalibrator_tranches; fasta_variant_eval; fasta_structural_variantcaller }
}
params.fai = params.genome ? params.genomes[ params.genome ].fai ?: false : false
if (params.fai) {
Channel.fromPath(params.fai)
.ifEmpty { exit 1, "fai annotation file not found: ${params.fai}" }
.into { fai_scatter_intervals; fai_bwa; fai_baserecalibrator; fai_haplotypecaller; fai_genotypeVcfs; fai_variantrecalibrator_snps; fai_variantrecalibrator_tranches; fai_variant_eval; fai_structural_variantcaller }
}
params.dict = params.genome ? params.genomes[ params.genome ].dict ?: false : false
if (params.dict) {
Channel.fromPath(params.dict)
.ifEmpty { exit 1, "dict annotation file not found: ${params.dict}" }
.into { dict_scatter_intervals; dict_bwa; dict_baserecalibrator; dict_haplotypecaller; dict_genotypeVcfs; dict_variantrecalibrator_snps; dict_variantrecalibrator_tranches; dict_variant_eval }
}
params.dbsnp_gz = params.genome ? params.genomes[ params.genome ].dbsnp_gz ?: false : false
if (params.dbsnp_gz) {
Channel.fromPath(params.dbsnp_gz)
.ifEmpty { exit 1, "dbsnp annotation file not found: ${params.dbsnp_gz}" }
.set { dbsnp_gz}
}
params.dbsnp_idx_gz = params.genome ? params.genomes[ params.genome ].dbsnp_idx_gz ?: false : false
if (params.dbsnp_idx_gz) {
Channel.fromPath(params.dbsnp_idx_gz)
.ifEmpty { exit 1, "dbsnp_idx_gz annotation file not found: ${params.dbsnp_idx_gz}" }
.set { dbsnp_idx_gz}
}
params.golden_indel_gz = params.genome ? params.genomes[ params.genome ].golden_indel_gz ?: false : false
if (params.golden_indel_gz) {
Channel.fromPath(params.golden_indel_gz)
.ifEmpty { exit 1, "golden_indel_gz annotation file not found: ${params.golden_indel_gz}" }
.set { golden_indel_gz }
}
params.golden_indel_idx_gz = params.genome ? params.genomes[ params.genome ].golden_indel_idx_gz ?: false : false
if (params.golden_indel_idx_gz) {
Channel.fromPath(params.golden_indel_idx_gz)
.ifEmpty { exit 1, "golden_indel_idx_gz annotation file not found: ${params.golden_indel_idx_gz}" }
.set { golden_indel_idx_gz }
}
params.bwa_index_amb = params.genome ? params.genomes[ params.genome ].bwa_index_amb ?: false : false
if (params.bwa_index_amb) {
Channel.fromPath(params.bwa_index_amb)
.ifEmpty { exit 1, "bwa_index_amb annotation file not found: ${params.bwa_index_amb}" }
.set { bwa_index_amb }
}
params.bwa_index_ann = params.genome ? params.genomes[ params.genome ].bwa_index_ann ?: false : false
if (params.bwa_index_ann) {
Channel.fromPath(params.bwa_index_ann)
.ifEmpty { exit 1, "bwa_index_ann annotation file not found: ${params.bwa_index_ann}" }
.set { bwa_index_ann }
}
params.bwa_index_bwt = params.genome ? params.genomes[ params.genome ].bwa_index_bwt ?: false : false
if (params.bwa_index_bwt) {
Channel.fromPath(params.bwa_index_bwt)
.ifEmpty { exit 1, "bwa_index_bwt annotation file not found: ${params.bwa_index_bwt}" }
.set { bwa_index_bwt }
}
params.bwa_index_pac = params.genome ? params.genomes[ params.genome ].bwa_index_pac ?: false : false
if (params.bwa_index_pac) {
Channel.fromPath(params.bwa_index_pac)
.ifEmpty { exit 1, "bwa_index_pac annotation file not found: ${params.bwa_index_pac}" }
.set { bwa_index_pac }
}
params.bwa_index_sa = params.genome ? params.genomes[ params.genome ].bwa_index_sa ?: false : false
if (params.bwa_index_sa) {
Channel.fromPath(params.bwa_index_sa)
.ifEmpty { exit 1, "bwa_index_sa annotation file not found: ${params.bwa_index_sa}" }
.set { bwa_index_sa }
}
if (params.intervals) {
Channel.fromPath(params.intervals)
.ifEmpty { exit 1, "Interval list file for HaplotypeCaller not found: ${params.intervals}" }
.set { intervals_input }
}
if (params.bai) {
Channel.fromPath(params.bai)
.ifEmpty { exit 1, "BAM index file not found: ${params.bai}" }
.set { bai }
}
// set threadmem equal to total memory divided by number of threads
int threads = Runtime.getRuntime().availableProcessors()
threadmem = (((Runtime.getRuntime().maxMemory() * 4) / threads) as nextflow.util.MemoryUnit)
// More memory for RunBam processes
threadmem_more = 4 * threadmem
// Added soft-coded method but hard-coded value of cpu-sage percentage for StructuralVariantCallers process
// ToDo: Expose the hard-coded value as parameter if needed in the future for user to allocate resources at will
// Declaring percentage of total cpus (aka 'threads' var) to be allocated to StructuralVariantCallers process
cpu_percentage = 1
// Multiplying & converting java.math.BigDecimal object to java.lang.Integer
// Check object type with 'my_object.getClass()' method
// More info here: https://www.geeksforgeeks.org/bigdecimal-intvalue-method-in-java/
cpus_to_use_StructVarCall = (cpu_percentage * threads).intValue()
/*
* Create a channel for input read files
* Dump can be used for debugging purposes, e.g. using the -dump-channels operator on run
*/
if (params.reads) {
Channel
.fromPath(params.reads)
.map { file -> tuple(file.baseName, file) }
.ifEmpty { exit 1, "Cannot find any reads matching: ${reads}\nNB: Path needs to be enclosed in quotes!\nIf this is single-end data, please specify --singleEnd on the command line." }
.into { reads_fastqc; reads_files }
reads_files
.combine(fasta_bwa)
.dump(tag:'input')
.set { reads_bwa }
} else if (params.reads_folder){
reads="${params.reads_folder}/${params.reads_prefix}_{1,2}.${params.reads_extension}"
Channel
.fromFilePairs(reads, size: 2)
.ifEmpty { exit 1, "Cannot find any reads matching: ${reads}\nNB: Path needs to be enclosed in quotes!\nIf this is single-end data, please specify --singleEnd on the command line." }
.into { reads_fastqc; reads_files}
reads_files
.combine(fasta_bwa)
.dump(tag:'input')
.set { reads_bwa }
} else if (params.bam) {
Channel.fromPath(params.bam)
.map { file -> tuple(file.baseName, file) }
.ifEmpty { exit 1, "BAM file not found: ${params.bam}" }
.set { bam_bqsr }
} else {
exit 1, "Please specify either --reads singleEnd.fastq, --reads_folder pairedReads or --bam myfile.bam"
}
scattered_intervals_ref = fasta_scatter_intervals.merge(fai_scatter_intervals, dict_scatter_intervals)
process ScatterIntervals {
tag "$fasta"
container 'broadinstitute/gatk:latest'
input:
set file(fasta), file(fai), file(dict) from scattered_intervals_ref
output:
file("skip_Ns.interval_list") into scattered_intervals
script:
"""
gatk ScatterIntervalsByNs \
-O skip_Ns.interval_list \
-R ${fasta} \
--MAX_TO_MERGE 1000000 \
--OUTPUT_TYPE ACGT \
--VERBOSITY ERROR
"""
}
process SkipIntervals {
tag "$intervals"
container 'broadinstitute/gatk:latest'
input:
file(intervals) from scattered_intervals
output:
file("skip_Ns.bed") into skipped_intervals
script:
"""
grep -v @ ${intervals}
#awk '{print \$1":"\$2"-"\$3}'
awk 'BEGIN { OFS = "" }{ print \$1,":",\$2,"-",\$3 }' ${intervals} > intervals.interval_list
gatk IntervalListToBed \
-I ${intervals} \
-O skip_Ns.bed
"""
}
process MakeIntervals {
tag "$intervals"
container 'broadinstitute/gatk:latest'
publishDir "${params.outdir}", mode: 'copy'
input:
file intervals from intervals_input
file bed from skipped_intervals
output:
file("ACGTmers_interval_size.interval_list") into expanded_intervals
script:
"""
cut -f 1-3 $bed > ACGTmers.per-interval.bed
awk '{print \$1, \$2, \$3, \$3-\$2}' $bed | sort -k4nr | cut -f 1-3 > ACGTmers_interval_size.bed
awk '{print \$1":"\$2+1"-"\$3}' ACGTmers.per-interval.bed > ACGTmers.per-interval.txt
grep -v @ $intervals | sed 's/:/\\t/' | sed 's/-/\\t/' | cut -f 1-3 > target_temp
bedtools intersect -a ACGTmers.per-interval.bed -b target_temp -wa | awk '{print \$1":"\$2+1"-"\$3}' | sort -u > ACGTmers_interval_target_intersect.txt
cp ACGTmers_interval_size.bed ACGTmers_interval_size_temp.txt
awk 'FNR==NR{a[\$1] = \$1;next}{if (\$1 in a) print \$1}' ACGTmers_interval_size_temp.txt ACGTmers_interval_target_intersect.txt > ACGTmers.per-interval_temp.txt
awk 'FNR==NR{a[\$1] = \$1;next}{if (\$1 in a) print \$1}' ACGTmers_interval_target_intersect.txt ACGTmers.per-interval.txt > ACGTmers_interval_size.interval_list
mv ACGTmers.per-interval_temp.txt ACGTmers.per-interval.txt
"""
}
expanded_intervals.into { intervals_file; split_intervals}
split_intervals
.splitText()
.map { it -> it.trim() }
.set { interval }
if (!params.bam) {
process fastqc {
tag "$name"
publishDir "${params.outdir}/fastqc", mode: 'copy',
saveAs: {filename -> filename.indexOf(".zip") > 0 ? "zips/$filename" : "$filename"}
container 'flowcraft/fastqc:0.11.7-1'
input:
set val(name), file(reads) from reads_fastqc
output:
file "*_fastqc.{zip,html}" into fastqc_results
when: !params.skip_multiqc
script:
"""
fastqc -q $reads
"""
}
process gunzip_dbsnp {
tag "$dbsnp_gz"
input:
file dbsnp_gz from dbsnp_gz
file dbsnp_idx_gz from dbsnp_idx_gz
output:
file "*.vcf" into dbsnp, dbsnp_variantrecalibrator_snps, dbsnp_variantrecalibrator_indels
file "*.vcf.idx" into dbsnp_idx, dbsnp_idx_variantrecalibrator_snps, dbsnp_idx_variantrecalibrator_indels
script:
if ( "${dbsnp_gz}".endsWith(".gz") ) {
"""
gunzip -d --force $dbsnp_gz
gunzip -d --force $dbsnp_idx_gz
"""
} else {
"""
cp $dbsnp_gz dbsnp.vcf
cp $dbsnp_idx_gz dbsnp.vcf.idx
"""
}
}
process gunzip_golden_indel {
tag "$golden_indel_gz"
input:
file golden_indel_gz from golden_indel_gz
file golden_indel_idx_gz from golden_indel_idx_gz
output:
file "*.vcf" into golden_indel, golden_indel_variantrecalibrator_indels
file "*.vcf.idx" into golden_indel_idx, golden_indel_idx_variantrecalibrator_indels
script:
if ( "${golden_indel_gz}".endsWith(".gz") ) {
"""
gunzip -d --force $golden_indel_gz
gunzip -d --force $golden_indel_idx_gz
"""
} else {
"""
cp $golden_indel_gz golden_indel.vcf
cp $golden_indel_idx_gz golden_indel.vcf.idx
"""
}
}
bwa_index = bwa_index_amb.merge(bwa_index_ann, bwa_index_bwt, bwa_index_pac, bwa_index_sa)
bwa = reads_bwa.combine(bwa_index)
process BWA {
tag "$reads"
container 'kathrinklee/bwa:latest'
input:
set val(name), file(reads), file(fasta), file(amb), file(ann), file(bwt), file(pac), file(sa) from bwa
output:
set val(name), file("${name}.sam") into sam
"""
bwa mem -M -R '@RG\\tID:${name}\\tSM:${name}\\tPL:Illumina' $fasta $reads > ${name}.sam
"""
}
process BWA_sort {
tag "$sam"
container 'lifebitai/samtools:latest'
input:
set val(name), file(sam) from sam
output:
set val(name), file("${name}-sorted.bam") into bam_sort, bam_sort_qc
"""
samtools sort -o ${name}-sorted.bam -O BAM $sam
"""
}
process RunBamQCmapped {
tag "$bam"
container 'maxulysse/sarek:2.3'
memory threadmem_more
cpus 4
input:
set val(name), file(bam) from bam_sort_qc
output:
file("${name}") into bamQCmappedReport
when: !params.skip_multiqc
script:
"""
qualimap \
bamqc \
-bam ${bam} \
--paint-chromosome-limits \
--genome-gc-distr HUMAN \
-nt ${task.cpus} \
-skip-duplicated \
--skip-dup-mode 0 \
-outdir ${name} \
-outformat HTML
"""
}
process MarkDuplicates {
tag "$bam_sort"
container 'broadinstitute/gatk:latest'
input:
set val(name), file(bam_sort) from bam_sort
output:
set val(name), file("${name}_MarkDup.bam") into bam_markdup_baserecalibrator, bam_markdup_applybqsr
file "metrics.txt" into markdup_multiqc
"""
gatk MarkDuplicates -I $bam_sort -M metrics.txt -O ${name}_MarkDup.bam
"""
}
baserecalibrator_index = fasta_baserecalibrator.merge(fai_baserecalibrator, dict_baserecalibrator, dbsnp, dbsnp_idx, golden_indel, golden_indel_idx)
baserecalibrator = bam_markdup_baserecalibrator.combine(baserecalibrator_index)
process BaseRecalibrator {
tag "$bam_markdup"
container 'broadinstitute/gatk:latest'
input:
set val(name), file(bam_markdup), file(fasta), file(fai), file(dict), file(dbsnp), file(dbsnp_idx), file(golden_indel), file(golden_indel_idx) from baserecalibrator
output:
set val(name), file("${name}_recal_data.table") into baserecalibrator_table
file ("*data.table") into baseRecalibratorReport
"""
gatk BaseRecalibrator \
-I $bam_markdup \
--known-sites $dbsnp \
--known-sites $golden_indel \
-O ${name}_recal_data.table \
-R $fasta
"""
}
applybqsr = baserecalibrator_table.join(bam_markdup_applybqsr)
process ApplyBQSR {
tag "$baserecalibrator_table"
container 'broadinstitute/gatk:latest'
input:
set val(name), file(baserecalibrator_table), file(bam_markdup) from applybqsr
output:
set val(name), file("${name}_bqsr.bam") into bam_bqsr
script:
"""
gatk ApplyBQSR -I $bam_markdup -bqsr $baserecalibrator_table -O ${name}_bqsr.bam
"""
}
}
if (!params.bai){
process IndexBam {
tag "$bam"
publishDir "${params.outdir}/Bam", mode: 'copy'
container 'lifebitai/samtools:latest'
input:
set val(name), file(bam) from bam_bqsr
output:
set val(name), file("ready/${bam}"), file("ready/${bam}.bai") into indexed_bam_bqsr, indexed_bam_qc, indexed_bam_structural_variantcaller
script:
"""
mkdir ready
[[ `samtools view -H ${bam} | grep '@RG' | wc -l` > 0 ]] && { mv $bam ready;}|| { picard AddOrReplaceReadGroups \
I=${bam} \
O=ready/${bam} \
RGID=${params.rgid} \
RGLB=${params.rglb} \
RGPL=${params.rgpl} \
RGPU=${params.rgpu} \
RGSM=${params.rgsm};}
cd ready ;samtools index ${bam};
"""
}
} else {
bam_bqsr.merge(bai).into { indexed_bam_bqsr; indexed_bam_qc; indexed_bam_structural_variantcaller }
}
process RunBamQCrecalibrated {
tag "$bam"
container 'maxulysse/sarek:2.3'
memory threadmem_more
cpus 4
input:
set val(name), file(bam), file(bai) from indexed_bam_qc
output:
file("${name}_recalibrated") into bamQCrecalibratedReport
when: !params.skip_multiqc
script:
"""
qualimap \
bamqc \
-bam ${bam} \
--paint-chromosome-limits \
--genome-gc-distr HUMAN \
-nt ${task.cpus} \
--java-mem-size=${task.memory.toGiga()}G \
-skip-duplicated \
--skip-dup-mode 0 \
-outdir ${name}_recalibrated \
-outformat HTML
"""
}
haplotypecaller_index = fasta_haplotypecaller.merge(fai_haplotypecaller, dict_haplotypecaller, indexed_bam_bqsr, intervals_file)
haplotypecaller = interval.combine(haplotypecaller_index)
process HaplotypeCaller {
tag "$interval"
container 'broadinstitute/gatk:latest'
memory threadmem
input:
set val(interval), file(fasta), file(fai), file(dict), val(sample), file(bam_bqsr), file(bai), file(intervals_file) from haplotypecaller
output:
file("${sample}.vcf") into haplotypecaller_Vcf
file("${sample}.vcf.idx") into index
val(sample) into sample
script:
int mem = (Runtime.getRuntime().totalMemory()) >> 30
"""
gatk HaplotypeCaller \
--java-options -Xmx${task.memory.toMega()}M \
-R $fasta \
-O ${sample}.vcf \
-I $bam_bqsr \
-L $interval \
-isr INTERSECTION \
--native-pair-hmm-threads 1 \
-ip 100 \
--max-alternate-alleles 3 \
-contamination 0 \
-L $intervals_file \
--QUIET
"""
}
process MergeVCFs {
tag "${name[0]}.vcf"
publishDir "${params.outdir}", mode: 'copy'
container 'broadinstitute/gatk:latest'
input:
file ('*.vcf') from haplotypecaller_Vcf.collect()
file ('*.vcf.idx') from index.collect()
val name from sample.collect()
output:
set val("${name[0]}"), file("${name[0]}.vcf"), file("${name[0]}.vcf.idx") into vcf_bcftools, vcf_variant_eval
script:
"""
## make list of input variant files
for vcf in \$(ls *vcf); do
echo \$vcf >> input_variant_files.list
done
gatk MergeVcfs \
--INPUT= input_variant_files.list \
--OUTPUT= ${name[0]}.vcf
"""
}
// Adding structural variant callers with parliament2
// Input data: -- fasta --fai --bam --bai
// channel with inpu files: fasta, fai from params in the beginning, bam and bai from IndexBam process
input_structural_variantcaller = indexed_bam_structural_variantcaller.merge(fasta_structural_variantcaller, fai_structural_variantcaller)
process StructuralVariantCallers {
tag "$bam"
container 'lifebitai/parliament2:latest'
publishDir "${params.outdir}/parliament2", mode: 'copy'
// Allocate cpus to be utilised in this process
cpus cpus_to_use_StructVarCall
input:
set val(name), file(bam), file(bai), file(fasta), file(fai) from input_structural_variantcaller
output:
file("*") into output_structural_variantcaller
when: !params.skip_structural_variants
script:
// TODO: --filter_short_contigs (include when using real data) --svviz_only_validated_candidates (both filterings to reduce computations)
"""
nf_work_dir=\$(pwd)
cp ${fasta} ref.fa
cp ${fai} ref.fa.fai
cp ${bam} input.bam
cp ${bai} input.bai
gzip ref.fa
mv * /home/dnanexus/in
cd /home/dnanexus
parliament2.py \
--bam input.bam \
--bai input.bai \
--fai ref.fa.fai \
--ref_genome ref.fa.gz \
--prefix ${name} \
--delly_deletion \
--delly_insertion \
--delly_inversion \
--delly_duplication \
--breakseq \
--breakdancer \
--manta \
--lumpy \
--cnvnator \
--genotype \
--svviz
mv /home/dnanexus/out/* \$nf_work_dir
"""
}
process bcftools{
tag "$vcf"
container 'lifebitai/bcftools:latest'
input:
set val(name), file(vcf), file(index) from vcf_bcftools
output:
file("*") into bcftools_multiqc
when: !params.skip_multiqc
script:
"""
bcftools stats $vcf > bcfstats.txt
"""
}
variant_eval_ref = fasta_variant_eval.merge(fai_variant_eval, dict_variant_eval)
variant_eval = vcf_variant_eval.combine(variant_eval_ref)
process VariantEval {
tag "$vcf"
container 'broadinstitute/gatk:latest'
input:
set val(name), file(vcf), file(index), file(fasta), file(fai), file(dict) from variant_eval
output:
file("${name}.eval.grp") into variantEvalReport
when: !params.skip_multiqc
script:
// TODO: add dbsnp & gold standard
"""
touch ${name}.eval.grp
gatk VariantEval \
-R ${fasta} \
--eval:${name} $vcf \
-O ${name}.eval.grp
"""
}
if (!params.skip_fastqc && !params.skip_multiqc) {
if (!params.bam) {
fastqc_multiqc = fastqc_results.collect().ifEmpty([])
multiqc_data = markdup_multiqc.merge(fastqc_multiqc, baseRecalibratorReport, variantEvalReport, bamQCmappedReport, bamQCrecalibratedReport)
multiqc = bcftools_multiqc.combine(multiqc_data)
} else {
multiqc = bcftools_multiqc.combine(variantEvalReport.merge(bamQCrecalibratedReport))
}
process multiqc {
tag "multiqc_report.html"
publishDir "${params.outdir}/MultiQC", mode: 'copy'
container 'ewels/multiqc:v1.7'
input:
file multiqc from multiqc
output:
file("*") into viz
when: !params.skip_multiqc
script:
"""
multiqc . -m fastqc -m qualimap -m picard -m gatk -m bcftools
"""
}
}