Skip to content

Commit

Permalink
add a task to the bulk download that renames the output file (#341)
Browse files Browse the repository at this point in the history
  • Loading branch information
rzlim08 authored Mar 29, 2024
1 parent 386bf7b commit 5bfe461
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 15 deletions.
18 changes: 7 additions & 11 deletions workflows/bulk-download/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@ workflow_name: bulk-download
specification_language: WDL
description: Generate bulk downloads for the CZID web application
entity_inputs:
files:
name: Files
description: Files to zip or concatenate together
entity_type: file
multivalue: True
samples:
name: Samples
description: Optionally associate this bulk download with some samples
entity_type: sample
consensus_genomes:
name: Consensus Genomes
description: Consensus genomes to bulk download
entity_type: consensus_genome
multivalue: True
required: False
raw_inputs:
Expand All @@ -29,10 +24,11 @@ raw_inputs:
- consensus_genome
- consensus_genome_intermediate_output_files
input_loaders:
- name: files
- name: bulk_download
version: ">=0.0.1"
inputs:
files: ~
consensus_genomes: ~
bulk_download_type: ~
outputs:
files: ~
- name: passthrough
Expand Down
39 changes: 35 additions & 4 deletions workflows/bulk-download/run.wdl
Original file line number Diff line number Diff line change
@@ -1,24 +1,38 @@
version 1.1

struct BulkDownloads {
File file_path
String output_name
}

workflow bulk_download {
input {
String action
Array[File] files
Array[BulkDownloads] files
String docker_image_id = "czid-bulk-download"
}

scatter (file in files) {
call rename {
input:
input_file = file.file_path,
output_name = file.output_name,
docker_image_id = docker_image_id
}
}

if (action == "concatenate") {
call concatenate {
input:
files = files,
files = rename.file,
docker_image_id = docker_image_id
}
}

if (action == "zip") {
call zip {
input:
files = files,
files = rename.file,
docker_image_id = docker_image_id
}
}
Expand All @@ -28,6 +42,24 @@ workflow bulk_download {
}
}

task rename {
input {
String docker_image_id
File input_file
String output_name
}
command <<<
set -euxo pipefail
cp "~{input_file}" "~{output_name}"
>>>
output {
File file = "~{output_name}"
}
runtime {
docker: docker_image_id
}
}

task concatenate {
input {
String docker_image_id
Expand All @@ -52,7 +84,6 @@ 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}
>>>
Expand Down

0 comments on commit 5bfe461

Please sign in to comment.