forked from trinhan/WDLPipelines
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvardict.wdl
322 lines (280 loc) · 10.7 KB
/
vardict.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
## Steps in this workflow:
## 1. Parallelise the intervals
## 2. run vardict on each
## 3. update headers
## 4. consolidate into 1 final vcf file
version 1.0
workflow VardictWF {
input {
File refFastaIdx
File refFasta
File refFastaDict
File? normalBam
File? normalBamIdx
File tumorBam
File tumorBamIdx
String? ctrlName
String caseName
Array[File] bed_list_in
Array[Int] scatterIndices_in
String gatk_docker
File? InputtargetInterval
}
Boolean buildIndices = if defined(bed_list_in) then false else true
File targetIntervals = select_first([InputtargetInterval, "NULL"])
if (buildIndices){
call CallSomaticMutations_Prepare_Task {
input:
refFasta=refFasta,
refFastaIdx=refFastaIdx,
refFastaDict=refFastaDict,
targetIntervals=targetIntervals,
gatk_docker=gatk_docker # takes padded interval file (10bp on each side)
}
}
Array[File] bed_list=select_first([bed_list_in, CallSomaticMutations_Prepare_Task.bed_list])
Array[Int] scatterIndices=select_first([scatterIndices_in, CallSomaticMutations_Prepare_Task.scatterIndices])
scatter (idx in scatterIndices) {
call runVardict {
input:
referenceFasta=refFasta,
referenceFastaFai=refFastaIdx,
tumorBam=tumorBam,
tumorBamIndex=tumorBamIdx,
normalBam=normalBam,
normalBamIndex=normalBamIdx,
outputName=caseName,
tumorSampleName=caseName,
bedFile=bed_list[idx],
tumorSampleName=caseName,
normalSampleName=ctrlName
}
}
call UpdateHeaders {
input:
input_vcfs = runVardict.vcfFile,
ref_dict=refFastaDict,
gatk_docker = gatk_docker,
caller = "Vardict"
}
call CombineVariants {
input:
input_header=UpdateHeaders.head_vcf,
ref_fasta = refFasta,
ref_fai = refFastaIdx,
ref_dict = refFastaDict,
gatk_docker = gatk_docker,
sample_name = caseName,
caller="Vardict"
}
output {
File vardict=CombineVariants.merged_vcf
}
}
task runVardict {
input {
## sample information here
String tumorSampleName
File tumorBam
File tumorBamIndex
String? normalSampleName
File? normalBam
File? normalBamIndex
## reference files go here
File referenceFasta
File referenceFastaFai
File? bedFile
String outputName
Boolean outputCandidateSomaticOnly = true
Boolean outputAllVariantsAtSamePosition = true
Boolean callSVs = false
Float mappingQuality = 20
Int minimumTotalDepth = 8
Int minimumVariantDepth = 5
Float minimumAlleleFrequency = 0.05
Int chromosomeColumn = 1
Int startColumn = 2
Int endColumn = 3
Int geneColumn = 4
Int runLocalRelignment = 0
## run time parameters
String javaXmx = "15G"
Int threads = 4
String memory = "16"
String dockerImage = "quay.io/biocontainers/vardict-java:1.8.3--hdfd78af_0"
Int? opt_preempt
Int? timeMinutes = 350
}
Int diskGB=3*ceil(size(tumorBam, "GB")+size(normalBam, "GB")+size(referenceFasta, "GB"))
String runPaired = if defined(normalBam) then "1" else "0"
command {
## remove this command: -XX:ParallelGCThreads=1
set -e -o pipefail
export JAVA_OPTS="-Xmx~{javaXmx}"
vardict-java \
~{"-th " + threads} \
-G ~{referenceFasta} \
-N ~{tumorSampleName} \
-b "~{tumorBam}~{"|" + normalBam}" \
~{false="--nosv " true = "" callSVs} \
~{true="" false="-z" defined(normalBam)} \
-c ~{chromosomeColumn} \
-S ~{startColumn} \
-E ~{endColumn} \
-g ~{geneColumn} \
~{bedFile} | \
~{true="testsomatic.R" false="teststrandbias.R" defined(normalBam)} | \
~{true="var2vcf_paired.pl" false="var2vcf_valid.pl" defined(normalBam)} \
-N "~{tumorSampleName}~{"|" + normalSampleName}" \
~{true="" false="-E" defined(normalBam)} \
~{true="-M" false="" outputCandidateSomaticOnly} \
~{true="-A" false="" outputAllVariantsAtSamePosition} \
-Q ~{mappingQuality} \
-d ~{minimumTotalDepth} \
-v ~{minimumVariantDepth} \
-f ~{minimumAlleleFrequency} \
> ~{outputName}.vardict.vcf
}
output {
File vcfFile = "~{outputName}.vardict.vcf"
}
runtime {
cpu: threads
memory: "${memory} GB"
docker: dockerImage
disks: "local-disk ${diskGB} HDD"
preemptible: select_first([opt_preempt, 1])
time_minutes: timeMinutes
}
parameter_meta {
# inputs
tumorSampleName: {description: "The name of the tumor/case sample.", category: "required"}
tumorBam: {description: "The tumor/case sample's BAM file.", category: "required"}
tumorBamIndex: {description: "The index for the tumor/case sample's BAM file.", category: "required"}
referenceFasta: {description: "The reference fasta file.", category: "required"}
referenceFastaFai: {description: "The index for the reference fasta file.", category: "required"}
bedFile: {description: "A bed file describing the regions to operate on. These regions must be below 1e6 bases in size.", category: "required"}
outputCandidateSomaticOnly: {description: "Equivalent to var2vcf_paired.pl or var2vcf_valid.pl's `-M` flag.", category: "advanced"}
outputAllVariantsAtSamePosition: {description: "Equivalent to var2vcf_paired.pl or var2vcf_valid.pl's `-A` flag.", category: "advanced"}
mappingQuality: {description: "Equivalent to var2vcf_paired.pl or var2vcf_valid.pl's `-Q` option.", category: "advanced"}
minimumTotalDepth: {description: "Equivalent to var2vcf_paired.pl or var2vcf_valid.pl's `-d` option.", category: "advanced"}
minimumVariantDepth: {description: "Equivalent to var2vcf_paired.pl or var2vcf_valid.pl's `-v` option.", category: "advanced"}
minimumAlleleFrequency: {description: "Equivalent to var2vcf_paired.pl or var2vcf_valid.pl's `-f` option.", category: "advanced"}
chromosomeColumn: {description: "Equivalent to vardict-java's `-c` option.", category: "advanced"}
startColumn: {description: "Equivalent to vardict-java's `-S` option.", category: "advanced"}
endColumn: {description: "Equivalent to vardict-java's `-E` option.", category: "advanced"}
geneColumn: {description: "Equivalent to vardict-java's `-g` option.", category: "advanced"}
normalSampleName: {description: "The name of the normal/control sample.", category: "common"}
normalBam: {description: "The normal/control sample's BAM file.", category: "common"}
normalBamIndex: {description: "The normal/control sample's BAM file.", category: "common"}
javaXmx: {description: "The maximum memory available to the program. Should be lower than `memory` to accommodate JVM overhead.", category: "advanced"}
threads: {description: "The number of threads to use.", category: "advanced"}
memory: {description: "The amount of memory this job will use.", category: "advanced"}
dockerImage: {description: "The docker image used for this task. Changing this may result in errors which the developers may choose not to address.", category: "advanced"}
}
}
task CombineVariants {
input {
Array[File] input_header
String caller
File ref_fasta
File ref_fai
File ref_dict
# runtime
String gatk_docker
String sample_name
Int mem_gb= 6
}
Int diskGB = 4*ceil(size(ref_fasta, "GB")+size(input_header, "GB"))
command <<<
gatk GatherVcfs -I ~{sep=' -I ' input_header} -R ~{ref_fasta} -O ~{sample_name}.~{caller}.vcf
>>>
runtime {
docker: gatk_docker
memory: "~{mem_gb} GB"
disk_space: "local-disk ~{diskGB} HDD"
}
output {
File merged_vcf = "~{sample_name}.~{caller}.vcf"
}
}
task UpdateHeaders {
input {
Array[File] input_vcfs
File ref_dict
# runtime
String gatk_docker
String caller
Int mem_gb=6
}
Int diskGB = 4*ceil(size(ref_dict, "GB"))
command <<<
count=0
for i in ~{sep=' ' input_vcfs};
do
newstr=`basename $i`
gatk UpdateVCFSequenceDictionary \
-V $i \
--source-dictionary ~{ref_dict} \
--output $newstr.$count.reheader.~{caller}.vcf \
--replace true
count+=1
done
>>>
runtime {
docker: gatk_docker
memory: "~{mem_gb} GB"
disk_space: "local-disk ~{diskGB} HDD"
}
output {
Array[File] head_vcf = glob("*.reheader.~{caller}.vcf")
}
}
task CallSomaticMutations_Prepare_Task {
input {
# TASK INPUT PARAMS
File targetIntervals
File refFasta
File refFastaIdx
File refFastaDict
String nWay = "10"
# RUNTIME INPUT PARAMS
String preemptible = "1"
String diskGB_boot = "15"
String gatk_docker
}
parameter_meta {
nWay : "Number of ways to scatter (MuTect1 and MuTect2)"
targetIntervals : "a list of genomic intervals over which MuTect1 will operate"
refFasta : "FASTA file for the appropriate genome build (Reference sequence file)"
refFastaIdx : "FASTA file index for the reference genome"
refFastaDict : "FASTA file dictionary for the reference genome"
}
command {
set -euxo pipefail
seq 0 $((~{nWay}-1)) > indices.dat
# create a list of intervalfiles
mkdir intervalfolder
gatk SplitIntervals -R ~{refFasta} -L ~{targetIntervals} --scatter-count ~{nWay} --subdivision-mode BALANCING_WITHOUT_INTERVAL_SUBDIVISION -O intervalfolder
cp intervalfolder/*.interval_list .
## make the list of bed files
mkdir bedfolder
for file in *.interval_list;
do
gatk IntervalListToBed -I $file -O bedfolder/$file.bed
##small hack to subtract 1 from the bed file
done
cp bedfolder/*.bed .
}
runtime {
docker : gatk_docker
bootDiskSizeGb : diskGB_boot
preemptible : preemptible
memory : "1 GB"
}
output {
Array[File] interval_files=glob("*.interval_list")
Array[Int] scatterIndices=read_lines("indices.dat")
Array[File] bed_list=glob("*.bed")
}
}