-
Notifications
You must be signed in to change notification settings - Fork 0
/
optitype.wdl
executable file
·285 lines (268 loc) · 6.36 KB
/
optitype.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
version 1.0
workflow optitype {
input {
File fastqR1
File fastqR2
String outputFileNamePrefix
Int numChunks = 1
Int numReads
String libtype
}
parameter_meta {
fastqR1: "Fastq file for read 1"
fastqR2: "Fastq file for read 2"
outputFileNamePrefix: "Prefix for output files"
numChunks: "Number of chunks to split fastq file [1, no splitting]"
numReads: "Number of reads"
libtype: "the type of library, which will determine the hla reference to use. dna|rna"
}
Map[String,File] ref_fasta = {
"dna":"/.mounts/labs/gsi/modulator/sw/Ubuntu20.04/optitype-1.3.1/ref/hla_reference_dna.fasta",
"rna":"/.mounts/labs/gsi/modulator/sw/Ubuntu20.04/optitype-1.3.1/ref/hla_reference_rna.fasta"
}
### if this is greater than 1, then the fastq files will be split to chunks and
if (numChunks > 1) {
call countChunkSize {
input:
fastqR1 = fastqR1,
numChunks = numChunks,
numReads = numReads
}
call slicer as slicerR1{
input:
fastqR = fastqR1,
chunkSize = countChunkSize.chunkSize
}
call slicer as slicerR2 {
input:
fastqR = fastqR2,
chunkSize = countChunkSize.chunkSize
}
}
Array[File] fastq1 = select_first([slicerR1.chunkFastq, [fastqR1]])
Array[File] fastq2 = select_first([slicerR2.chunkFastq, [fastqR2]])
scatter(fq1 in fastq1){
call HLAReads as HLAReadsR1{
input:
fastq = fq1,
hlaref = ref_fasta[libtype]
}
}
scatter(fq2 in fastq2){
call HLAReads as HLAReadsR2{
input:
fastq = fq2,
hlaref = ref_fasta[libtype]
}
}
Array[File] hlafastq1 = HLAReadsR1.hlafastq
Array[File] hlafastq2 = HLAReadsR2.hlafastq
call concatReads as concatR1{
input:
fastq=hlafastq1
}
call concatReads as concatR2{
input:
fastq=hlafastq2
}
call run_optitype{
input:
fastqR1 = concatR1.concatenated_fastq,
fastqR2 = concatR2.concatenated_fastq,
prefix = outputFileNamePrefix,
libtype = libtype
}
output {
File optitypeResults = run_optitype.results
File optitypePlot = run_optitype.plot
}
meta {
author: "Lawrence Heisler"
email: "[email protected]"
description: "OptiType does HLA genotyping producing 4-digit HLA genotyping predictions from NGS data and selects major/minor HLA Class I alleles. The workflow pre-filters input fastq reads by aligning to and HLA fasta reference based on library type (dna|rna) using RazerS3, as suggested in the tool documentation."
dependencies: [
{
name: "optiType/1.3.1",
url: "https://github.com/FRED-2/OptiType"
},
{
name: "razers3/3.5.8",
url: "http://packages.seqan.de/razers3/razers3-3.5.8-Linux-x86_64.tar.xz"
},
{
name: "slicer/0.3.0",
url: "https://github.com/OpenGene/slicer/archive/v0.3.0.tar.gz"
},
{
name: "gsi software modules : optitype/1.3.1 slicer/0.3.0",
url: "https://gitlab.oicr.on.ca/ResearchIT/modulator"
},
{
name: "gsi software module dependencies : singularity/3.9.4 razers/3.5.8 samtools/1.16.1",
url: "https://gitlab.oicr.on.ca/ResearchIT/modulator"
}
]
output_meta: {
optitypeResults: {
description: "Results of optitype",
vidarr_label: "optitypeResults"
},
optitypePlot: {
description: "Plots of optitype",
vidarr_label: "optitypePlot"
}
}
}
}
task countChunkSize{
input {
File fastqR1
Int numChunks
Int numReads
String modules = "python/3.7"
Int jobMemory = 16
Int timeout = 48
}
parameter_meta {
fastqR1: "input fatsq file"
numChunks: " number of chunks"
numReads: "number of reads"
modules: "name and version of modules"
jobMemory: "Memory allocated for this job"
timeout: "Hours before task timeout"
}
command <<<
set -euo pipefail
if [ "~{numReads}" -ne 0 ]; then
totalLines=$(zcat ~{fastqR1} | wc -l)
else totalLines=$((~{numReads}*4))
fi
python3 -c "from math import ceil; print (int(ceil(($totalLines/4.0)/~{numChunks})*4))"
>>>
runtime {
modules: "~{modules}"
memory: "~{jobMemory} GB"
timeout: "~{timeout}"
}
output {
String chunkSize =read_string(stdout())
}
}
task slicer {
input {
File fastqR
String chunkSize
String modules = "slicer/0.3.0"
Int jobMemory = 16
Int timeout = 48
}
parameter_meta {
fastqR: "Fastq file"
chunkSize: "Number of lines per chunk"
modules: "Required environment modules"
jobMemory: "Memory allocated for this job"
timeout: "Hours before task timeout"
}
command <<<
set -euo pipefail
module load slicer/0.3.0
slicer -i ~{fastqR} -l ~{chunkSize} --gzip
>>>
runtime {
modules: "~{modules}"
memory: "~{jobMemory} GB"
timeout: "~{timeout}"
}
output {
Array[File] chunkFastq = glob("*.fastq.gz")
}
meta {
output_meta: {
chunkFastq: "output fastq chunks"
}
}
}
task HLAReads{
input {
File fastq
File hlaref
String modules = "optitype/1.3.1 hla-reference/1.0.0"
Int jobMemory = 16
Int timeout = 48
}
parameter_meta {
fastq: "Fastq file"
hlaref: "hla reference file"
modules: "Required environment modules"
jobMemory: "Memory allocated for this job"
timeout: "Hours before task timeout"
}
command <<<
set -euo pipefail
razers3 -i 95 -m 1 -dr 0 -o HLA.bam ~{hlaref} ~{fastq}
samtools bam2fq HLA.bam > HLA.fastq
>>>
runtime {
modules: "~{modules}"
memory: "~{jobMemory} GB"
timeout: "~{timeout}"
}
output {
File hlafastq = "HLA.fastq"
}
}
task concatReads{
input{
Array[File] fastq
Int jobMemory = 16
Int timeout = 48
}
parameter_meta {
fastq: "Array of input fastq files"
jobMemory: "Memory allocated for this job"
timeout: "Hours before task timeout"
}
command <<<
set -euo pipefail
cat ~{sep=" " fastq} > hlareads.fastq
>>>
runtime {
memory: "~{jobMemory} GB"
timeout: "~{timeout}"
}
output {
File concatenated_fastq = "hlareads.fastq"
}
}
task run_optitype{
input{
File fastqR1
File fastqR2
String prefix
String libtype
String modules = "optitype/1.3.1"
Int jobMemory = 16
Int timeout = 48
}
parameter_meta {
fastqR1: "Fastq file 1ead1"
fastqR2: "Fastq file read2"
prefix: "Prefix for output files"
modules: "Required environment modules"
jobMemory: "Memory allocated for this job"
timeout: "Hours before task timeout"
}
command <<<
module load optitype
optitype -i ~{fastqR1} ~{fastqR2} --~{libtype} -v -o . --prefix ~{prefix}
>>>
runtime {
modules: "~{modules}"
memory: "~{jobMemory} GB"
timeout: "~{timeout}"
}
output {
File results = "~{prefix}_result.tsv"
File plot = "~{prefix}_coverage_plot.pdf"
}
}