-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathoxog_varbam_annotate_wf.cwl
438 lines (412 loc) · 14.2 KB
/
oxog_varbam_annotate_wf.cwl
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
#!/usr/bin/env cwl-runner
cwlVersion: v1.0
class: Workflow
doc: |
This workflow will run OxoG, variantbam, and annotate.
Run this as `dockstore --script --debug workflow launch --descriptor cwl --local-entry --entry ./oxog_varbam_annotate_wf.cwl --json oxog_varbam_annotat_wf.input.json `
dct:creator:
foaf:name: "Solomon Shorser"
foaf:mbox: "[email protected]"
requirements:
- class: SchemaDefRequirement
types:
- $import: PreprocessedFilesType.yaml
- $import: TumourType.yaml
- class: ScatterFeatureRequirement
- class: StepInputExpressionRequirement
- class: MultipleInputFeatureRequirement
- class: InlineJavascriptRequirement
expressionLib:
- { $include: oxog_varbam_annotate_util.js }
# Shouldn't have to *explicitly* include these but there's
# probably a bug somewhere that makes it necessary
- { $include: preprocess_util.js }
- { $include: vcf_merge_util.js }
- class: SubworkflowFeatureRequirement
inputs:
inputFileDirectory:
type: Directory
refFile:
type: File
out_dir:
type: string
normalBam:
type: File
snv-padding:
type: string
sv-padding:
type: string
indel-padding:
type: string
refDataDir:
type: Directory
minibamName:
type: string
vcfdir:
type: Directory
# "tumours" is an array of records. Each record contains the tumour ID, BAM
# file name, and an array of VCFs.
tumours:
type:
type: array
items: "TumourType.yaml#TumourType"
outputs:
oxog_filtered_files:
type: File[]
outputSource: flatten_oxog_output/oxogVCFs
secondaryFiles: "*.tbi"
minibams:
type: File[]
outputSource: gather_minibams/minibams
secondaryFiles: "*.bai"
annotated_files:
type: File[]
outputSource: gather_annotated_vcfs/annotated_vcfs
steps:
########################################
# Preprocessing #
########################################
#
# Execute the preprocessor subworkflow.
preprocess_vcfs:
in:
vcfdir: inputFileDirectory
ref: refFile
out_dir: out_dir
filesToPreprocess:
source: [ tumours ]
valueFrom: |
${
// Put all VCFs into an array.
var VCFs = []
for (var i in self)
{
for (var j in self[i].associatedVcfs)
{
VCFs.push(self[i].associatedVcfs[j])
}
}
return VCFs;
//return self[0].associatedVcfs
}
run: preprocess_vcf.cwl
out: [preprocessedFiles]
get_merged_vcfs:
in:
in_record: preprocess_vcfs/preprocessedFiles
run:
class: ExpressionTool
inputs:
in_record: "PreprocessedFilesType.yaml#PreprocessedFileset"
outputs:
merged_vcfs: File[]
expression: |
$( { merged_vcfs: inputs.in_record.mergedVcfs } )
out: [merged_vcfs]
get_cleaned_vcfs:
in:
in_record: preprocess_vcfs/preprocessedFiles
run:
class: ExpressionTool
inputs:
in_record: "PreprocessedFilesType.yaml#PreprocessedFileset"
outputs:
cleaned_vcfs: File[]
expression: |
$( { cleaned_vcfs: inputs.in_record.cleanedVcfs } )
out: [cleaned_vcfs]
get_normalized_vcfs:
in:
in_record: preprocess_vcfs/preprocessedFiles
run:
class: ExpressionTool
inputs:
in_record: "PreprocessedFilesType.yaml#PreprocessedFileset"
outputs:
normalized_vcfs: File[]
expression: |
$( { normalized_vcfs: inputs.in_record.normalizedVcfs } )
out: [normalized_vcfs]
get_extracted_snvs:
in:
in_record: preprocess_vcfs/preprocessedFiles
run:
class: ExpressionTool
inputs:
in_record: "PreprocessedFilesType.yaml#PreprocessedFileset"
outputs:
extracted_snvs: File[]?
expression: |
$( { extracted_snvs: inputs.in_record.extractedSnvs } )
out: [extracted_snvs]
filter_merged_snv:
in:
in_vcfs: get_merged_vcfs/merged_vcfs
run:
class: ExpressionTool
inputs:
in_vcfs: File[]
outputs:
merged_snv_vcf: File
expression: |
$({ merged_snv_vcf: filterFileArray("snv",inputs.in_vcfs) })
out: [merged_snv_vcf]
filter_merged_indel:
in:
in_vcfs: get_merged_vcfs/merged_vcfs
run:
class: ExpressionTool
inputs:
in_vcfs: File[]
outputs:
merged_indel_vcf: File
expression: |
$({ merged_indel_vcf: filterFileArray("indel",inputs.in_vcfs) })
out: [merged_indel_vcf]
filter_merged_sv:
in:
in_vcfs: get_merged_vcfs/merged_vcfs
run:
class: ExpressionTool
inputs:
in_vcfs: File[]
outputs:
merged_sv_vcf: File
expression: |
$({ merged_sv_vcf: filterFileArray("sv",inputs.in_vcfs) })
out: [merged_sv_vcf]
########################################
# Do Variantbam #
########################################
# This needs to be run for each tumour, using VCFs that are merged pipelines per tumour.
run_variant_bam:
in:
in_data:
source: tumours
indel-padding: indel-padding
snv-padding: snv-padding
sv-padding: sv-padding
input-snv: filter_merged_snv/merged_snv_vcf
input-sv: filter_merged_sv/merged_sv_vcf
input-indel: filter_merged_indel/merged_indel_vcf
inputFileDirectory: inputFileDirectory
out: [minibam]
scatter: [in_data]
run: ./minibam_sub_wf.cwl
# Create minibam for normal BAM. It would be nice to figure out how to get this into
# the main run_variant_bam step that currently only does tumour BAMs.
run_variant_bam_normal:
in:
indel-padding: indel-padding
snv-padding: snv-padding
sv-padding: sv-padding
input-snv: filter_merged_snv/merged_snv_vcf
input-sv: filter_merged_sv/merged_sv_vcf
input-indel: filter_merged_indel/merged_indel_vcf
inputFileDirectory: inputFileDirectory
input-bam: normalBam
outfile:
source: normalBam
valueFrom: $("mini-".concat(self.basename))
run: Variantbam-for-dockstore/variantbam.cwl
out: [minibam]
# Gather all minibams into a single output array.
gather_minibams:
in:
tumour_minibams: run_variant_bam/minibam
normal_minibam: run_variant_bam_normal/minibam
run:
class: ExpressionTool
inputs:
tumour_minibams: File[]
normal_minibam: File
outputs:
minibams: File[]
expression: |
$( { minibams: inputs.tumour_minibams.concat(inputs.normal_minibam) } )
out: [minibams]
### Prepare for OxoG!
# First we need to zip and index the VCFs - the OxoG filter requires them to be
# zipped and index.
zip_and_index_files_for_oxog:
in:
vcf:
source: get_cleaned_vcfs/cleaned_vcfs
scatter: [vcf]
out: [zipped_file]
run: zip_and_index_vcf.cwl
# Gather the appropriate VCFS.
# All SNVs, and all SNVs extracted from INDELs.
gather_vcfs_for_oxog:
in:
vcf:
source: [zip_and_index_files_for_oxog/zipped_file]
valueFrom: |
${
var snvs = []
for (var i in self)
{
if (self[i].basename.indexOf("snv") !== -1)
{
snvs.push(self[i])
}
}
return snvs
}
extractedSNVs:
source: get_extracted_snvs/extracted_snvs
run:
class: ExpressionTool
inputs:
vcf: File[]
extractedSNVs: File[]?
outputs:
vcfs: File[]
expression: |
$(
{ vcfs: inputs.vcf.concat(inputs.extractedSNVs) }
)
out: [vcfs]
########################################
# Do OxoG Filtering #
########################################
#
# OxoG only runs on SNV VCFs
run_oxog:
in:
in_data:
source: tumours
inputFileDirectory: inputFileDirectory
refDataDir: refDataDir
vcfsForOxoG: gather_vcfs_for_oxog/vcfs
out: [oxogVCF]
scatter: [in_data]
run: oxog_sub_wf.cwl
flatten_oxog_output:
in:
array_of_arrays: run_oxog/oxogVCF
run:
class: ExpressionTool
inputs:
array_of_arrays:
type: { type: array, items: { type: array, items: File } }
expression: |
$(
{ oxogVCFs: flatten_nested_arrays(inputs.array_of_arrays) }
)
outputs:
oxogVCFs: File[]
out:
[oxogVCFs]
########################################
# Do Annotation. #
########################################
#
# we need OxoG filtered files, and minibams (tumour and normal).
# Then we need to scatter. We can scatter on minibams, and perform all annotations
# for each minibam at a time.
run_annotator_snvs:
in:
tumourMinibams: run_variant_bam/minibam
VCFs: flatten_oxog_output/oxogVCFs
tumour_record:
source: tumours
normalMinibam: run_variant_bam_normal/minibam
variantType:
default: "SNV"
out: [ annotated_vcfs ]
scatter: [tumour_record]
run: annotator_sub_wf.cwl
# Annotation must also be performed on INDELs but since INDELs don't get OxoG-filtered,
# we will use the normalized INDELs.
run_annotator_indels:
in:
tumourMinibams: run_variant_bam/minibam
VCFs: get_normalized_vcfs/normalized_vcfs
tumour_record:
source: tumours
normalMinibam: run_variant_bam_normal/minibam
variantType:
default: "INDEL"
out: [annotated_vcfs]
scatter: [tumour_record]
run: annotator_sub_wf.cwl
gather_annotated_vcfs:
in:
annotated_snvs: run_annotator_snvs/annotated_vcfs
annotated_indels: run_annotator_indels/annotated_vcfs
run:
class: ExpressionTool
inputs:
annotated_snvs:
type: { type: array, items: { type: array, items: File } }
annotated_indels:
type: { type: array, items: { type: array, items: File } }
outputs:
annotated_vcfs: File[]
expression: |
$(
{ annotated_vcfs: flatten_nested_arrays(inputs.annotated_snvs).concat(flatten_nested_arrays(inputs.annotated_indels)) }
)
out:
[annotated_vcfs]
# Now run the QA check.
qa_check:
in:
tumourMinibams: run_variant_bam/minibam
tumour_record:
source: tumours
normal_bam: normalBam
vcfs: flatten_oxog_output/oxogVCFs
normalMinibam: run_variant_bam_normal/minibam
inputFileDirectory: inputFileDirectory
scatter: [tumour_record]
run:
class: Workflow
inputs:
inputFileDirectory:
type: Directory
tumour_record:
type: "TumourType.yaml#TumourType"
vcfs:
type: File[]
normal_bam:
type: File
secondaryFiles: .bai
tumourMinibams:
type: File[]
normalMinibam:
type: File
steps:
run_qa_check:
in:
tumour_record: tumour_record
vcfs: vcfs
normal_bam: normal_bam
normal_minibam: normalMinibam
tumour_minibam:
source: [tumour_record, tumourMinibams]
valueFrom: |
${
for (var i in self[1])
{
var tumourMinibam = self[1][i]
if (tumourMinibam.basename.indexOf( self[0].bamFileName ) !== -1)
{
return tumourMinibam
}
}
}
tumour_bam:
source: [inputFileDirectory, tumour_record]
valueFrom: |
${
return { "class":"File", "location": self[0].location + "/" + self[1].bamFileName }
}
out: [qa_result]
run: qa_check_subwf.cwl
outputs:
qa_result:
type: File
out:
[qa_result]