Skip to content

Commit

Permalink
fix bulk download output to handle zip files and optionally create a …
Browse files Browse the repository at this point in the history
…concatenated output (#347)

* fix bulk download output to handle zip files and optionally create a concatenated output name

* add default name for concatenate task
  • Loading branch information
rzlim08 authored Apr 16, 2024
1 parent 6b57a96 commit 79a4f29
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions workflows/bulk-download/run.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ workflow bulk_download {
input {
String action
Array[BulkDownloads] files
String concatenated_output_name = "concatenated.txt"
String docker_image_id = "czid-bulk-download"
}

Expand All @@ -25,6 +26,7 @@ workflow bulk_download {
call concatenate {
input:
files = rename.file,
concatenated_output_name = concatenated_output_name,
docker_image_id = docker_image_id
}
}
Expand Down Expand Up @@ -63,14 +65,15 @@ task rename {
task concatenate {
input {
String docker_image_id
String concatenated_output_name = "concatenated.txt"
Array[File] files
}
command <<<
set -euxo pipefail
cat ~{sep=" " files} > concatenated.txt
cat ~{sep=" " files} > "~{concatenated_output_name}"
>>>
output {
File file = "concatenated.txt"
File file = "~{concatenated_output_name}"
}
runtime {
docker: docker_image_id
Expand All @@ -85,7 +88,14 @@ task zip {
command <<<
set -euxo pipefail
# Don't store full path of original files in the .zip file
zip --junk-paths result.zip ~{sep=" " files}
if [[ "~{select_first(files)}" == *.zip ]]; then
mkdir zip_folders
for f in ~{sep=" " files}; do unzip "$f" -d zip_folders/$(basename "${f%.zip}"); done
cd zip_folders
zip ../result.zip *
else
zip --junk-paths result.zip ~{sep=" " files}
fi
>>>
output {
File file = "result.zip"
Expand Down

0 comments on commit 79a4f29

Please sign in to comment.