-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun_QC_checks.wdl
659 lines (574 loc) · 24 KB
/
run_QC_checks.wdl
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
## Author: Anne Trinh
## Last Modified: 18/11/2022
## This pipeline is a modification of the QC metrics in Getz somatic variant pipeline modified for hg38
## Legacy features have been retained in this pipeline and can be turned off using Boolean input
##
## main mod:
## - override cross check lane for hg19 only
## - one boolean for running picard for normal and tumour
##
## COMPONENTS:
## 1. Copy Number QC: Quick QC based on CN to ensure normal and tumour are not mixed up
## 2. ContEst: Estimate the estimated amount of normal
## 3. CrossCheckFingerprint: check that all read groups within the set of BAM files appear to come from the same individual
## 4. Picard Metrics
##
############################################
## DEFAULT OPTIONS (In the listed .json file)
#############################################
## refGenome = "hg38" (also works with "hg19")
## runMode = "Paired" (can also be "TumOnly")
## run_CNQC = false. Run copy number QC in QC step?
## run_Picard_tumor = true
## run_Picard_normal = false
## run_CrossCheck = false. Run Cross Check Fingerprints?
version 1.0
workflow QCChecks {
input {
File tumorBam
# sample normal BAM file (see https://samtools.github.io/hts-specs/SAMv1.pdf)
File? normalBam
# sample normal BAI file (BAM indexed) (see samtools index command http://www.htslib.org/doc/samtools.html)
File tumorBamIdx
# sample normal BAI file (BAM indexed) (see samtools index command http://www.htslib.org/doc/samtools.html)
File? normalBamIdx
# a string for the name of the pair under analysis used for naming output files
String pairName
# a string for the name of the tumor sample under analysis used for naming output files
String caseName
# a string for the name of the normal sample under analysis used for naming output files
String? ctrlName
# list of read groups to exclude from the analysis in MuTect1 and MuTect_FC tasks
File refFasta
File refFastaIdx
File refFastaDict
File targetIntervals
File baitIntervals
File DB_SNP_VCF
File DB_SNP_VCF_IDX
String gatk_docker
File gnomad
File gnomad_idx
# For CNQC
File? captureNormalsDBRCLZip
File? regionFile
File? readGroupBlackList
## Option: refGenome "hg19" or "hg18"
String refGenome
# ContEst
# CrossCheckLane
File HaplotypeDBForCrossCheck
Float? fracContam
# Does the sample already have picard metrics computed
Boolean run_Picard_tumor = false
Boolean run_Picard_normal = false
# Forceto compute picard metrics anyway, even if they exist
Boolean run_CNQC = false
Boolean run_CrossCheck = true
# Is the run WGS (false) or a targeted hybrid capture panel (true)
Boolean targetedRun
}
Int tumorBam_size = ceil(size(tumorBam, "G") + size(tumorBamIdx, "G"))
Int normalBam_size = if defined(normalBam) then ceil(size(normalBam, "G") + size(normalBamIdx, "G")) else 0
Int db_snp_vcf_size = ceil(size(DB_SNP_VCF, "G") + size(DB_SNP_VCF_IDX, "G"))
Int refFasta_size = ceil(size(refFasta, "G") + size(refFastaDict, "G") + size(refFastaIdx, "G"))
File capNorm=select_first([captureNormalsDBRCLZip, "null"])
File regF=select_first([regionFile, "null"])
File readGrpBL=select_first([readGroupBlackList, "null"])
Boolean override_CNQC = if defined (normalBam) then run_CNQC else false
Boolean runContEst = if defined(fracContam) || !defined(normalBam) then false else true
if (override_CNQC){
call CopyNumberReportQC_Task {
input:
tumorBam=tumorBam,
tumorBamIdx=tumorBamIdx,
normalBam=normalBam,
normalBamIdx=normalBamIdx,
readGroupBlackList=readGrpBL,
tumorBam_size=tumorBam_size,
normalBam_size=normalBam_size,
captureNormalsDBRCLZip=capNorm,
regionFile=regF
}
}
if (runContEst){
call ContEST_Task {
input:
tumorBam=tumorBam,
tumorBamIdx=tumorBamIdx,
normalBam=normalBam,
normalBamIdx=normalBamIdx,
pairName=pairName,
targetIntervals=targetIntervals,
tumorBam_size=tumorBam_size,
normalBam_size=normalBam_size,
gnomad=gnomad,
gnomad_idx=gnomad_idx,
gatk_docker=gatk_docker
}
}
# Program to check that all read groups within the set of BAM files appear to come from the same individual.
if (run_CrossCheck){
call CrossCheckLaneFingerprints_Task {
input:
tumorBam=tumorBam,
normalBam=normalBam,
tumorBamIdx=tumorBamIdx,
normalBamIdx=normalBamIdx,
pairName=pairName,
tumorBam_size=tumorBam_size,
normalBam_size=normalBam_size,
HaplotypeDBForCrossCheck=HaplotypeDBForCrossCheck,
gatk_docker=gatk_docker
}
}
#Picard tasks (tumor and normal)
###################################
# The task runs 3 tools:
# ValidateSamFile, CollectMultipleMetrics and CollectHSMetrics
# ValidateSamFile makes sure the the given file is constructed correctly.
# CollectMultipleMetrics collects multiple classes of metrics. This 'meta-metrics' tool runs one or more of the metrics collection modules at the same time
# to cut down on the time spent reading in data from input files.
# Available modules include CollectAlignmentSummaryMetrics, CollectInsertSizeMetrics, QualityScoreDistribution, MeanQualityByCycle,
# CollectBaseDistributionByCycle, CollectGcBiasMetrics, RnaSeqMetrics, CollectSequencingArtifactMetrics, and CollectQualityYieldMetrics.
# CollectHSMetrics adds coverage statistics for WES files, on top of CollectMultipleMetrics.
# tumor
if (run_Picard_tumor) {
call PicardMultipleMetrics_Task as tumorMM_Task {
input:
bam=tumorBam,
bamIndex=tumorBamIdx,
sampleName=caseName,
refFasta=refFasta,
DB_SNP_VCF=DB_SNP_VCF,
DB_SNP_VCF_IDX=DB_SNP_VCF_IDX,
targetIntervals=targetIntervals,
baitIntervals=baitIntervals,
gatk_docker=gatk_docker,
refFasta_size=refFasta_size,
db_snp_vcf_size=db_snp_vcf_size,
bam_size=tumorBam_size,
targetedRun=targetedRun
}
}
#normal
if (run_Picard_normal && defined(normalBam)) {
call PicardMultipleMetrics_Task as normalMM_Task {
input:
bam=normalBam,
bamIndex=normalBamIdx,
sampleName=ctrlName,
refFasta=refFasta,
DB_SNP_VCF=DB_SNP_VCF,
DB_SNP_VCF_IDX=DB_SNP_VCF_IDX,
targetIntervals=targetIntervals,
baitIntervals=baitIntervals,
gatk_docker=gatk_docker,
refFasta_size=refFasta_size,
db_snp_vcf_size=db_snp_vcf_size,
bam_size=normalBam_size,
targetedRun=targetedRun
}
}
output {
####### QC Tasks Outputs #######
# Copy Number QC Report files
File? tumor_bam_lane_list=CopyNumberReportQC_Task.tumorBamLaneList
File? normal_bam_lane_list=CopyNumberReportQC_Task.normalBamLaneList
File? tumor_bam_read_coverage_lane=CopyNumberReportQC_Task.tumorRCL
File? normal_bam_read_coverage_lane=CopyNumberReportQC_Task.normalRCL
File? copy_number_qc_report=CopyNumberReportQC_Task.CopyNumQCReport
File? copy_number_qc_report_png=CopyNumberReportQC_Task.CopyNumQCReportPNG
Int? copy_number_qc_mix_ups=CopyNumberReportQC_Task.CopyNumQCMixUps
# Picard Multiple Metrics Task - NORMAL BAM
File? normal_bam_picard=normalMM_Task.picard_files
File? tumor_bam_picard=tumorMM_Task.picard_files
File? normal_bam_hsmetrics=normalMM_Task.hsMetrics
File? tumor_bam_hsmetrics=tumorMM_Task.hsMetrics
File? tumor_cleaned_unmapped_bam=tumorMM_Task.bam_unmapped_cleaned
File? normal_cleaned_unmapped_bam=normalMM_Task.bam_unmapped_cleaned
# Cross-Sample Contamination Task
File contamination_table=select_first([ContEST_Task.contamTable, "null"])
File normalTable=select_first([ContEST_Task.normTable, "null"])
File tumorTable=select_first([ContEST_Task.tumTable, "null"])
Float fracContam=select_first([ContEST_Task.fracContam, "0"])
# Cross Check Lane Fingerprints Task
File? cross_check_fingprt_metrics=CrossCheckLaneFingerprints_Task.crossCheckMetrics
}
}
task CopyNumberReportQC_Task {
input{
# TASK INPUT PARAMS
File tumorBam
File tumorBamIdx
File? normalBam
File? normalBamIdx
File regionFile
File readGroupBlackList
File captureNormalsDBRCLZip
# FILE SIZE
Int tumorBam_size
Int normalBam_size
# RUNTIME INPUT PARAMS
String preemptible = "1"
String diskGB_boot = "15"
String diskGB_buffer = "20"
String memoryGB = "7"
String cpu = "1"
}
# COMPUTE MEMORY SIZE
Int command_memoryGB = floor(memoryGB) - 1
# COMPUTE DISK SIZE
Int diskGB = ceil(2.5*ceil(tumorBam_size + normalBam_size + size(regionFile, 'G') + size(readGroupBlackList, 'G')
+ size(captureNormalsDBRCLZip, 'G') + diskGB_buffer))
parameter_meta {
tumorBam : "sample tumor BAM file"
tumorBamIdx : "sample tumor BAI file (BAM indexed)"
regionFile : ""
readGroupBlackList : ""
captureNormalsDBRCLZip : ""
}
command {
# e - exit when a command fails
# u - exit when script tries to use undeclared variables
# x - trace what gets executed
# o - exit status of the last command that threw a non-zero exit code is returned
set -eux pipefail
# Copy Number QC for Capture
# Make lane lists for tumor and normal
# MakeLaneList_12
java "-Xmx${command_memoryGB}g" -jar /usr/local/bin/MakeLaneList.jar ${tumorBam} case.lanelist.txt ;
java "-Xmx${command_memoryGB}g" -jar /usr/local/bin/MakeLaneList.jar ${normalBam} control.lanelist.txt ;
# make region coverages per lane for tumor
# RegionCovPerLane_18
for CHROM in `seq 1 24` ; do
echo "Working on $CHROM for ${tumorBam}"
SCATTER_DIR="scatter.$CHROM" ;
mkdir -v $SCATTER_DIR
OUTPATH=`echo -ne "$SCATTER_DIR/chr$CHROM.case.rcl"` ;
echo "OUTPATH is $OUTPATH"
echo "chrom is $CHROM"
java -jar /usr/local/bin/RegionCovPerLane.jar ${tumorBam} ${regionFile} $OUTPATH $CHROM
done ;
wait ;
/usr/local/bin/rcl.gather.sh case.rcl ;
rm -rf scatter.* ;
# make region coverages per lane for control
# RegionCovPerLane_18
for CHROM in `seq 1 24` ; do
echo "Working on $CHROM for ${normalBam}"
SCATTER_DIR="scatter.$CHROM" ;
mkdir -v $SCATTER_DIR
OUTPATH=`echo -ne "$SCATTER_DIR/chr$CHROM.control.rcl"` ;
echo "OUTPATH is $OUTPATH"
echo "chrom is $CHROM"
java -jar /usr/local/bin/RegionCovPerLane.jar ${normalBam} ${regionFile} $OUTPATH $CHROM
done ;
wait ;
/usr/local/bin/rcl.gather.sh control.rcl ;
rm -rf scatter.* ;
# run the Matlab based report
# CopyNumberQCReport_27
cp -vfr /CopyNumberQCReport_27/unzip/* .
# Make a file of files paths
# This command aims to list the zip files contents, filtering out all but the file paths and then write the paths to a file
python <<CODE
from zipfile import ZipFile
with open('capture_normals_db_wdl', 'w') as writer:
with ZipFile("${captureNormalsDBRCLZip}", 'r') as f:
names = f.namelist()
for name in names:
writer.write(name + '\n')
CODE
unzip ${captureNormalsDBRCLZip}
./run_fh_CopyNumberQCReport.sh /opt/MATLAB/MATLAB_Compiler_Runtime/v710/ PairCopyNumQCReport \
case.rcl control.rcl case.lanelist.txt control.lanelist.txt \
${readGroupBlackList} ${regionFile} capture_normals_db_wdl NA NA
}
runtime {
docker : "gcr.io/broad-getzlab-workflows/cga_production_pipeline:v0.2"
bootDiskSizeGb : diskGB_boot
preemptible : preemptible
cpu : cpu
disks : "local-disk ${diskGB} HDD"
memory : memoryGB + "GB"
}
output {
#lane lists
File tumorBamLaneList="case.lanelist.txt"
File normalBamLaneList="control.lanelist.txt"
File tumorRCL="case.rcl"
File normalRCL="control.rcl"
#CopyNumQC
File CopyNumQCReport="report.html"
File CopyNumQCReportPNG="PairCopyNumQCReport_CopyNumberQC.png"
Int CopyNumQCMixUps=read_int("num.mixups.txt")
}
}
task PicardMultipleMetrics_Task {
input{
# TASK INPUT PARAMS
File? bam
File? bamIndex
String? sampleName
File targetIntervals
File baitIntervals
File refFasta
File DB_SNP_VCF
File DB_SNP_VCF_IDX
String validationStringencyLevel ="LENIENT"
String run_clean_sam = false
# FILE SIZE
Int bam_size
Int refFasta_size
Int db_snp_vcf_size
# RUNTIME INPUT PARAMS
String preemptible ="1"
String diskGB_boot ="15"
String diskGB_buffer = "20"
String memoryGB ="7"
String cpu ="1"
String gatk_docker
String targetedRun = true
}
# DEFAULT VALUES
# COMPUTE MEMORY SIZE
Int command_memoryGB = floor(memoryGB) - 1
# COMPUTE DISK SIZE
Int diskGB = ceil(bam_size + refFasta_size + db_snp_vcf_size + diskGB_buffer)
parameter_meta {
bam : "sample (normal or tumor) BAM file"
bamIndex : "sample (normal or tumor) BAI file (BAM indexed)"
sampleName : "sample (normal or tumor) name, prefix for output"
refFasta : "FASTA file for the appropriate genome build (Reference sequence file)"
DB_SNP_VCF : "VCF format dbSNP file, used to exclude regions around known polymorphisms from analysis by some PROGRAMs"
DB_SNP_VCF_IDX : "dbSNP indexed file"
}
command {
if [ "${run_clean_sam}" = true ] ;
then
gatk --java-options "-Xmx~{command_memoryGB}g" ValidateSamFile \
--INPUT ${bam} \
--OUTPUT "${sampleName}.bam_validation" \
--MODE VERBOSE \
--IGNORE_WARNINGS true \
--REFERENCE_SEQUENCE ${refFasta} \
--VALIDATION_STRINGENCY ${validationStringencyLevel}
# Run bam through CleanSam to set MAPQ of unmapped reads to zero
gatk --java-options "-Xmx~{command_memoryGB}g" CleanSam \
--INPUT ${bam} \
--OUTPUT ${sampleName}.unmapped_reads_cleaned.bam
fi
gatk --java-options "-Xmx~{command_memoryGB}g" CollectMultipleMetrics \
--INPUT ${bam} \
--OUTPUT ${sampleName}.multiple_metrics \
--REFERENCE_SEQUENCE ${refFasta} \
--DB_SNP ${DB_SNP_VCF} \
--PROGRAM CollectAlignmentSummaryMetrics \
--PROGRAM CollectInsertSizeMetrics \
--PROGRAM QualityScoreDistribution \
--PROGRAM MeanQualityByCycle \
--PROGRAM CollectBaseDistributionByCycle \
--PROGRAM CollectSequencingArtifactMetrics \
--PROGRAM CollectQualityYieldMetrics \
--PROGRAM CollectGcBiasMetrics
#Extract OxoG metrics from generalized artifacts metrics.
# This tool extracts 8-oxoguanine (OxoG) artifact metrics from the output of CollectSequencingArtifactsMetrics
# (a tool that provides detailed information on a variety of
# artifacts found in sequencing libraries) and converts them to the CollectOxoGMetrics tool's output format. This
# conveniently eliminates the need to run CollectOxoGMetrics if we already ran CollectSequencingArtifactsMetrics in our
# pipeline.
gatk --java-options "-Xmx~{command_memoryGB}g" ConvertSequencingArtifactToOxoG \
--INPUT_BASE "${sampleName}.multiple_metrics" \
--OUTPUT_BASE "${sampleName}.multiple_metrics.converted" \
--REFERENCE_SEQUENCE ${refFasta} \
--VALIDATION_STRINGENCY ${validationStringencyLevel}
mkdir ${sampleName}.Picard_Multiple_Metrics
mv ${sampleName}.multiple_metrics.* ${sampleName}.Picard_Multiple_Metrics
#zip up reports for QC Nozzle report
tar -czvf ${sampleName}.picard_multiple_metrics.tar.gz ${sampleName}.Picard_Multiple_Metrics/
# Collect WES HS metrics
if [ "${targetedRun}" = true ];
then
gatk --java-options "-Xmx~{command_memoryGB}g" CollectHsMetrics \
--INPUT ${bam} \
--BAIT_INTERVALS ${targetIntervals} \
--TARGET_INTERVALS ${baitIntervals} \
--OUTPUT "${sampleName}.HSMetrics.txt" \
--VALIDATION_STRINGENCY ${validationStringencyLevel}
fi
}
runtime {
docker : gatk_docker
bootDiskSizeGb : diskGB_boot
preemptible : preemptible
cpu : cpu
disks : "local-disk ${diskGB} HDD"
memory : memoryGB + "GB"
}
output {
File picard_files="${sampleName}.picard_multiple_metrics.tar.gz"
File? bam_validation="${sampleName}.bam_validation"
File? bam_unmapped_cleaned="${sampleName}.unmapped_reads_cleaned.bam"
#File metricsReportsZip="${sampleName}.picard_multiple_metrics.zip"
#File alignment_summary_metrics="${sampleName}.multiple_metrics.alignment_summary_metrics"
#File bait_bias_detail_metrics="${sampleName}.multiple_metrics.bait_bias_detail_metrics"
#File bait_bias_summary_metrics="${sampleName}.multiple_metrics.bait_bias_summary_metrics"
#File base_distribution_by_cycle="${sampleName}.multiple_metrics.base_distribution_by_cycle.pdf"
#File base_distribution_by_cycle_metrics="${sampleName}.multiple_metrics.base_distribution_by_cycle_metrics"
#File gc_bias_detail_metrics="${sampleName}.multiple_metrics.gc_bias.detail_metrics"
#File gc_bias="${sampleName}.multiple_metrics.gc_bias.pdf"
#File gc_bias_summary_metrics="${sampleName}.multiple_metrics.gc_bias.summary_metrics"
#File insert_size_histogram="${sampleName}.multiple_metrics.insert_size_histogram.pdf"
#File insert_size_metrics="${sampleName}.multiple_metrics.insert_size_metrics"
#File pre_adapter_detail_metrics="${sampleName}.multiple_metrics.pre_adapter_detail_metrics"
#File pre_adapter_summary_metrics="${sampleName}.multiple_metrics.pre_adapter_summary_metrics"
#File quality_by_cycle="${sampleName}.multiple_metrics.quality_by_cycle.pdf"
#File quality_by_cycle_metrics="${sampleName}.multiple_metrics.quality_by_cycle_metrics"
#File quality_distribution="${sampleName}.multiple_metrics.quality_distribution.pdf"
#File quality_distribution_metrics="${sampleName}.multiple_metrics.quality_distribution_metrics"
#File quality_yield_metrics="${sampleName}.multiple_metrics.quality_yield_metrics"
#File converted_oxog_metrics="${sampleName}.multiple_metrics.converted.oxog_metrics"
File? hsMetrics="${sampleName}.HSMetrics.txt"
}
}
task ContEST_Task {
input{
# TASK INPUT PARAMS
File tumorBam
File tumorBamIdx
File? normalBam
File? normalBamIdx
File targetIntervals
File gnomad_idx
File gnomad
String pairName
String gatk_docker
# FILE SIZE
Int tumorBam_size
Int normalBam_size
# RUNTIME INPUT PARAMS
String preemptible ="1"
String diskGB_boot = "15"
String diskGB_buffer ="20"
String memoryGB ="10"
String cpu ="1"
}
# DEFAULT VALUES
# COMPUTE MEMORY SIZE
Int command_memoryGB = floor(memoryGB) - 1
# COMPUTE DISK SIZE
Int diskGB = ceil(1.1*(tumorBam_size + normalBam_size)+
+ size(targetIntervals, "G") + size(gnomad, "G") + diskGB_buffer)
parameter_meta {
tumorBam : "sample tumor BAM file"
tumorBamIdx : "sample tumor BAI file (indexed BAM file)"
normalBam : "sample normal BAM file"
normalBamIdx : "sample normal BAI file (indexed BAM file)"
pairName : "sample name, prefix for output"
targetIntervals : ""
}
command <<<
set -euxo pipefail
savTable="~{pairName}.contamination.table"
gatk --java-options "-Xmx~{command_memoryGB}g" GetPileupSummaries \
-I ~{normalBam} \
-V ~{gnomad} \
-L ~{targetIntervals} \
-O normal.pileups.table
gatk --java-options "-Xmx~{command_memoryGB}g" GetPileupSummaries \
-I ~{tumorBam} \
-V ~{gnomad} \
-L ~{targetIntervals} \
-O tumor.pileups.table
gatk --java-options "-Xmx~{command_memoryGB}g" CalculateContamination \
-I tumor.pileups.table \
-matched normal.pileups.table \
-O $savTable
awk 'NR == 2 {print $2}' $savTable > contamination.value
>>>
runtime {
docker : gatk_docker
bootDiskSizeGb : diskGB_boot
preemptible : preemptible
cpu : cpu
disks : "local-disk ${diskGB} HDD"
memory : memoryGB + "GB"
}
output {
File contamTable="${pairName}.contamination.table"
File normTable="normal.pileups.table"
File tumTable="tumor.pileups.table"
Float fracContam=read_float("contamination.value")
}
}
task CrossCheckLaneFingerprints_Task {
## NOTE: UPDATE THE GATK_JAR HERE!
## NOTE: Check if there's an update haplotypeDBforcrosscheck
## NOTE: Need to update
input {
# TASK INPUT PARAMS
File tumorBam
File? normalBam
File tumorBamIdx
File? normalBamIdx
String pairName
File HaplotypeDBForCrossCheck
String validationStringencyLevel = "LENIENT"
String gatk_docker
# FILE SIZE
Int tumorBam_size
Int normalBam_size
# RUNTIME INPUT PARAMS
String preemptible ="1"
String diskGB_boot ="15"
String diskGB_buffer ="20"
String memoryGB ="3"
String cpu ="1"
}
# COMPUTE MEMORY SIZE
Int command_memoryGB = floor(memoryGB) - 1
# COMPUTE DISK SIZE
Int diskGB = ceil(tumorBam_size + normalBam_size + size(HaplotypeDBForCrossCheck, "G")
+ diskGB_buffer)
parameter_meta {
tumorBam : "sample tumor BAM file"
tumorBamIdx : "sample tumor BAI file (indexed BAM file)"
normalBam : "sample normal BAM file"
normalBamIdx : "sample normal BAI file (indexed BAM file)"
pairName : "a string for the name of the pair under analysis used for naming output files"
HaplotypeDBForCrossCheck : ""
validationStringencyLevel : ""
}
command {
set -euxo pipefail
#drop from haplotypeDB seq entries which aren't in BAM if there are any found
#PREPPED_HAPLOTYPE_DB=PreppedHaplotypeDB.txt
#/usr/local/bin/filter_not_in_bam_dict.pl ${normalBam} ${HaplotypeDBForCrossCheck} $PREPPED_HAPLOTYPE_DB
#CrosscheckLaneFingerprints[version=9]/PREPPED HP DB
mkdir -v tmp
gatk --java-options "-Xmx${command_memoryGB}g" CrosscheckFingerprints \
-I ${tumorBam} \
-I ${normalBam} \
-H ${HaplotypeDBForCrossCheck} \
--TMP_DIR `pwd`/tmp \
--QUIET false \
--EXIT_CODE_WHEN_MISMATCH 0 \
--OUTPUT crosscheck.metrics \
--VALIDATION_STRINGENCY ${validationStringencyLevel}
#Produce crosscheck.stats.txt file for making the html report
grep -v "#" crosscheck.metrics | sed 1d > crosscheck.metrics.stripped
# python /usr/local/bin/crosscheck_report.py crosscheck.metrics.stripped
}
runtime {
docker : gatk_docker
bootDiskSizeGb : diskGB_boot
preemptible : preemptible
cpu : cpu
disks : "local-disk ${diskGB} HDD"
memory : memoryGB + "GB"
}
output {
File crossCheckMetrics="crosscheck.metrics"
}
}