Skip to content

Commit 5e37f5f

Browse files
dpark01claude
andcommitted
Convert WDL command blocks from brace to heredoc syntax
Update all WDL task files to use modern `command <<<` heredoc syntax instead of the older `command {` brace style. This ensures consistent behavior with shell special characters (quotes, braces) across all WDL interpreters. Also updates legacy `${var}` variable interpolation to `~{var}` syntax in affected tasks. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 6834109 commit 5e37f5f

10 files changed

Lines changed: 203 additions & 203 deletions

pipes/WDL/tasks/tasks_assembly.wdl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ task assemble {
6060

6161
Int disk_size = 375
6262

63-
command {
63+
command <<<
6464
set -ex -o pipefail
6565
6666
# find 90% memory
@@ -87,7 +87,7 @@ task assemble {
8787
cat /proc/loadavg | cut -f 3 -d ' ' > LOAD_15M
8888
set +o pipefail
8989
{ if [ -f /sys/fs/cgroup/memory.peak ]; then cat /sys/fs/cgroup/memory.peak; elif [ -f /sys/fs/cgroup/memory/memory.peak ]; then cat /sys/fs/cgroup/memory/memory.peak; elif [ -f /sys/fs/cgroup/memory/memory.max_usage_in_bytes ]; then cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes; else echo "0"; fi; } > MEM_BYTES
90-
}
90+
>>>
9191

9292
output {
9393
File contigs_fasta = "~{sample_name}.assembly1-spades.fasta"
@@ -574,7 +574,7 @@ task ivar_trim {
574574
}
575575
}
576576

577-
command {
577+
command <<<
578578
ivar version | head -1 | tee VERSION
579579
if [ -f "~{trim_coords_bed}" ]; then
580580
ivar trim -e \
@@ -593,7 +593,7 @@ task ivar_trim {
593593
PCT=$(grep "Trimmed primers from" IVAR_OUT | perl -lape 's/Trimmed primers from (\S+)%.*/$1/')
594594
if [[ $PCT = -* ]]; then echo 0; else echo $PCT; fi > IVAR_TRIM_PCT
595595
grep "Trimmed primers from" IVAR_OUT | perl -lape 's/Trimmed primers from \S+% \((\d+)\).*/$1/' > IVAR_TRIM_COUNT
596-
}
596+
>>>
597597

598598
output {
599599
File aligned_trimmed_bam = "~{bam_basename}.trimmed.bam"
@@ -992,7 +992,7 @@ task run_discordance {
992992

993993
Int disk_size = 100
994994

995-
command {
995+
command <<<
996996
set -ex -o pipefail
997997
998998
read_utils.py --version | tee VERSION
@@ -1058,7 +1058,7 @@ task run_discordance {
10581058
echo 0 > num_discordant_snps
10591059
echo 0 > num_discordant_indels
10601060
fi
1061-
}
1061+
>>>
10621062

10631063
output {
10641064
File discordant_sites_vcf = "~{out_basename}.discordant.vcf"

pipes/WDL/tasks/tasks_demux.wdl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ task merge_tarballs {
1111

1212
Int disk_size = 2625
1313

14-
command {
14+
command <<<
1515
set -ex -o pipefail
1616
1717
if [ -z "$TMPDIR" ]; then
@@ -23,7 +23,7 @@ task merge_tarballs {
2323
file_utils.py merge_tarballs \
2424
~{out_filename} ~{sep=' ' tar_chunks} \
2525
--loglevel=DEBUG
26-
}
26+
>>>
2727

2828
output {
2929
File combined_tar = "~{out_filename}"

pipes/WDL/tasks/tasks_intrahost.wdl

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -202,24 +202,24 @@ task isnvs_per_sample {
202202
}
203203

204204

205-
command {
205+
command <<<
206206
intrahost.py --version | tee VERSION
207207
intrahost.py vphaser_one_sample \
208-
${mapped_bam} \
209-
${assembly_fasta} \
210-
vphaser2.${sample_name}.txt.gz \
211-
${'--vphaserNumThreads=' + threads} \
212-
${true="--removeDoublyMappedReads" false="" removeDoublyMappedReads} \
213-
${'--minReadsEach=' + minReadsPerStrand} \
214-
${'--maxBias=' + maxBias}
215-
}
208+
~{mapped_bam} \
209+
~{assembly_fasta} \
210+
vphaser2.~{sample_name}.txt.gz \
211+
~{'--vphaserNumThreads=' + threads} \
212+
~{true="--removeDoublyMappedReads" false="" removeDoublyMappedReads} \
213+
~{'--minReadsEach=' + minReadsPerStrand} \
214+
~{'--maxBias=' + maxBias}
215+
>>>
216216

217217
output {
218-
File isnvsFile = "vphaser2.${sample_name}.txt.gz"
218+
File isnvsFile = "vphaser2.~{sample_name}.txt.gz"
219219
String viralngs_version = read_string("VERSION")
220220
}
221221
runtime {
222-
docker: "${docker}"
222+
docker: docker
223223
memory: select_first([machine_mem_gb, 7]) + " GB"
224224
dx_instance_type: "mem1_ssd1_v2_x8"
225225
maxRetries: 2
@@ -250,43 +250,43 @@ task isnvs_vcf {
250250
emailAddress: { description: "email address passed to NCBI if we need to download reference sequences" }
251251
}
252252

253-
command {
253+
command <<<
254254
set -ex -o pipefail
255255
256256
intrahost.py --version | tee VERSION
257257
258-
SAMPLES="${sep=' ' sampleNames}"
258+
SAMPLES="~{sep=' ' sampleNames}"
259259
if [ -n "$SAMPLES" ]; then SAMPLES="--samples $SAMPLES"; fi
260260
261-
providedSnpRefAccessions="${sep=' ' snpEffRef}"
262-
if [ -n "$providedSnpRefAccessions" ]; then
261+
providedSnpRefAccessions="~{sep=' ' snpEffRef}"
262+
if [ -n "$providedSnpRefAccessions" ]; then
263263
snpRefAccessions="$providedSnpRefAccessions";
264264
else
265-
snpRefAccessions="$(python -c "from Bio import SeqIO; print(' '.join(list(s.id for s in SeqIO.parse('${reference_fasta}', 'fasta'))))")"
265+
snpRefAccessions="$(python -c "from Bio import SeqIO; print(' '.join(list(s.id for s in SeqIO.parse('~{reference_fasta}', 'fasta'))))")"
266266
fi
267267
268268
echo "snpRefAccessions: $snpRefAccessions"
269269
270270
intrahost.py merge_to_vcf \
271-
${reference_fasta} \
271+
~{reference_fasta} \
272272
isnvs.vcf.gz \
273273
$SAMPLES \
274-
--isnvs ${sep=' ' vphaser2Calls} \
275-
--alignments ${sep=' ' perSegmentMultiAlignments} \
274+
--isnvs ~{sep=' ' vphaser2Calls} \
275+
--alignments ~{sep=' ' perSegmentMultiAlignments} \
276276
--strip_chr_version \
277-
${true="--naive_filter" false="" naiveFilter} \
277+
~{true="--naive_filter" false="" naiveFilter} \
278278
--parse_accession
279-
279+
280280
interhost.py snpEff \
281281
isnvs.vcf.gz \
282282
$snpRefAccessions \
283283
isnvs.annot.vcf.gz \
284-
${'--emailAddress=' + emailAddress}
284+
~{'--emailAddress=' + emailAddress}
285285
286286
intrahost.py iSNV_table \
287287
isnvs.annot.vcf.gz \
288288
isnvs.annot.txt.gz
289-
}
289+
>>>
290290

291291
output {
292292
File isnvs_vcf = "isnvs.vcf.gz"
@@ -297,7 +297,7 @@ task isnvs_vcf {
297297
String viralngs_version = read_string("VERSION")
298298
}
299299
runtime {
300-
docker: "${docker}"
300+
docker: docker
301301
memory: select_first([machine_mem_gb, 4]) + " GB"
302302
dx_instance_type: "mem1_ssd1_v2_x4"
303303
maxRetries: 2
@@ -328,27 +328,27 @@ task annotate_vcf_snpeff {
328328
emailAddress: { description: "email address passed to NCBI if we need to download reference sequences" }
329329
}
330330

331-
command {
331+
command <<<
332332
set -ex -o pipefail
333333
334334
intrahost.py --version | tee VERSION
335335
336-
providedSnpRefAccessions="${sep=' ' snpEffRef}"
337-
if [ -n "$providedSnpRefAccessions" ]; then
336+
providedSnpRefAccessions="~{sep=' ' snpEffRef}"
337+
if [ -n "$providedSnpRefAccessions" ]; then
338338
snpRefAccessions="$providedSnpRefAccessions";
339339
else
340-
snpRefAccessions="$(python -c "from Bio import SeqIO; print(' '.join(list(s.id for s in SeqIO.parse('${ref_fasta}', 'fasta'))))")"
340+
snpRefAccessions="$(python -c "from Bio import SeqIO; print(' '.join(list(s.id for s in SeqIO.parse('~{ref_fasta}', 'fasta'))))")"
341341
fi
342342
echo "snpRefAccessions: $snpRefAccessions"
343343
344344
vcf_to_use=""
345-
if (file "${in_vcf}" | grep -q "gzip" ) ; then
346-
echo "${in_vcf} is already compressed"
347-
vcf_to_use="${in_vcf}"
345+
if (file "~{in_vcf}" | grep -q "gzip" ) ; then
346+
echo "~{in_vcf} is already compressed"
347+
vcf_to_use="~{in_vcf}"
348348
else
349-
echo "${in_vcf} is not compressed; gzipping..."
350-
bgzip "${in_vcf}"
351-
vcf_to_use="${in_vcf}.gz"
349+
echo "~{in_vcf} is not compressed; gzipping..."
350+
bgzip "~{in_vcf}"
351+
vcf_to_use="~{in_vcf}.gz"
352352
fi
353353
354354
# renames the seq id using the first sequence in the alignment
@@ -360,7 +360,7 @@ task annotate_vcf_snpeff {
360360
bgzip -d "temp.vcf.gz"
361361
# rename chr field (first col) in vcf
362362
cat "temp.vcf" | sed "s/^1/$ref_name_no_version/" > "temp2.vcf"
363-
363+
364364
# output the vcf, removing the reference sequence if present as a sample name
365365
bgzip "temp2.vcf"
366366
tabix -p vcf "temp2.vcf.gz"
@@ -377,13 +377,13 @@ task annotate_vcf_snpeff {
377377
echo "Creating vcf index"
378378
bcftools index "$vcf_to_use"
379379
tabix -p vcf "$vcf_to_use"
380-
380+
381381
interhost.py snpEff \
382382
"$vcf_to_use" \
383383
$snpRefAccessions \
384-
"${output_basename}.annot.vcf.gz" \
385-
${'--emailAddress=' + emailAddress}
386-
}
384+
"~{output_basename}.annot.vcf.gz" \
385+
~{'--emailAddress=' + emailAddress}
386+
>>>
387387

388388
output {
389389
File annot_vcf_gz = "~{output_basename}.annot.vcf.gz"

pipes/WDL/tasks/tasks_ncbi.wdl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ task download_fasta {
99
String docker = "quay.io/broadinstitute/viral-phylo:2.5.16.0"
1010
}
1111

12-
command {
12+
command <<<
1313
ncbi.py --version | tee VERSION
1414
ncbi.py fetch_fastas \
15-
${emailAddress} \
15+
~{emailAddress} \
1616
. \
17-
${sep=' ' accessions} \
18-
--combinedFilePrefix ${out_prefix} \
19-
}
17+
~{sep=' ' accessions} \
18+
--combinedFilePrefix ~{out_prefix} \
19+
>>>
2020

2121
output {
22-
File sequences_fasta = "${out_prefix}.fasta"
22+
File sequences_fasta = "~{out_prefix}.fasta"
2323
String viralngs_version = read_string("VERSION")
2424
}
2525

@@ -467,11 +467,11 @@ task rename_fasta_header {
467467

468468
String docker = "quay.io/broadinstitute/viral-core:2.5.20"
469469
}
470-
command {
470+
command <<<
471471
set -e
472472
file_utils.py rename_fasta_sequences \
473473
"~{genome_fasta}" "~{out_basename}.fasta" "~{new_name}"
474-
}
474+
>>>
475475
output {
476476
File renamed_fasta = "~{out_basename}.fasta"
477477
}
@@ -600,10 +600,10 @@ task lookup_table_by_filename {
600600

601601
String docker = "ubuntu"
602602
}
603-
command {
603+
command <<<
604604
set -e -o pipefail
605605
grep ^"~{id}" ~{mapping_tsv} | cut -f ~{return_col} > OUTVAL
606-
}
606+
>>>
607607
output {
608608
String value = read_string("OUTVAL")
609609
}

pipes/WDL/tasks/tasks_nextstrain.wdl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -649,11 +649,11 @@ task nextstrain_ncov_defaults {
649649
String docker = "docker.io/nextstrain/base:build-20240318T173028Z"
650650
Int disk_size = 50
651651
}
652-
command {
652+
command <<<
653653
set -e
654654
wget -q "https://github.com/nextstrain/ncov/archive/~{nextstrain_ncov_repo_commit}.tar.gz"
655655
tar -xf "~{nextstrain_ncov_repo_commit}.tar.gz" --strip-components=1
656-
}
656+
>>>
657657
runtime {
658658
docker: docker
659659
memory: "1 GB"
@@ -700,7 +700,7 @@ task nextstrain_deduplicate_sequences {
700700

701701
String out_basename = basename(basename(basename(basename(sequences_fasta, '.xz'), '.gz'), '.tar'), '.fasta')
702702
String out_filename = "~{out_basename}_sequences_deduplicated.fasta"
703-
command {
703+
command <<<
704704
set -e
705705
ncov_path_prefix="/nextstrain/ncov"
706706
wget -q "https://github.com/nextstrain/ncov/archive/~{nextstrain_ncov_repo_commit}.tar.gz"
@@ -709,9 +709,9 @@ task nextstrain_deduplicate_sequences {
709709
710710
python3 "$ncov_path_prefix/scripts/sanitize_sequences.py" \
711711
--sequences "~{sequences_fasta}" \
712-
${true="--error-on-duplicate-strains" false="" error_on_seq_diff} \
712+
~{true="--error-on-duplicate-strains" false="" error_on_seq_diff} \
713713
--output "~{out_filename}"
714-
}
714+
>>>
715715
runtime {
716716
docker: docker
717717
memory: "7 GB"
@@ -757,7 +757,7 @@ task nextstrain_ncov_sanitize_gisaid_data {
757757
}
758758

759759
String out_basename = basename(basename(basename(basename(sequences_gisaid_fasta, '.xz'), '.gz'), '.tar'), '.fasta')
760-
command {
760+
command <<<
761761
set -e
762762
ncov_path_prefix="/nextstrain/ncov"
763763
wget -q "https://github.com/nextstrain/ncov/archive/~{nextstrain_ncov_repo_commit}.tar.gz"
@@ -775,7 +775,7 @@ task nextstrain_ncov_sanitize_gisaid_data {
775775
--rename-fields 'Virus name=strain' 'Accession ID=gisaid_epi_isl' 'Collection date=date' 'Clade=GISAID_clade' 'Pango lineage=pango_lineage' 'Host=host' 'Type=virus' 'Patient age=age' \
776776
~{"--strip-prefixes=" + prefix_to_strip} \
777777
--output "~{out_basename}_metadata_sanitized_for_nextstrain.tsv.gz"
778-
}
778+
>>>
779779
runtime {
780780
docker: docker
781781
memory: "7 GB"
@@ -1246,10 +1246,10 @@ task snp_sites {
12461246
Int disk_size = 750
12471247
}
12481248
String out_basename = basename(msa_fasta, ".fasta")
1249-
command {
1249+
command <<<
12501250
snp-sites -V > VERSION
12511251
snp-sites -v ~{true="" false="-c" allow_wildcard_bases} -o "~{out_basename}.vcf" "~{msa_fasta}"
1252-
}
1252+
>>>
12531253
runtime {
12541254
docker: docker
12551255
memory: "31 GB"

pipes/WDL/tasks/tasks_read_utils.wdl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -426,32 +426,32 @@ task downsample_bams {
426426

427427
Int disk_size = 750
428428

429-
command {
429+
command <<<
430430
set -ex -o pipefail
431431
432432
# find 90% memory
433433
mem_in_mb=$(/opt/viral-ngs/source/docker/calc_mem.py mb 90)
434434
435-
if [[ "${deduplicateBefore}" == "true" ]]; then
435+
if [[ "~{deduplicateBefore}" == "true" ]]; then
436436
DEDUP_OPTION="--deduplicateBefore"
437-
elif [[ "${deduplicateAfter}" == "true" ]]; then
437+
elif [[ "~{deduplicateAfter}" == "true" ]]; then
438438
DEDUP_OPTION="--deduplicateAfter"
439439
fi
440440
441-
if [[ "${deduplicateBefore}" == "true" && "${deduplicateAfter}" == "true" ]]; then
441+
if [[ "~{deduplicateBefore}" == "true" && "~{deduplicateAfter}" == "true" ]]; then
442442
echo "deduplicateBefore and deduplicateAfter are mutually exclusive. Only one can be used."
443443
exit 1
444444
fi
445-
445+
446446
read_utils.py --version | tee VERSION
447447
448448
read_utils.py downsample_bams \
449-
${sep=' ' reads_bam} \
449+
~{sep=' ' reads_bam} \
450450
--outPath ./output \
451-
${'--readCount=' + readCount} \
451+
~{'--readCount=' + readCount} \
452452
$DEDUP_OPTION \
453453
--JVMmemory "$mem_in_mb"m
454-
}
454+
>>>
455455

456456
output {
457457
Array[File] downsampled_bam = glob("output/*.downsampled-*.bam")

0 commit comments

Comments
 (0)