-
Notifications
You must be signed in to change notification settings - Fork 29
/
gridss.wdl
496 lines (433 loc) · 19.4 KB
/
gridss.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
version 1.0
# Copyright (c) 2020 Leiden University Medical Center
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import "bwa.wdl" as bwa
task AnnotateInsertedSequence {
input {
File inputVcf
String outputPath = "gridss.annotated.vcf.gz"
File viralReference
File viralReferenceFai
File viralReferenceDict
File viralReferenceImg
Int threads = 8
String javaXmx = "8G"
String memory = "9GiB"
String dockerImage = "quay.io/biowdl/gridss:2.12.2"
Int timeMinutes = 120
}
command {
set -e
_JAVA_OPTIONS="$_JAVA_OPTIONS -Xmx~{javaXmx}"
AnnotateInsertedSequence \
REFERENCE_SEQUENCE=~{viralReference} \
INPUT=~{inputVcf} \
OUTPUT=~{outputPath} \
ALIGNMENT=APPEND \
WORKING_DIR='.' \
WORKER_THREADS=~{threads}
}
output {
File outputVcf = outputPath
File outputVcfIndex = outputPath + ".tbi"
}
runtime {
cpu: threads
memory: memory
time_minutes: timeMinutes # !UnknownRuntimeKey
docker: dockerImage
}
parameter_meta {
inputVcf: {description: "The input VCF file.", category: "required"}
outputPath: {description: "The path the output will be written to.", category: "common"}
viralReference: {description: "A fasta file with viral sequences.", category: "required"}
viralReferenceFai: {description: "The index for the viral reference fasta.", category: "required"}
viralReferenceDict: {description: "The dict file for the viral reference.", category: "required"}
viralReferenceImg: {description: "The BWA index image (generated with GATK BwaMemIndexImageCreator) of the viral reference.", category: "required"}
memory: {description: "The amount of memory this job will use.", category: "advanced"}
javaXmx: {description: "The maximum memory available to the program. Should be lower than `memory` to accommodate JVM overhead.",
category: "advanced"}
timeMinutes: {description: "The maximum amount of time the job will run in minutes.", 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 AnnotateSvTypes {
input {
File gridssVcf
File gridssVcfIndex
String outputPath = "./gridss.svtyped.vcf.bgz"
String memory = "32GiB"
String dockerImage = "quay.io/biocontainers/bioconductor-structuralvariantannotation:1.10.0--r41hdfd78af_0"
Int timeMinutes = 240
}
String effectiveOutputPath = sub(outputPath, "\\.bgz", "")
String index = if effectiveOutputPath != outputPath then "T" else "F"
# Based on https://github.com/PapenfussLab/gridss/issues/74
command <<<
set -e
mkdir -p "$(dirname ~{outputPath})"
R --vanilla << "EOF"
library(VariantAnnotation)
library(StructuralVariantAnnotation)
vcf_path <- "~{gridssVcf}"
out_path <- "~{effectiveOutputPath}"
# Simple SV type classifier
simpleEventType <- function(gr) {
return(ifelse(seqnames(gr) != seqnames(partner(gr)), "BND", # inter-chromosomosal
ifelse(gr$insLen >= abs(gr$svLen) * 0.7, "INS",
ifelse(strand(gr) == strand(partner(gr)), "INV",
ifelse(xor(start(gr) < start(partner(gr)), strand(gr) == "-"), "DEL",
"DUP")))))
}
header <- scanVcfHeader(vcf_path)
vcf <- readVcf(vcf_path, seqinfo(header))
gr <- breakpointRanges(vcf)
svtype <- simpleEventType(gr)
info(vcf[gr$sourceId])$SVTYPE <- svtype
# GRIDSS doesn't supply a GT, simply set it to 0/1
geno(vcf)$GT <- as.matrix(sapply(row.names(vcf), function(x) {"0/1"}))
# Select only one breakend per event (also removes single breakends):
# sourceId ends with o or h for paired breakends, the first in the pair
# end with o the second with h. Single breakend end with b, these will
# also be removed since we can't determine the SVTYPE.
gr2 <- gr[grepl(".*o$", gr$sourceId)]
writeVcf(vcf[gr2$sourceId], out_path, index=~{index})
EOF
>>>
output {
File vcf = outputPath
File? vcfIndex = outputPath + ".tbi"
}
runtime {
memory: memory
time_minutes: timeMinutes # !UnknownRuntimeKey
docker: dockerImage
}
parameter_meta {
gridssVcf: {description: "The VCF produced by GRIDSS.", category: "required"}
gridssVcfIndex: {description: "The index for the VCF produced by GRIDSS.", category: "required"}
outputPath: {description: "The path the output should be written to.", category: "common"}
memory: {description: "The amount of memory this job will use.", category: "advanced"}
timeMinutes: {description: "The maximum amount of time the job will run in minutes.", 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 FilterPon {
input {
File ponBed
File ponBedpe
Int minimumScore = 3
String outputDir = "."
String memory = "1GiB"
String dockerImage = "quay.io/biowdl/gridss:2.12.2"
Int timeMinutes = 20
}
command <<<
set -e
mkdir -p ~{outputDir}
cat ~{ponBed} | awk '{if ($5 >= ~{minimumScore}) print $0}' > ~{outputDir}/gridss_pon_single_breakend.bed
cat ~{ponBedpe} | awk '{if ($8 >= ~{minimumScore}) print $0}' > ~{outputDir}/gridss_pon_breakpoint.bedpe
>>>
output {
File bedpe = "~{outputDir}/gridss_pon_breakpoint.bedpe"
File bed = "~{outputDir}/gridss_pon_single_breakend.bed"
}
runtime {
memory: memory
time_minutes: timeMinutes # !UnknownRuntimeKey
docker: dockerImage
}
parameter_meta {
ponBed: {description: "The PON BED file.", category: "required"}
ponBedpe: {description: "The PON BEDPE file.", category: "required"}
minimumScore: {description: "The minimum number normal samples an SV must have been found in to be kept.", category: "advanced"}
outputDir: {description: "The directory the output will be written to.", category: "common"}
memory: {description: "The amount of memory this job will use.", category: "advanced"}
timeMinutes: {description: "The maximum amount of time the job will run in minutes.", 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 GeneratePonBedpe {
input {
Array[File]+ vcfFiles
Array[File]+ vcfIndexes
File referenceFasta
File referenceFastaFai
String outputDir = "."
Int threads = 8
String javaXmx = "8G"
String memory = "9GiB"
String dockerImage = "quay.io/biowdl/gridss:2.12.2"
Int timeMinutes = 120
}
command {
set -e
mkdir -p ~{outputDir}
java -Xmx~{javaXmx} \
-cp /usr/local/share/gridss-2.12.2-0/gridss.jar \
gridss.GeneratePonBedpe \
INPUT=~{sep=" INPUT=" vcfFiles} \
NO=0 \
O=~{outputDir}/gridss_pon_breakpoint.bedpe \
SBO=~{outputDir}/gridss_pon_single_breakend.bed \
REFERENCE_SEQUENCE=~{referenceFasta} \
THREADS=~{threads}
}
output {
File bedpe = "~{outputDir}/gridss_pon_breakpoint.bedpe"
File bed = "~{outputDir}/gridss_pon_single_breakend.bed"
}
runtime {
cpu: threads
memory: memory
time_minutes: timeMinutes # !UnknownRuntimeKey
docker: dockerImage
}
parameter_meta {
vcfFiles: {description: "The vcf files with the normals as the first sample.", category: "required"}
referenceFasta: {description: "The fasta of the reference genome.", category: "required"}
referenceFastaFai: {description: "The index for the reference genome fasta.", category: "required"}
outputDir: {description: "The directory the output will be written to.", category: "common"}
threads: {description: "The number of the threads to use.", category: "advanced"}
memory: {description: "The amount of memory this job will use.", category: "advanced"}
javaXmx: {description: "The maximum memory available to the program. Should be lower than `memory` to accommodate JVM overhead.",
category: "advanced"}
timeMinutes: {description: "The maximum amount of time the job will run in minutes.", 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 GRIDSS {
input {
Array[File]+ tumorBam
Array[File]+ tumorBai
Array[String]+ tumorLabel
BwaIndex reference
String outputPrefix = "gridss"
File? normalBam
File? normalBai
String? normalLabel
File? blacklistBed
File? gridssProperties
Int jvmHeapSizeGb = 64
Int nonJvmMemoryGb = 10
Int threads = 12
Int timeMinutes = ceil(7200 / threads) + 1800
String dockerImage = "quay.io/biowdl/gridss:2.12.2"
}
command {
set -e
mkdir -p "$(dirname ~{outputPrefix})"
gridss \
-w . \
--reference ~{reference.fastaFile} \
--output ~{outputPrefix}.vcf.gz \
--assembly ~{outputPrefix}_assembly.bam \
~{"-c " + gridssProperties} \
~{"-t " + threads} \
~{"--jvmheap " + jvmHeapSizeGb + "G"} \
--labels ~{normalLabel}~{true="," false="" defined(normalLabel)}~{sep="," tumorLabel} \
~{"--blacklist " + blacklistBed} \
~{normalBam} \
~{sep=" " tumorBam}
samtools index ~{outputPrefix}_assembly.bam ~{outputPrefix}_assembly.bai
# For some reason the VCF index is sometimes missing
if [ ! -e ~{outputPrefix}.vcf.gz.tbi ]
then
tabix ~{outputPrefix}.vcf.gz
fi
}
output {
File vcf = outputPrefix + ".vcf.gz"
File vcfIndex = outputPrefix + ".vcf.gz.tbi"
File assembly = outputPrefix + "_assembly.bam"
File assemblyIndex = outputPrefix + "_assembly.bai"
}
runtime {
cpu: threads
memory: "~{jvmHeapSizeGb + nonJvmMemoryGb}GiB"
time_minutes: timeMinutes # !UnknownRuntimeKey
docker: dockerImage
}
parameter_meta {
# inputs
tumorBam: {description: "The input BAM file. This should be the tumor/case sample in case of a paired analysis.", category: "required"}
tumorBai: {description: "The index for tumorBam.", category: "required"}
tumorLabel: {description: "The name of the (tumor) sample.", category: "required"}
reference: {description: "A BWA index, this should also include the fasta index file (.fai).", category: "required"}
outputPrefix: {description: "The prefix for the output files. This may include parent directories.", category: "common"}
normalBam: {description: "The BAM file for the normal/control sample.", category: "advanced"}
normalBai: {description: "The index for normalBam.", category: "advanced"}
normalLabel: {description: "The name of the normal sample.", category: "advanced"}
blacklistBed: {description: "A bed file with blaclisted regins.", category: "advanced"}
gridssProperties: {description: "A properties file for gridss.", category: "advanced"}
threads: {description: "The number of the threads to use.", category: "advanced"}
jvmHeapSizeGb: {description: "The size of JVM heap for assembly and variant calling", category: "advanced"}
nonJvmMemoryGb: {description: "The amount of memory in Gb to be requested besides JVM memory.", category: "advanced"}
timeMinutes: {description: "The maximum amount of time the job will run in minutes.", 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"}
# outputs
vcf: {description: "VCF file including variant allele fractions."}
vcfIndex: {description: "Index of output VCF."}
assembly: {description: "The GRIDSS assembly BAM."}
assemblyIndex: {description: "Index of output BAM file."}
}
}
task GridssAnnotateVcfRepeatmasker {
input {
File gridssVcf
File gridssVcfIndex
String outputPath = "./gridss.repeatmasker_annotated.vcf.gz"
String memory = "25GiB"
Int threads = 8
String dockerImage = "quay.io/biowdl/gridss:2.12.2"
Int timeMinutes = 1440
}
command {
gridss_annotate_vcf_repeatmasker \
--output ~{outputPath} \
--jar /usr/local/share/gridss-2.12.2-0/gridss.jar \
-w . \
-t ~{threads} \
~{gridssVcf}
}
output {
File annotatedVcf = outputPath
File annotatedVcfIndex = "~{outputPath}.tbi"
}
runtime {
cpu: threads
memory: memory
time_minutes: timeMinutes # !UnknownRuntimeKey
docker: dockerImage
}
parameter_meta {
gridssVcf: {description: "The GRIDSS output.", category: "required"}
gridssVcfIndex: {description: "The index for the GRIDSS output.", category: "required"}
outputPath: {description: "The path the output should be written to.", category: "common"}
threads: {description: "The number of the threads to use.", category: "advanced"}
memory: {description: "The amount of memory this job will use.", category: "advanced"}
timeMinutes: {description: "The maximum amount of time the job will run in minutes.", 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 SomaticFilter {
input {
File vcfFile
File vcfIndex
File ponBed
File ponBedpe
String outputPath = "./high_confidence_somatic.vcf"
String fullOutputPath = "./high_and_low_confidence_somatic.vcf"
String memory = "16GiB"
String dockerImage = "quay.io/biowdl/gridss:2.12.2"
Int timeMinutes = 60
}
String ponDir = sub(ponBed, basename(ponBed), "")
command {
set -e
mkdir -p $(dirname ~{outputPath})
mkdir -p $(dirname ~{fullOutputPath})
gridss_somatic_filter \
--pondir ~{ponDir} \
--input ~{vcfFile} \
--output ~{outputPath} \
--fulloutput ~{fullOutputPath}
}
output {
File fullVcf = "~{fullOutputPath}.bgz"
File fullVcfIndex = "~{fullOutputPath}.bgz.tbi"
File highConfidenceVcf = "~{outputPath}.bgz"
File highConfidenceVcfIndex = "~{outputPath}.bgz.tbi"
}
runtime {
memory: memory
time_minutes: timeMinutes # !UnknownRuntimeKey
docker: dockerImage
}
parameter_meta {
vcfFile: {description: "The GRIDSS VCF file.", category: "required"}
vcfIndex: {description: "The index for the GRIDSS VCF file.", category: "required"}
ponBed: {description: "The PON BED file.", category: "required"}
ponBedpe: {description: "The PON BEDPE file.", category: "required"}
outputPath: {description: "The path the high confidence output should be written to.", category: "common"}
fullOutputPath: {description: "The path the full output should be written to.", category: "common"}
memory: {description: "The amount of memory this job will use.", category: "advanced"}
timeMinutes: {description: "The maximum amount of time the job will run in minutes.", 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 Virusbreakend {
input {
File bam
File bamIndex
File referenceFasta
File referenceFastaFai
File referenceFastaDict
File referenceImg
File virusbreakendDB
String outputPath = "./virusbreakend.vcf"
String memory = "75GiB"
Int threads = 12
String dockerImage = "quay.io/biowdl/gridss:2.12.2"
Int timeMinutes = 320
}
command {
set -e
mkdir virusbreakenddb
tar -xzvf ~{virusbreakendDB} -C virusbreakenddb --strip-components 1
virusbreakend \
--output ~{outputPath} \
--workingdir . \
--reference ~{referenceFasta} \
--db virusbreakenddb \
--jar /usr/local/share/gridss-2.12.2-0/gridss.jar \
-t ~{threads} \
~{bam}
}
output {
File vcf = outputPath
File summary = "~{outputPath}.summary.tsv"
}
runtime {
cpu: threads
memory: memory
time_minutes: timeMinutes # !UnknownRuntimeKey
docker: dockerImage
}
parameter_meta {
bam: {description: "A BAM file.", category: "required"}
bamIndex: {description: "The index for the BAM file.", category: "required"}
referenceFasta: {description: "The fasta of the reference genome.", category: "required"}
referenceImg: {description: "The BWA index image (generated with GATK BwaMemIndexImageCreator) of the reference.", category: "required"}
virusbreakendDB: {description: "A .tar.gz containing the virusbreakend database.", category: "required"}
outputPath: {description: "The path the output should be written to.", category: "common"}
memory: {description: "The amount of memory this job will use.", category: "advanced"}
threads: {description: "The number of the threads to use.", category: "advanced"}
timeMinutes: {description: "The maximum amount of time the job will run in minutes.", 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"}
}
}