forked from biowdl/somatic-variantcalling
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsomatic-variantcalling.wdl
270 lines (249 loc) · 11.3 KB
/
somatic-variantcalling.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
version 1.0
import "mutect2.wdl" as mutect2Workflow
import "tasks/gatk.wdl" as gatk
import "tasks/samtools.wdl" as samtools
import "tasks/somaticseq.wdl" as somaticSeqTask
import "strelka.wdl" as strelkaWorkflow
import "structs.wdl" as structs
import "vardict.wdl" as vardictWorkflow
workflow SomaticVariantcalling {
input {
String outputDir = "."
File referenceFasta
File referenceFastaFai
File referenceFastaDict
String tumorSample
File tumorBam
File tumorBamIndex
String? controlSample
File? controlBam
File? controlBamIndex
TrainingSet? trainingSet
File? regions
File? variantsForContamination
File? variantsForContaminationIndex
File? sitesForContamination
File? sitesForContaminationIndex
Boolean runStrelka = true
Boolean runVardict = true
Boolean runMutect2 = true
Boolean runCombineVariants = false
Map[String, String] dockerImages = {
"picard":"quay.io/biocontainers/picard:2.19.0--0",
"biopet-scatterregions":"quay.io/biocontainers/biopet-scatterregions:0.2--0",
"tabix":"quay.io/biocontainers/tabix:0.2.6--ha92aebf_0",
"manta": "quay.io/biocontainers/manta:1.4.0--py27_1",
"strelka": "quay.io/biocontainers/strelka:2.9.7--0",
"gatk4":"quay.io/biocontainers/gatk4:4.1.2.0--1",
"vardict-java": "quay.io/biocontainers/vardict-java:1.5.8--1",
"somaticseq": "lethalfang/somaticseq:3.1.0"
}
IndexedVcfFile? DONOTDEFINETHIS #FIXME
}
String mutect2Dir = outputDir + "/mutect2"
String strelkaDir = outputDir + "/strelka"
String vardictDir = outputDir + "/vardict"
String somaticSeqDir = outputDir + "/somaticSeq"
Boolean runStrelkaCombineVariants = if runCombineVariants then true else false
if (runMutect2) {
call mutect2Workflow.Mutect2 as mutect2 {
input:
tumorSample = tumorSample,
tumorBam = tumorBam,
tumorBamIndex = tumorBamIndex,
controlSample = controlSample,
controlBam = controlBam,
controlBamIndex = controlBamIndex,
referenceFasta = referenceFasta,
referenceFastaFai = referenceFastaFai,
referenceFastaDict = referenceFastaDict,
outputDir = mutect2Dir,
regions = regions,
variantsForContamination = variantsForContamination,
variantsForContaminationIndex = variantsForContaminationIndex,
sitesForContamination = sitesForContamination,
sitesForContaminationIndex = sitesForContaminationIndex,
dockerImages = dockerImages
}
}
if (runStrelka) {
call strelkaWorkflow.Strelka as strelka {
input:
controlBam = controlBam,
controlBamIndex = controlBamIndex,
tumorBam = tumorBam,
tumorBamIndex = tumorBamIndex,
referenceFasta = referenceFasta,
referenceFastaFai = referenceFastaFai,
referenceFastaDict = referenceFastaDict,
outputDir = strelkaDir,
basename = if defined(controlBam)
then "${tumorSample}-${controlSample}"
else tumorSample,
runCombineVariants = runStrelkaCombineVariants,
regions = regions,
dockerImages = dockerImages
}
}
if (runVardict) {
call vardictWorkflow.VarDict as vardict {
input:
tumorSample = tumorSample,
tumorBam = tumorBam,
tumorBamIndex = tumorBamIndex,
controlSample = controlSample,
controlBam = controlBam,
controlBamIndex = controlBamIndex,
referenceFasta = referenceFasta,
referenceFastaFai = referenceFastaFai,
referenceFastaDict = referenceFastaDict,
outputDir = vardictDir,
regions = regions,
dockerImages = dockerImages
}
}
if (runCombineVariants && runStrelkaCombineVariants && runVardict &&
runMutect2 && defined(strelka.combinedVcf) && runStrelka) {
call gatk.CombineVariants as combineVariants {
input:
referenceFasta = referenceFasta,
referenceFastaFai = referenceFastaFai,
referenceFastaDict = referenceFastaDict,
identifiers = ["mutect2", "varDict", "Strelka"],
variantVcfs = select_all([mutect2.outputVcf, vardict.outputVcf, strelka.combinedVcf]),
variantIndexes = select_all([mutect2.outputVcfIndex, vardict.outputVcfIndex, strelka.combinedVcfIndex]),
outputPath = outputDir + "/combined-VCFs/combined_vcfs.vcf.gz"
}
}
if (defined(trainingSet) && defined(controlBam)) {
#FIXME workaround for faulty 'no such field' errors which occur when a Struct is optional
TrainingSet trainSetPaired = select_first([trainingSet])
call somaticSeqTask.ParallelPairedTrain as pairedTraining {
input:
truthSNV = trainSetPaired.truthSNV,
truthIndel = trainSetPaired.truthIndel,
outputDir = somaticSeqDir + "/train",
referenceFasta = referenceFasta,
referenceFastaFai = referenceFastaFai,
inclusionRegion = regions,
tumorBam = trainSetPaired.tumorBam,
tumorBamIndex = trainSetPaired.tumorBamIndex,
normalBam = select_first([trainSetPaired.normalBam]),
normalBamIndex = select_first([trainSetPaired.normalBamIndex]),
mutect2VCF = trainSetPaired.mutect2VCF,
varscanSNV = trainSetPaired.varscanSNV,
varscanIndel = trainSetPaired.varscanIndel,
jsmVCF = trainSetPaired.jsmVCF,
somaticsniperVCF = trainSetPaired.somaticsniperVCF,
vardictVCF = trainSetPaired.vardictVCF,
museVCF = trainSetPaired.museVCF,
lofreqSNV = trainSetPaired.lofreqSNV,
lofreqIndel = trainSetPaired.lofreqIndel,
scalpelVCF = trainSetPaired.scalpelVCF,
strelkaSNV = trainSetPaired.strelkaSNV,
strelkaIndel = trainSetPaired.strelkaIndel,
dockerImage = dockerImages["somaticseq"]
}
}
if (defined(controlBam)) {
call somaticSeqTask.ParallelPaired as pairedSomaticSeq {
input:
classifierSNV = pairedTraining.ensembleSNVClassifier,
classifierIndel = pairedTraining.ensembleIndelsClassifier,
outputDir = somaticSeqDir,
referenceFasta = referenceFasta,
referenceFastaFai = referenceFastaFai,
inclusionRegion = regions,
tumorBam = tumorBam,
tumorBamIndex = tumorBamIndex,
normalBam = select_first([controlBam]),
normalBamIndex = select_first([controlBamIndex]),
mutect2VCF = mutect2.outputVcf,
vardictVCF = vardict.outputVcf,
strelkaSNV = strelka.variantsVcf,
strelkaIndel = strelka.indelsVcf,
dockerImage = dockerImages["somaticseq"]
}
}
if (defined(trainingSet) && !defined(controlBam)) {
#FIXME workaround for faulty 'no such field' errors which occur when a Struct is optional
TrainingSet trainSetSingle = select_first([trainingSet])
call somaticSeqTask.ParallelSingleTrain as singleTraining {
input:
truthSNV = trainSetSingle.truthSNV,
truthIndel = trainSetSingle.truthIndel,
outputDir = somaticSeqDir + "/train",
referenceFasta = referenceFasta,
referenceFastaFai = referenceFastaFai,
inclusionRegion = regions,
bam = trainSetSingle.tumorBam,
bamIndex = trainSetSingle.tumorBamIndex,
mutect2VCF = trainSetSingle.mutect2VCF,
varscanVCF = trainSetSingle.varscanSNV,
vardictVCF = trainSetSingle.vardictVCF,
lofreqVCF = trainSetSingle.lofreqSNV,
scalpelVCF = trainSetSingle.scalpelVCF,
strelkaVCF = trainSetSingle.strelkaSNV,
dockerImage = dockerImages["somaticseq"]
}
}
if (!defined(controlBam)) {
call somaticSeqTask.ParallelSingle as singleSomaticSeq {
input:
classifierSNV = singleTraining.ensembleSNVClassifier,
classifierIndel = singleTraining.ensembleIndelsClassifier,
outputDir = somaticSeqDir,
referenceFasta = referenceFasta,
referenceFastaFai = referenceFastaFai,
inclusionRegion = regions,
bam = tumorBam,
bamIndex = tumorBamIndex,
mutect2VCF = mutect2.outputVcf,
vardictVCF = vardict.outputVcf,
strelkaVCF = strelka.variantsVcf,
dockerImage = dockerImages["somaticseq"]
}
}
call samtools.BgzipAndIndex as snvIndex {
input:
inputFile = select_first([if defined(controlBam)
then pairedSomaticSeq.snvs
else singleSomaticSeq.snvs]),
outputDir = somaticSeqDir,
dockerImage = dockerImages["tabix"]
}
call samtools.BgzipAndIndex as indelIndex {
input:
inputFile = select_first([if defined(controlBam)
then pairedSomaticSeq.indels
else singleSomaticSeq.indels]),
outputDir = somaticSeqDir,
dockerImage = dockerImages["tabix"]
}
output {
File somaticSeqSnvVcf = snvIndex.compressed
File somaticSeqSnvVcfIndex = snvIndex.index
File somaticSeqIndelVcf = indelIndex.compressed
File somaticSeqIndelVcfIndex = indelIndex.index
File? mutect2Vcf = mutect2.outputVcf
File? mutect2VcfIndex = mutect2.outputVcfIndex
File? vardictVcf = vardict.outputVcf
File? vardictVcfIndex = vardict.outputVcfIndex
File? strelkaSnvsVcf = strelka.variantsVcf
File? strelkaSnvsVcfIndex = strelka.variantsVcfIndex
File? strelkaIndelsVcf = strelka.indelsVcf
File? strelkaIndelsVcfIndex = strelka.indelsVcfIndex
File? strelkaCombinedVcf = strelka.combinedVcf
File? strelkaCombinedVcfIndex = strelka.combinedVcfIndex
File? mantaVcf = strelka.mantaVcf
File? mantaVcfIndex = strelka.mantaVcfIndex
File? combinedVcf = combineVariants.combinedVcf
File? combinedVcfIndex = combineVariants.combinedVcfIndex
File? ensembleIndelsClassifier = if defined(controlBam)
then pairedTraining.ensembleIndelsClassifier
else singleTraining.ensembleIndelsClassifier
File? ensembleSNVClassifier = if defined(controlBam)
then pairedTraining.ensembleSNVClassifier
else singleTraining.ensembleSNVClassifier
}
}