This repository has been archived by the owner on Jul 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
/
mutect2_pon.wdl
171 lines (147 loc) · 5.52 KB
/
mutect2_pon.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
version 1.0
# Create a Mutect2 panel of normals
#
# Description of inputs
# intervals: genomic intervals
# ref_fasta, ref_fai, ref_dict: reference genome, index, and dictionary
# normal_bams: arrays of normal bams
# scatter_count: number of parallel jobs when scattering over intervals
# pon_name: the resulting panel of normals is {pon_name}.vcf
# m2_extra_args: additional command line parameters for Mutect2. This should not involve --max-mnp-distance,
# which the wdl hard-codes to 0 because GenpmicsDBImport can't handle MNPs
#import "mutect2.wdl" as m2
import "https://raw.githubusercontent.com/gatk-workflows/gatk4-somatic-snvs-indels/2.6.0/mutect2.wdl" as m2
workflow Mutect2_Panel {
input {
File? intervals
File ref_fasta
File ref_fai
File ref_dict
Int scatter_count
Array[String] normal_bams
Array[String] normal_bais
File gnomad
File gnomad_idx
String? m2_extra_args
String? create_pon_extra_args
Boolean? compress
String pon_name
Int? min_contig_size
Int? num_contigs
# runtime
String gatk_docker
File? gatk_override
String basic_bash_docker = "ubuntu:16.04"
Int? preemptible
Int? max_retries
Int small_task_cpu = 2
Int small_task_mem = 4
Int small_task_disk = 100
Int boot_disk_size = 12
# Use as a last resort to increase the disk given to every task in case of ill behaving data
Int? emergency_extra_disk
}
Int contig_size = select_first([min_contig_size, 1000000])
Int preemptible_or_default = select_first([preemptible, 2])
Int max_retries_or_default = select_first([max_retries, 2])
Runtime standard_runtime = {"gatk_docker": gatk_docker, "gatk_override": gatk_override,
"max_retries": max_retries_or_default, "preemptible": preemptible_or_default, "cpu": small_task_cpu,
"machine_mem": small_task_mem * 1000, "command_mem": small_task_mem * 1000 - 500,
"disk": small_task_disk, "boot_disk_size": boot_disk_size}
scatter (normal_bam in zip(normal_bams, normal_bais)) {
call m2.Mutect2 {
input:
intervals = intervals,
ref_fasta = ref_fasta,
ref_fai = ref_fai,
ref_dict = ref_dict,
tumor_reads = normal_bam.left,
tumor_reads_index = normal_bam.right,
scatter_count = scatter_count,
m2_extra_args = select_first([m2_extra_args, ""]) + "--max-mnp-distance 0",
gatk_override = gatk_override,
gatk_docker = gatk_docker,
preemptible = preemptible,
max_retries = max_retries
}
}
call m2.SplitIntervals {
input:
ref_fasta = ref_fasta,
ref_fai = ref_fai,
ref_dict = ref_dict,
scatter_count = select_first([num_contigs, 24]),
split_intervals_extra_args = "--subdivision-mode BALANCING_WITHOUT_INTERVAL_SUBDIVISION --min-contig-size " + contig_size,
runtime_params = standard_runtime
}
scatter (subintervals in SplitIntervals.interval_files ) {
call CreatePanel {
input:
input_vcfs = Mutect2.filtered_vcf,
intervals = subintervals,
ref_fasta = ref_fasta,
ref_fai = ref_fai,
ref_dict = ref_dict,
gnomad = gnomad,
gnomad_idx = gnomad_idx,
output_vcf_name = pon_name,
create_pon_extra_args = create_pon_extra_args,
runtime_params = standard_runtime
}
}
call m2.MergeVCFs {
input:
input_vcfs = CreatePanel.output_vcf,
input_vcf_indices = CreatePanel.output_vcf_index,
output_name = pon_name,
compress = select_first([compress, false]),
runtime_params = standard_runtime
}
output {
File pon = MergeVCFs.merged_vcf
File pon_idx = MergeVCFs.merged_vcf_idx
Array[File] normal_calls = Mutect2.filtered_vcf
Array[File] normal_calls_idx = Mutect2.filtered_vcf_idx
}
}
task CreatePanel {
input {
File intervals
Array[String] input_vcfs
File ref_fasta
File ref_fai
File ref_dict
String output_vcf_name
File gnomad
File gnomad_idx
String? create_pon_extra_args
# runtime
Runtime runtime_params
}
Int machine_mem = 8
Int command_mem = machine_mem - 1
parameter_meta{
gnomad: {localization_optional: true}
gnomad_idx: {localization_optional: true}
}
command {
set -e
export GATK_LOCAL_JAR=~{default="/root/gatk.jar" runtime_params.gatk_override}
gatk GenomicsDBImport --genomicsdb-workspace-path pon_db -R ~{ref_fasta} -V ~{sep=' -V ' input_vcfs} -L ~{intervals}
gatk --java-options "-Xmx~{command_mem}g" CreateSomaticPanelOfNormals -R ~{ref_fasta} --germline-resource ~{gnomad} \
-V gendb://pon_db -O ~{output_vcf_name}.vcf ~{create_pon_extra_args}
}
runtime {
docker: runtime_params.gatk_docker
bootDiskSizeGb: runtime_params.boot_disk_size
memory: machine_mem + " GB"
disks: "local-disk " + runtime_params.disk + " HDD"
preemptible: runtime_params.preemptible
maxRetries: runtime_params.max_retries
cpu: runtime_params.cpu
}
output {
File output_vcf = "~{output_vcf_name}.vcf"
File output_vcf_index = "~{output_vcf_name}.vcf.idx"
}
}