4141## onco_ds_tar_gz, default_config_file: Oncotator datasources and config file
4242## sequencing_center, sequence_source: metadata for Oncotator
4343## filter_oncotator_maf: Whether the MAF generated by oncotator should have the filtered variants removed. Default: true
44+ ## realignment_index_bundle: resource for FilterAlignmentArtifacts, which runs if and only if it is specified. Generated by BwaMemIndexImageCreator.
4445##
4546## Outputs :
4647## - One VCF file and its index with primary filtering applied; secondary filtering and functional annotation if requested; a bamout.bam
@@ -73,6 +74,8 @@ workflow Mutect2 {
7374 File ? gnomad_index
7475 File ? variants_for_contamination
7576 File ? variants_for_contamination_index
77+ File ? realignment_index_bundle
78+ String ? realignment_extra_args
7679 Boolean ? run_orientation_bias_filter
7780 Boolean run_ob_filter = select_first ([run_orientation_bias_filter , false ])
7881 Array [String ]? artifact_modes
@@ -115,6 +118,8 @@ workflow Mutect2 {
115118 String oncotator_docker_or_default = select_first ([oncotator_docker , "broadinstitute/oncotator:1.9.9.0" ])
116119 Boolean ? filter_oncotator_maf
117120 Boolean filter_oncotator_maf_or_default = select_first ([filter_oncotator_maf , true ])
121+ Boolean ? filter_funcotations
122+ Boolean filter_funcotations_or_default = select_first ([filter_funcotations , true ])
118123 String ? oncotator_extra_args
119124
120125 Int ? preemptible_attempts
@@ -302,8 +307,26 @@ workflow Mutect2 {
302307 }
303308 }
304309
310+ if (defined (realignment_index_bundle )) {
311+ File realignment_filter_input = select_first ([FilterByOrientationBias .filtered_vcf , Filter .filtered_vcf ])
312+ File realignment_filter_input_idx = select_first ([FilterByOrientationBias .filtered_vcf_index , Filter .filtered_vcf_index ])
313+ call FilterAlignmentArtifacts {
314+ input :
315+ gatk_override = gatk_override ,
316+ bam = tumor_bam ,
317+ bai = tumor_bai ,
318+ realignment_index_bundle = select_first ([realignment_index_bundle ]),
319+ realignment_extra_args = realignment_extra_args ,
320+ gatk_docker = gatk_docker ,
321+ compress = compress ,
322+ output_name = filtered_name ,
323+ input_vcf = realignment_filter_input ,
324+ input_vcf_idx = realignment_filter_input_idx
325+ }
326+ }
327+
305328 if (run_oncotator_or_default ) {
306- File oncotate_vcf_input = select_first ([FilterByOrientationBias .filtered_vcf , Filter .filtered_vcf ])
329+ File oncotate_vcf_input = select_first ([FilterAlignmentArtifacts . filtered_vcf , FilterByOrientationBias .filtered_vcf , Filter .filtered_vcf ])
307330 call oncotate_m2 {
308331 input :
309332 m2_vcf = oncotate_vcf_input ,
@@ -323,8 +346,8 @@ workflow Mutect2 {
323346 }
324347
325348 if (run_funcotator_or_default ) {
326- File funcotate_vcf_input = select_first ([FilterByOrientationBias .filtered_vcf , Filter .filtered_vcf ])
327- File funcotate_vcf_input_index = select_first ([FilterByOrientationBias .filtered_vcf_index , Filter .filtered_vcf_index ])
349+ File funcotate_vcf_input = select_first ([FilterAlignmentArtifacts . filtered_vcf , FilterByOrientationBias .filtered_vcf , Filter .filtered_vcf ])
350+ File funcotate_vcf_input_index = select_first ([FilterAlignmentArtifacts . filtered_vcf_index , FilterByOrientationBias .filtered_vcf_index , Filter .filtered_vcf_index ])
328351 call Funcotate {
329352 input :
330353 m2_vcf = funcotate_vcf_input ,
@@ -341,15 +364,16 @@ workflow Mutect2 {
341364 annotation_defaults = annotation_defaults ,
342365 annotation_overrides = annotation_overrides ,
343366 gatk_docker = gatk_docker ,
344- gatk_override = gatk_override
367+ gatk_override = gatk_override ,
368+ filter_funcotations = filter_funcotations_or_default
345369 }
346370 }
347371
348372 output {
349373 File unfiltered_vcf = MergeVCFs .merged_vcf
350374 File unfiltered_vcf_index = MergeVCFs .merged_vcf_index
351- File filtered_vcf = select_first ([FilterByOrientationBias .filtered_vcf , Filter .filtered_vcf ])
352- File filtered_vcf_index = select_first ([FilterByOrientationBias .filtered_vcf_index , Filter .filtered_vcf_index ])
375+ File filtered_vcf = select_first ([FilterAlignmentArtifacts . filtered_vcf , FilterByOrientationBias .filtered_vcf , Filter .filtered_vcf ])
376+ File filtered_vcf_index = select_first ([FilterAlignmentArtifacts . filtered_vcf_index , FilterByOrientationBias .filtered_vcf_index , Filter .filtered_vcf_index ])
353377 File ? contamination_table = CalculateContamination .contamination_table
354378
355379 File ? oncotated_m2_maf = oncotate_m2 .oncotated_m2_maf
@@ -358,6 +382,7 @@ workflow Mutect2 {
358382 File ? preadapter_detail_metrics = CollectSequencingArtifactMetrics .pre_adapter_metrics
359383 File ? bamout = MergeBamOuts .merged_bam_out
360384 File ? bamout_index = MergeBamOuts .merged_bam_out_index
385+ File ? maf_segments = CalculateContamination .maf_segments
361386 }
362387}
363388
@@ -400,6 +425,7 @@ task SplitIntervals {
400425
401426 runtime {
402427 docker : gatk_docker
428+ bootDiskSizeGb : 12
403429 memory : machine_mem + " MB"
404430 disks : "local-disk " + select_first ([disk_space , 100 ]) + if use_ssd then " SSD" else " HDD"
405431 preemptible : select_first ([preemptible_attempts , 10 ])
@@ -481,6 +507,7 @@ task M2 {
481507
482508 runtime {
483509 docker : gatk_docker
510+ bootDiskSizeGb : 12
484511 memory : machine_mem + " MB"
485512 disks : "local-disk " + select_first ([disk_space , 100 ]) + if use_ssd then " SSD" else " HDD"
486513 preemptible : select_first ([preemptible_attempts , 10 ])
@@ -529,6 +556,7 @@ task MergeVCFs {
529556
530557 runtime {
531558 docker : gatk_docker
559+ bootDiskSizeGb : 12
532560 memory : machine_mem + " MB"
533561 disks : "local-disk " + select_first ([disk_space , 100 ]) + if use_ssd then " SSD" else " HDD"
534562 preemptible : select_first ([preemptible_attempts , 10 ])
@@ -576,12 +604,13 @@ task MergeBamOuts {
576604
577605 gatk --java-options "-Xmx${command_mem} m" SortSam -I unsorted.out.bam \
578606 -O ${output_vcf_name }.out.bam \
579- --SORT_ORDER coordinate
580- gatk --java-options "-Xmx${command_mem} m" BuildBamIndex -I ${output_vcf_name }.out.bam
607+ --SORT_ORDER coordinate -VALIDATION_STRINGENCY LENIENT
608+ gatk --java-options "-Xmx${command_mem} m" BuildBamIndex -I ${output_vcf_name }.out.bam -VALIDATION_STRINGENCY LENIENT
581609 >>>
582610
583611 runtime {
584612 docker : gatk_docker
613+ bootDiskSizeGb : 12
585614 memory : machine_mem + " MB"
586615 disks : "local-disk " + select_first ([disk_space , 100 ]) + if use_ssd then " SSD" else " HDD"
587616 preemptible : select_first ([preemptible_attempts , 10 ])
@@ -624,6 +653,7 @@ task CollectSequencingArtifactMetrics {
624653
625654 runtime {
626655 docker : gatk_docker
656+ bootDiskSizeGb : 12
627657 memory : machine_mem + " MB"
628658 disks : "local-disk " + select_first ([disk_space , 100 ]) + if use_ssd then " SSD" else " HDD"
629659 preemptible : select_first ([preemptible_attempts , 10 ])
@@ -676,6 +706,7 @@ task CalculateContamination {
676706
677707 runtime {
678708 docker : gatk_docker
709+ bootDiskSizeGb : 12
679710 memory : command_mem + " MB"
680711 disks : "local-disk " + select_first ([disk_space , 100 ]) + " HDD"
681712 preemptible : select_first ([preemptible_attempts , 10 ])
@@ -729,6 +760,7 @@ task Filter {
729760
730761 runtime {
731762 docker : gatk_docker
763+ bootDiskSizeGb : 12
732764 memory : machine_mem + " MB"
733765 disks : "local-disk " + select_first ([disk_space , 100 ]) + if use_ssd then " SSD" else " HDD"
734766 preemptible : select_first ([preemptible_attempts , 10 ])
@@ -779,6 +811,61 @@ task FilterByOrientationBias {
779811
780812 runtime {
781813 docker : gatk_docker
814+ bootDiskSizeGb : 12
815+ memory : command_mem + " MB"
816+ disks : "local-disk " + select_first ([disk_space , 100 ]) + if use_ssd then " SSD" else " HDD"
817+ preemptible : select_first ([preemptible_attempts , 10 ])
818+ cpu : select_first ([cpu , 1 ])
819+ }
820+
821+ output {
822+ File filtered_vcf = "${output_vcf }"
823+ File filtered_vcf_index = "${output_vcf_index }"
824+ }
825+ }
826+
827+ task FilterAlignmentArtifacts {
828+ #input
829+ File ? gatk_override
830+ File input_vcf
831+ File input_vcf_idx
832+ File bam
833+ File bai
834+ String output_name
835+ Boolean compress
836+ String output_vcf = output_name + if compress then ".vcf.gz" else ".vcf"
837+ String output_vcf_index = output_vcf + if compress then ".tbi" else ".idx"
838+ File realignment_index_bundle
839+ String ? realignment_extra_args
840+
841+ # runtime
842+ String gatk_docker
843+ Int ? mem
844+ Int ? preemptible_attempts
845+ Int ? disk_space
846+ Int ? cpu
847+ Boolean use_ssd = false
848+
849+ # Mem is in units of GB but our command and memory runtime values are in MB
850+ Int machine_mem = if defined (mem ) then mem * 1000 else 9000
851+ Int command_mem = machine_mem - 500
852+
853+ command {
854+ set -e
855+
856+ export GATK_LOCAL_JAR = ${default ="/root/gatk.jar" gatk_override }
857+
858+ gatk --java-options "-Xmx${command_mem} m" FilterAlignmentArtifacts \
859+ -V ${input_vcf } \
860+ -I ${bam } \
861+ --bwa-mem-index-image ${realignment_index_bundle } \
862+ ${realignment_extra_args } \
863+ -O ${output_vcf }
864+ }
865+
866+ runtime {
867+ docker : gatk_docker
868+ bootDiskSizeGb : 12
782869 memory : command_mem + " MB"
783870 disks : "local-disk " + select_first ([disk_space , 100 ]) + if use_ssd then " SSD" else " HDD"
784871 preemptible : select_first ([preemptible_attempts , 10 ])
@@ -842,7 +929,7 @@ task oncotate_m2 {
842929 fi
843930
844931 ${default ="/root/oncotator_venv/bin/oncotator" oncotator_exe } --db-dir onco_dbdir / -c $HOME /tx_exact_uniprot_matches.AKT1_CRLF2_FGFR1.txt \
845- -v ${m2_vcf } ${case_id }.maf.annotated hg19 -i VCF -o TCGAMAF --skip-no-alt --infer-onps -- collapse-number-annotations --log_name oncotator.log \
932+ -v ${m2_vcf } ${case_id }.maf.annotated hg19 -i VCF -o TCGAMAF --skip-no-alt --collapse-number-annotations --log_name oncotator.log \
846933 -a Center :${default ="Unknown" sequencing_center } \
847934 -a source :${default ="Unknown" sequence_source } \
848935 -a normal_barcode :${control_id } \
@@ -906,12 +993,14 @@ task Funcotate {
906993 Array [String ]? transcript_selection_list
907994 Array [String ]? annotation_defaults
908995 Array [String ]? annotation_overrides
996+ Boolean filter_funcotations
909997
910998 # ==============
911999 # Process input args:
9121000 String transcript_selection_arg = if defined (transcript_selection_list ) then " --transcript-list " else ""
9131001 String annotation_def_arg = if defined (annotation_defaults ) then " --annotation-default " else ""
9141002 String annotation_over_arg = if defined (annotation_overrides ) then " --annotation-override " else ""
1003+ String filter_funcotations_args = if (filter_funcotations ) then " --remove-filtered-variants " else ""
9151004 # ==============
9161005
9171006 # runtime
@@ -962,11 +1051,13 @@ task Funcotate {
9621051 ${"--transcript-selection-mode " + transcript_selection_mode } \
9631052 ${transcript_selection_arg }${default ="" sep =" --transcript-list " transcript_selection_list } \
9641053 ${annotation_def_arg }${default ="" sep =" --annotation-default " annotation_defaults } \
965- ${annotation_over_arg }${default ="" sep =" --annotation-override " annotation_overrides }
1054+ ${annotation_over_arg }${default ="" sep =" --annotation-override " annotation_overrides } \
1055+ ${filter_funcotations_args }
9661056 >>>
9671057
9681058 runtime {
9691059 docker : gatk_docker
1060+ bootDiskSizeGb : 12
9701061 memory : machine_mem + " MB"
9711062 disks : "local-disk " + select_first ([disk_space_gb , default_disk_space_gb ]) + if use_ssd then " SSD" else " HDD"
9721063 preemptible : select_first ([preemptible_attempts , 3 ])
0 commit comments