forked from ENCODE-DCC/hic-pipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
genophase.wdl
246 lines (218 loc) · 6.8 KB
/
genophase.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
version 1.0
import "./hic.wdl"
workflow genophase {
meta {
version: "1.11.0"
caper_docker: "encodedcc/hic-pipeline:1.11.0"
caper_singularity: "docker://encodedcc/hic-pipeline:1.11.0"
croo_out_def: "https://raw.githubusercontent.com/ENCODE-DCC/hic-pipeline/dev/croo_out_def.json"
}
input {
File reference_fasta
Array[File] bams
# From GATK bundle
# https://gatk.broadinstitute.org/hc/en-us/articles/360035890811-Resource-bundle
# https://console.cloud.google.com/storage/browser/genomics-public-data/resources/broad/hg38/v0/
File dbsnp_vcf
File dbsnp_vcf_index
File hapmap_vcf_index
File hapmap_vcf
File mills_vcf
File mills_vcf_index
File omni_vcf
File omni_vcf_index
Int? gatk_num_cpus
Int? gatk_disk_size_gb
Int? gatk_ram_gb
Int? run_3d_dna_num_cpus
Int? run_3d_dna_disk_size_gb
Int? run_3d_dna_ram_gb
Boolean no_phasing = false
# Only for testing purposes
Boolean no_bundle = false
}
call hic.merge as merged { input:
bams = bams,
}
call create_fasta_index as create_reference_fasta_index { input:
fasta = reference_fasta,
}
call create_gatk_references { input:
reference_fasta = reference_fasta,
reference_fasta_index = create_reference_fasta_index.fasta_index,
output_stem = basename(reference_fasta, ".fasta.gz")
}
call gatk { input:
bam = merged.bam,
reference_fasta = reference_fasta,
reference_fasta_index = create_reference_fasta_index.fasta_index,
sequence_dictionary = create_gatk_references.sequence_dictionary,
interval_list = create_gatk_references.interval_list,
mills_vcf = mills_vcf,
omni_vcf = omni_vcf,
hapmap_vcf = hapmap_vcf,
dbsnp_vcf = dbsnp_vcf,
mills_vcf_index = mills_vcf_index,
omni_vcf_index = omni_vcf_index,
hapmap_vcf_index = hapmap_vcf_index,
dbsnp_vcf_index = dbsnp_vcf_index,
no_bundle = no_bundle,
num_cpus = gatk_num_cpus,
ram_gb = gatk_ram_gb,
disk_size_gb = gatk_disk_size_gb,
}
if (!no_phasing) {
call run_3d_dna { input:
vcf = gatk.snp_vcf,
bam = merged.bam,
num_cpus = run_3d_dna_num_cpus,
ram_gb = run_3d_dna_ram_gb,
disk_size_gb = run_3d_dna_disk_size_gb,
}
}
}
task create_fasta_index {
input {
File fasta
}
command <<<
set -euo pipefail
gzip -dc ~{fasta} > ~{basename(fasta, ".gz")}
samtools faidx ~{basename(fasta, ".gz")}
>>>
output {
File fasta_index = "~{basename(fasta, '.gz')}.fai"
}
}
task create_gatk_references {
input {
File reference_fasta
File reference_fasta_index
String output_stem
}
command <<<
set -euo pipefail
gzip -dc ~{reference_fasta} > ~{basename(reference_fasta, ".gz")}
mv ~{reference_fasta_index} .
gatk \
CreateSequenceDictionary \
--REFERENCE ~{basename(reference_fasta, ".gz")} \
--OUTPUT ~{output_stem}.dict \
--URI ~{basename(reference_fasta, ".gz")}
gatk \
ScatterIntervalsByNs \
--REFERENCE ~{basename(reference_fasta, ".gz")} \
--OUTPUT_TYPE ACGT \
--MAX_TO_MERGE 500 \
--OUTPUT ~{output_stem}.interval_list
>>>
output {
File sequence_dictionary = "~{output_stem}.dict"
File interval_list = "~{output_stem}.interval_list"
}
runtime {
cpu : "1"
memory: "16 GB"
disks: "local-disk 100 HDD"
}
}
task gatk {
input {
File bam
File reference_fasta
File reference_fasta_index
File sequence_dictionary
File interval_list
File mills_vcf
File omni_vcf
File hapmap_vcf
File dbsnp_vcf
File mills_vcf_index
File omni_vcf_index
File hapmap_vcf_index
File dbsnp_vcf_index
# Only for testing purposes
Boolean no_bundle = false
Int num_cpus = 16
Int ram_gb = 128
Int disk_size_gb = 1000
}
String final_snp_vcf_name = "snp.out.vcf"
String final_indel_vcf_name = "indel.out.vcf"
command <<<
mkdir bundle
if [[ ~{if(no_bundle) then "0" else "1"} -eq 1 ]]
then
mv \
~{mills_vcf} \
~{omni_vcf} \
~{hapmap_vcf} \
~{dbsnp_vcf} \
~{mills_vcf_index} \
~{omni_vcf_index} \
~{hapmap_vcf_index} \
~{dbsnp_vcf_index} \
bundle
fi
mkdir reference
mv ~{reference_fasta_index} ~{sequence_dictionary} ~{interval_list} reference
gzip -dc ~{reference_fasta} > reference/~{basename(reference_fasta, ".gz")}
run-gatk-after-juicer2.sh \
-r reference/~{basename(reference_fasta, ".gz")} \
~{if !no_bundle then "--gatk-bundle bundle" else ""} \
--threads ~{num_cpus} \
~{bam}
gzip -n ~{final_snp_vcf_name}
gzip -n ~{final_indel_vcf_name}
>>>
output {
File snp_vcf = "~{final_snp_vcf_name}.gz"
File indel_vcf = "~{final_indel_vcf_name}.gz"
}
runtime {
cpu : "~{num_cpus}"
memory: "~{ram_gb} GB"
disks: "local-disk ~{disk_size_gb} HDD"
}
}
task run_3d_dna {
input {
File vcf
File bam
Int num_cpus = 8
Int disk_size_gb = 2000
Int ram_gb = 100
}
command <<<
set -euo pipefail
export VCF_FILENAME=~{basename(vcf, ".gz")}
gzip -dc ~{vcf} > ${VCF_FILENAME}
bash \
/opt/3d-dna/phase/run-hic-phaser-encode.sh \
--threads ~{num_cpus} \
--to-stage update_vcf \
${VCF_FILENAME} \
~{bam}
gzip -n *.txt *.vcf *.assembly
ls
>>>
output {
File snp_vcf = "snp.out.vcf.gz"
File hic_vcf = "snp.out_HiC.vcf.gz"
# .hic files
File hic_in= "snp.out.in.hic"
File hic = "snp.out.out.hic"
# Scaffold boundary files (Juicebox 2D annotation format)
File scaffold_track = "snp.out.out_asm.scaffold_track.txt.gz"
File superscaffold_track = "snp.out.out_asm.superscaf_track.txt.gz"
File scaffold_track_in = "snp.out.in_asm.scaffold_track.txt.gz"
File superscaffold_track_in = "snp.out.in_asm.superscaf_track.txt.gz"
File assembly_in = "snp.out.in.assembly.gz"
File assembly = "snp.out.out.assembly.gz"
}
runtime {
cpu : "~{num_cpus}"
disks: "local-disk ~{disk_size_gb} HDD"
memory: "~{ram_gb} GB"
}
}