-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgermlineVC.nf
657 lines (547 loc) · 23.1 KB
/
germlineVC.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
#!/usr/bin/env nextflow
/*
kate: syntax groovy; space-indent on; indent-width 2;
================================================================================
= S A R E K =
================================================================================
New Germline (+ Somatic) Analysis Workflow. Started March 2016.
--------------------------------------------------------------------------------
@Authors
Sebastian DiLorenzo <[email protected]> [@Sebastian-D]
Jesper Eisfeldt <[email protected]> [@J35P312]
Phil Ewels <[email protected]> [@ewels]
Maxime Garcia <[email protected]> [@MaxUlysse]
Szilveszter Juhos <[email protected]> [@szilvajuhos]
Max Käller <[email protected]> [@gulfshores]
Malin Larsson <[email protected]> [@malinlarsson]
Marcel Martin <[email protected]> [@marcelm]
Björn Nystedt <[email protected]> [@bjornnystedt]
Pall Olason <[email protected]> [@pallolason]
--------------------------------------------------------------------------------
@Homepage
http://opensource.scilifelab.se/projects/sarek/
--------------------------------------------------------------------------------
@Documentation
https://github.com/SciLifeLab/Sarek/README.md
--------------------------------------------------------------------------------
Processes overview
- CreateIntervalBeds - Create and sort intervals into bed files
- RunHaplotypecaller - Run HaplotypeCaller for Germline Variant Calling (Parallelized processes)
- RunGenotypeGVCFs - Run HaplotypeCaller for Germline Variant Calling (Parallelized processes)
- ConcatVCF - Merge results from paralellized callers
- RunSingleStrelka - Run Strelka for Germline Variant Calling
- RunSingleManta - Run Manta for Single Structural Variant Calling
- RunBcftoolsStats - Run BCFTools stats on vcf files
- RunVcftools - Run VCFTools on vcf files
================================================================================
= C O N F I G U R A T I O N =
================================================================================
*/
if (params.help) exit 0, helpMessage()
if (!SarekUtils.isAllowedParams(params)) exit 1, "params unknown, see --help for more information"
if (!checkUppmaxProject()) exit 1, "No UPPMAX project ID found! Use --project <UPPMAX Project ID>"
// Check for awsbatch profile configuration
// make sure queue is defined
if (workflow.profile == 'awsbatch') {
if (!params.awsqueue) exit 1, "Provide the job queue for aws batch!"
}
tools = params.tools ? params.tools.split(',').collect{it.trim().toLowerCase()} : []
referenceMap = defineReferenceMap()
toolList = defineToolList()
if (!SarekUtils.checkReferenceMap(referenceMap)) exit 1, 'Missing Reference file(s), see --help for more information'
if (!SarekUtils.checkParameterList(tools,toolList)) exit 1, 'Unknown tool(s), see --help for more information'
if (params.test && params.genome in ['GRCh37', 'GRCh38']) {
referenceMap.intervals = file("$workflow.projectDir/repeats/tiny_${params.genome}.list")
}
// TODO
// FreeBayes does not need recalibrated BAMs, but we need to test whether
// the channels are set up correctly when we disable it
tsvPath = ''
if (params.sample) tsvPath = params.sample
else tsvPath = "${params.outDir}/Preprocessing/Recalibrated/recalibrated.tsv"
// Set up the bamFiles channel
bamFiles = Channel.empty()
if (tsvPath) {
tsvFile = file(tsvPath)
bamFiles = SarekUtils.extractBams(tsvFile, "germline")
} else exit 1, 'No sample were defined, see --help'
/*
================================================================================
= P R O C E S S E S =
================================================================================
*/
startMessage()
if (params.verbose) bamFiles = bamFiles.view {
"BAMs to process:\n\
ID : ${it[0]}\tStatus: ${it[1]}\tSample: ${it[2]}\n\
Files : [${it[3].fileName}, ${it[4].fileName}]"
}
// assume input is recalibrated, ignore explicitBqsrNeeded
(recalibratedBam, recalTables) = bamFiles.into(2)
recalTables = recalTables.map{ it + [null] } // null recalibration table means: do not use --BQSR
recalTables = recalTables.map { [it[0]] + it[2..-1] } // remove status
if (params.verbose) recalibratedBam = recalibratedBam.view {
"Recalibrated BAM for variant Calling:\n\
ID : ${it[0]}\tStatus: ${it[1]}\tSample: ${it[2]}\n\
Files : [${it[3].fileName}, ${it[4].fileName}]"
}
// Here we have a recalibrated bam set, but we need to separate the bam files based on patient status.
// The sample tsv config file which is formatted like: "subject status sample lane fastq1 fastq2"
// cf fastqFiles channel, I decided just to add _status to the sample name to have less changes to do.
// And so I'm sorting the channel if the sample match _0, then it's a normal sample, otherwise tumor.
// Then combine normal and tumor to get each possibilities
// ie. normal vs tumor1, normal vs tumor2, normal vs tumor3
// then copy this channel into channels for each variant calling
// I guess it will still work even if we have multiple normal samples
// separate recalibrateBams by status
bamsNormal = Channel.create()
bamsTumor = Channel.create()
recalibratedBam
.choice(bamsTumor, bamsNormal) {it[1] == 0 ? 1 : 0}
// Ascat, Strelka Germline & Manta Germline SV
bamsForAscat = Channel.create()
bamsForSingleManta = Channel.create()
bamsForSingleStrelka = Channel.create()
(bamsTumorTemp, bamsTumor) = bamsTumor.into(2)
(bamsNormalTemp, bamsNormal) = bamsNormal.into(2)
(bamsForAscat, bamsForSingleManta, bamsForSingleStrelka) = bamsNormalTemp.mix(bamsTumorTemp).into(3)
// Removing status because not relevant anymore
bamsNormal = bamsNormal.map { idPatient, status, idSample, bam, bai -> [idPatient, idSample, bam, bai] }
bamsTumor = bamsTumor.map { idPatient, status, idSample, bam, bai -> [idPatient, idSample, bam, bai] }
// We know that MuTect2 (and other somatic callers) are notoriously slow.
// To speed them up we are chopping the reference into smaller pieces.
// (see repeats/centromeres.list).
// Do variant calling by this intervals, and re-merge the VCFs.
// Since we are on a cluster, this can parallelize the variant call processes.
// And push down the variant call wall clock time significanlty.
process CreateIntervalBeds {
tag {intervals.fileName}
input:
file(intervals) from Channel.value(referenceMap.intervals)
output:
file '*.bed' into bedIntervals mode flatten
script:
// If the interval file is BED format, the fifth column is interpreted to
// contain runtime estimates, which is then used to combine short-running jobs
if (intervals.getName().endsWith('.bed'))
"""
awk -vFS="\t" '{
t = \$5 # runtime estimate
if (t == "") {
# no runtime estimate in this row, assume default value
t = (\$3 - \$2) / ${params.nucleotidesPerSecond}
}
if (name == "" || (chunk > 600 && (chunk + t) > longest * 1.05)) {
# start a new chunk
name = sprintf("%s_%d-%d.bed", \$1, \$2+1, \$3)
chunk = 0
longest = 0
}
if (t > longest)
longest = t
chunk += t
print \$0 > name
}' ${intervals}
"""
else
"""
awk -vFS="[:-]" '{
name = sprintf("%s_%d-%d", \$1, \$2, \$3);
printf("%s\\t%d\\t%d\\n", \$1, \$2-1, \$3) > name ".bed"
}' ${intervals}
"""
}
bedIntervals = bedIntervals
.map { intervalFile ->
def duration = 0.0
for (line in intervalFile.readLines()) {
final fields = line.split('\t')
if (fields.size() >= 5) duration += fields[4].toFloat()
else {
start = fields[1].toInteger()
end = fields[2].toInteger()
duration += (end - start) / params.nucleotidesPerSecond
}
}
[duration, intervalFile]
}.toSortedList({ a, b -> b[0] <=> a[0] })
.flatten().collate(2)
.map{duration, intervalFile -> intervalFile}
if (params.verbose) bedIntervals = bedIntervals.view {
" Interv: ${it.baseName}"
}
(bamsNormalTemp, bamsNormal, bedIntervals) = generateIntervalsForVC(bamsNormal, bedIntervals)
(bamsTumorTemp, bamsTumor, bedIntervals) = generateIntervalsForVC(bamsTumor, bedIntervals)
// HaplotypeCaller
bamsForHC = bamsNormalTemp.mix(bamsTumorTemp)
bedIntervals = bedIntervals.tap { intervalsTemp }
recalTables = recalTables
.spread(intervalsTemp)
.map { patient, sample, bam, bai, recalTable, intervalBed ->
[patient, sample, bam, bai, intervalBed, recalTable] }
// re-associate the BAMs and samples with the recalibration table
bamsForHC = bamsForHC.join(recalTables, by:[0,1,2,3,4])
bamsAll = bamsNormal.combine(bamsTumor)
// Since idPatientNormal and idPatientTumor are the same
// It's removed from bamsAll Channel (same for genderNormal)
// /!\ It is assumed that every sample are from the same patient
bamsAll = bamsAll.map {
idPatientNormal, idSampleNormal, bamNormal, baiNormal, idPatientTumor, idSampleTumor, bamTumor, baiTumor ->
[idPatientNormal, idSampleNormal, bamNormal, baiNormal, idSampleTumor, bamTumor, baiTumor]
}
// Manta and Strelka
(bamsForManta, bamsForStrelka, bamsAll) = bamsAll.into(3)
bamsTumorNormalIntervals = bamsAll.spread(bedIntervals)
// MuTect2, FreeBayes
(bamsFMT2, bamsFFB) = bamsTumorNormalIntervals.into(2)
process RunHaplotypecaller {
tag {idSample + "-" + intervalBed.baseName}
input:
set idPatient, idSample, file(bam), file(bai), file(intervalBed), recalTable from bamsForHC //Are these values `ped to bamNormal already?
set file(genomeFile), file(genomeIndex), file(genomeDict), file(dbsnp), file(dbsnpIndex) from Channel.value([
referenceMap.genomeFile,
referenceMap.genomeIndex,
referenceMap.genomeDict,
referenceMap.dbsnp,
referenceMap.dbsnpIndex
])
output:
set val("HaplotypeCallerGVCF"), idPatient, idSample, idSample, file("${intervalBed.baseName}_${idSample}.g.vcf") into hcGenomicVCF
set idPatient, idSample, file(intervalBed), file("${intervalBed.baseName}_${idSample}.g.vcf") into vcfsToGenotype
when: 'haplotypecaller' in tools && !params.onlyQC
script:
"""
gatk --java-options "-Xmx${task.memory.toGiga()}g -Xms6000m -XX:GCTimeLimit=50 -XX:GCHeapFreeLimit=10" \
HaplotypeCaller \
-R ${genomeFile} \
-I ${bam} \
-L ${intervalBed} \
-D ${dbsnp} \
-O ${intervalBed.baseName}_${idSample}.g.vcf \
-ERC GVCF
"""
}
hcGenomicVCF = hcGenomicVCF.groupTuple(by:[0,1,2,3])
if (params.noGVCF) hcGenomicVCF.close()
process RunGenotypeGVCFs {
tag {idSample + "-" + intervalBed.baseName}
input:
set idPatient, idSample, file(intervalBed), file(gvcf) from vcfsToGenotype
set file(genomeFile), file(genomeIndex), file(genomeDict), file(dbsnp), file(dbsnpIndex) from Channel.value([
referenceMap.genomeFile,
referenceMap.genomeIndex,
referenceMap.genomeDict,
referenceMap.dbsnp,
referenceMap.dbsnpIndex
])
output:
set val("HaplotypeCaller"), idPatient, idSample, idSample, file("${intervalBed.baseName}_${idSample}.vcf") into hcGenotypedVCF
when: 'haplotypecaller' in tools && !params.onlyQC
script:
// Using -L is important for speed and we have to index the interval files also
"""
gatk --java-options -Xmx${task.memory.toGiga()}g \
IndexFeatureFile -F ${gvcf}
gatk --java-options -Xmx${task.memory.toGiga()}g \
GenotypeGVCFs \
-R ${genomeFile} \
-L ${intervalBed} \
-D ${dbsnp} \
-V ${gvcf} \
-O ${intervalBed.baseName}_${idSample}.vcf
"""
}
hcGenotypedVCF = hcGenotypedVCF.groupTuple(by:[0,1,2,3])
// we are merging the VCFs that are called separatelly for different intervals
// so we can have a single sorted VCF containing all the calls for a given caller
vcfsToMerge = hcGenomicVCF.mix(hcGenotypedVCF)
if (params.verbose) vcfsToMerge = vcfsToMerge.view {
"VCFs To be merged:\n\
Tool : ${it[0]}\tID : ${it[1]}\tSample: [${it[3]}, ${it[2]}]\n\
Files : ${it[4].fileName}"
}
process ConcatVCF {
tag {variantCaller + "-" + idSampleNormal}
publishDir "${params.outDir}/VariantCalling/${idPatient}/${"$variantCaller"}", mode: params.publishDirMode
input:
set variantCaller, idPatient, idSampleNormal, idSampleTumor, file(vcFiles) from vcfsToMerge
file(genomeIndex) from Channel.value(referenceMap.genomeIndex)
file(targetBED) from Channel.value(params.targetBED ? file(params.targetBED) : "null")
output:
// we have this funny *_* pattern to avoid copying the raw calls to publishdir
set variantCaller, idPatient, idSampleNormal, idSampleTumor, file("*_*.vcf.gz"), file("*_*.vcf.gz.tbi") into vcfConcatenated
when: ( 'haplotypecaller' in tools || 'mutect2' in tools || 'freebayes' in tools ) && !params.onlyQC
script:
if (variantCaller == 'HaplotypeCaller') outputFile = "${variantCaller}_${idSampleNormal}.vcf"
else if (variantCaller == 'HaplotypeCallerGVCF') outputFile = "haplotypecaller_${idSampleNormal}.g.vcf"
else outputFile = "${variantCaller}_${idSampleTumor}_vs_${idSampleNormal}.vcf"
options = params.targetBED ? "-t ${targetBED}" : ""
"""
concatenateVCFs.sh -i ${genomeIndex} -c ${task.cpus} -o ${outputFile} ${options}
"""
}
if (params.verbose) vcfConcatenated = vcfConcatenated.view {
"Variant Calling output:\n\
Tool : ${it[0]}\tID : ${it[1]}\tSample: ${it[2]}\n\
Files : ${it[4].fileName}\n\
Index : ${it[5].fileName}"
}
process RunSingleStrelka {
tag {idSample}
publishDir "${params.outDir}/VariantCalling/${idPatient}/Strelka", mode: params.publishDirMode
input:
set idPatient, status, idSample, file(bam), file(bai) from bamsForSingleStrelka
file(targetBED) from Channel.value(params.targetBED ? file(params.targetBED) : "null")
set file(genomeFile), file(genomeIndex) from Channel.value([
referenceMap.genomeFile,
referenceMap.genomeIndex
])
output:
set val("Strelka"), idPatient, idSample, file("*.vcf.gz"), file("*.vcf.gz.tbi") into singleStrelkaOutput
when: 'strelka' in tools && !params.onlyQC
script:
beforeScript = params.targetBED ? "bgzip --threads ${task.cpus} -c ${targetBED} > call_targets.bed.gz ; tabix call_targets.bed.gz" : ""
options = params.targetBED ? "--exome --callRegions call_targets.bed.gz" : ""
"""
${beforeScript}
configureStrelkaGermlineWorkflow.py \
--bam ${bam} \
--referenceFasta ${genomeFile} \
${options} \
--runDir Strelka
python Strelka/runWorkflow.py -m local -j ${task.cpus}
mv Strelka/results/variants/genome.*.vcf.gz Strelka_${idSample}_genome.vcf.gz
mv Strelka/results/variants/genome.*.vcf.gz.tbi Strelka_${idSample}_genome.vcf.gz.tbi
mv Strelka/results/variants/variants.vcf.gz Strelka_${idSample}_variants.vcf.gz
mv Strelka/results/variants/variants.vcf.gz.tbi Strelka_${idSample}_variants.vcf.gz.tbi
"""
}
if (params.verbose) singleStrelkaOutput = singleStrelkaOutput.view {
"Variant Calling output:\n\
Tool : ${it[0]}\tID : ${it[1]}\tSample: ${it[2]}\n\
Files : ${it[3].fileName}\n\
Index : ${it[4].fileName}"
}
process RunSingleManta {
tag {idSample + " - Single Diploid"}
publishDir "${params.outDir}/VariantCalling/${idPatient}/Manta", mode: params.publishDirMode
input:
set idPatient, status, idSample, file(bam), file(bai) from bamsForSingleManta
file(targetBED) from Channel.value(params.targetBED ? file(params.targetBED) : "null")
set file(genomeFile), file(genomeIndex) from Channel.value([
referenceMap.genomeFile,
referenceMap.genomeIndex
])
output:
set val("Manta"), idPatient, idSample, file("*.vcf.gz"), file("*.vcf.gz.tbi") into singleMantaOutput
when: 'manta' in tools && status == 0 && !params.onlyQC
script:
beforeScript = params.targetBED ? "bgzip --threads ${task.cpus} -c ${targetBED} > call_targets.bed.gz ; tabix call_targets.bed.gz" : ""
options = params.targetBED ? "--exome --callRegions call_targets.bed.gz" : ""
"""
${beforeScript}
configManta.py \
--bam ${bam} \
--reference ${genomeFile} \
${options} \
--runDir Manta
python Manta/runWorkflow.py -m local -j ${task.cpus}
mv Manta/results/variants/candidateSmallIndels.vcf.gz \
Manta_${idSample}.candidateSmallIndels.vcf.gz
mv Manta/results/variants/candidateSmallIndels.vcf.gz.tbi \
Manta_${idSample}.candidateSmallIndels.vcf.gz.tbi
mv Manta/results/variants/candidateSV.vcf.gz \
Manta_${idSample}.candidateSV.vcf.gz
mv Manta/results/variants/candidateSV.vcf.gz.tbi \
Manta_${idSample}.candidateSV.vcf.gz.tbi
mv Manta/results/variants/diploidSV.vcf.gz \
Manta_${idSample}.diploidSV.vcf.gz
mv Manta/results/variants/diploidSV.vcf.gz.tbi \
Manta_${idSample}.diploidSV.vcf.gz.tbi
"""
}
if (params.verbose) singleMantaOutput = singleMantaOutput.view {
"Variant Calling output:\n\
Tool : ${it[0]}\tID : ${it[1]}\tSample: ${it[2]}\n\
Files : ${it[3].fileName}\n\
Index : ${it[4].fileName}"
}
vcfForQC = Channel.empty().mix(
vcfConcatenated.map {
variantcaller, idPatient, idSampleNormal, idSampleTumor, vcf, tbi ->
[variantcaller, vcf]
},
singleStrelkaOutput.map {
variantcaller, idPatient, idSample, vcf, tbi ->
[variantcaller, vcf[1]]
},
singleMantaOutput.map {
variantcaller, idPatient, idSample, vcf, tbi ->
[variantcaller, vcf[2]]
})
(vcfForBCFtools, vcfForVCFtools) = vcfForQC.into(2)
process RunBcftoolsStats {
tag {vcf}
publishDir "${params.outDir}/Reports/BCFToolsStats", mode: params.publishDirMode
input:
set variantCaller, file(vcf) from vcfForBCFtools
output:
file ("${vcf.simpleName}.bcf.tools.stats.out") into bcfReport
when: !params.noReports
script: QC.bcftools(vcf)
}
if (params.verbose) bcfReport = bcfReport.view {
"BCFTools stats report:\n\
File : [${it.fileName}]"
}
bcfReport.close()
process RunVcftools {
tag {vcf}
publishDir "${params.outDir}/Reports/VCFTools", mode: params.publishDirMode
input:
set variantCaller, file(vcf) from vcfForVCFtools
output:
file ("${vcf.simpleName}.*") into vcfReport
when: !params.noReports
script: QC.vcftools(vcf)
}
if (params.verbose) vcfReport = vcfReport.view {
"VCFTools stats report:\n\
File : [${it.fileName}]"
}
vcfReport.close()
/*
================================================================================
= F U N C T I O N S =
================================================================================
*/
def checkParamReturnFile(item) {
params."${item}" = params.genomes[params.genome]."${item}"
return file(params."${item}")
}
def checkUppmaxProject() {
// check if UPPMAX project number is specified
return !(workflow.profile == 'slurm' && !params.project)
}
def defineReferenceMap() {
if (!(params.genome in params.genomes)) exit 1, "Genome ${params.genome} not found in configuration"
return [
'dbsnp' : checkParamReturnFile("dbsnp"),
'dbsnpIndex' : checkParamReturnFile("dbsnpIndex"),
// genome reference dictionary
'genomeDict' : checkParamReturnFile("genomeDict"),
// FASTA genome reference
'genomeFile' : checkParamReturnFile("genomeFile"),
// genome .fai file
'genomeIndex' : checkParamReturnFile("genomeIndex"),
// intervals file for spread-and-gather processes
'intervals' : checkParamReturnFile("intervals")
]
}
def defineToolList() {
return [
'ascat',
'freebayes',
'haplotypecaller',
'manta',
'mutect2',
'strelka'
]
}
def generateIntervalsForVC(bams, intervals) {
def (bamsNew, bamsForVC) = bams.into(2)
def (intervalsNew, vcIntervals) = intervals.into(2)
def bamsForVCNew = bamsForVC.combine(vcIntervals)
return [bamsForVCNew, bamsNew, intervalsNew]
}
def grabRevision() {
// Return the same string executed from github or not
return workflow.revision ?: workflow.commitId ?: workflow.scriptId.substring(0,10)
}
def helpMessage() {
// Display help message
this.sarekMessage()
log.info " Usage:"
log.info " nextflow run germlineVC.nf --sample <file.tsv> [--tools TOOL[,TOOL]] --genome <Genome>"
log.info " --sample <file.tsv>"
log.info " Specify a TSV file containing paths to sample files."
log.info " --test"
log.info " Use a test sample."
log.info " --noReports"
log.info " Disable QC tools and MultiQC to generate a HTML report"
log.info " --tools"
log.info " Option to configure which tools to use in the workflow."
log.info " Different tools to be separated by commas."
log.info " Possible values are:"
log.info " strelka (use Strelka for VC)"
log.info " haplotypecaller (use HaplotypeCaller for normal bams VC)"
log.info " manta (use Manta for SV)"
log.info " --genome <Genome>"
log.info " Use a specific genome version."
log.info " Possible values are:"
log.info " GRCh37"
log.info " GRCh38 (Default)"
log.info " smallGRCh37 (Use a small reference (Tests only))"
log.info " --onlyQC"
log.info " Run only QC tools and gather reports"
log.info " --help"
log.info " you're reading it"
log.info " --verbose"
log.info " Adds more verbosity to workflow"
}
def minimalInformationMessage() {
// Minimal information message
log.info "Command Line: " + workflow.commandLine
log.info "Profile : " + workflow.profile
log.info "Project Dir : " + workflow.projectDir
log.info "Launch Dir : " + workflow.launchDir
log.info "Work Dir : " + workflow.workDir
log.info "Out Dir : " + params.outDir
log.info "TSV file : " + tsvFile
log.info "Genome : " + params.genome
log.info "Genome_base : " + params.genome_base
log.info "Target BED : " + params.targetBED
log.info "Tools : " + tools.join(', ')
log.info "Containers"
if (params.repository != "") log.info " Repository : " + params.repository
if (params.containerPath != "") log.info " ContainerPath: " + params.containerPath
log.info "Reference files used:"
log.info " dbsnp :\n\t" + referenceMap.dbsnp
log.info "\t" + referenceMap.dbsnpIndex
log.info " genome :\n\t" + referenceMap.genomeFile
log.info "\t" + referenceMap.genomeDict
log.info "\t" + referenceMap.genomeIndex
log.info " intervals :\n\t" + referenceMap.intervals
}
def nextflowMessage() {
// Nextflow message (version + build)
log.info "N E X T F L O W ~ version ${workflow.nextflow.version} ${workflow.nextflow.build}"
}
def sarekMessage() {
// Display Sarek message
log.info "Sarek - Workflow For Somatic And Germline Variations ~ ${workflow.manifest.version} - " + this.grabRevision() + (workflow.commitId ? " [${workflow.commitId}]" : "")
}
def startMessage() {
// Display start message
SarekUtils.sarek_ascii()
this.sarekMessage()
this.minimalInformationMessage()
}
workflow.onComplete {
// Display complete message
this.nextflowMessage()
this.sarekMessage()
this.minimalInformationMessage()
log.info "Completed at: " + workflow.complete
log.info "Duration : " + workflow.duration
log.info "Success : " + workflow.success
log.info "Exit status : " + workflow.exitStatus
log.info "Error report: " + (workflow.errorReport ?: '-')
}
workflow.onError {
// Display error message
this.nextflowMessage()
this.sarekMessage()
log.info "Workflow execution stopped with the following message:"
log.info " " + workflow.errorMessage
}