gz handling in WDL 1.0
The snippet can be accessed without any authentication.
Authored by
Will Holtz
If you have a WDL task that takes an input that can be in an uncompressed or gziped state, but you need the uncompressed form internally, then this code will generate the uncompressed form.
uncompress.WDL 558 B
task example {
input {
File fasta_or_fasta_gz
}
String uncompressed_fasta = basename(fasta_or_fasta_gz, ".gz")
command <<<
set -exuo pipefail
uncompress() { # uncompress source dest
if [ "$(basename "${1}")" = "$2" ]; then
cp "${1}" "${2}"
else
gunzip --stdout "${1}" > "${2}"
fi
}
uncompress '~{fasta_or_fasta_gz}' '~{uncompressed_fasta}'
samtools faidx '~{uncompressed_fasta}'
>>>
output {
File fasta = uncompressed_fasta
File fasta_index = uncompressed_fasta + '.fai'
}
}
Please register or sign in to comment