Skip to content
Snippets Groups Projects

gz handling in WDL 1.0

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    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.

    Edited
    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'
      }
    }
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment