Skip to content
Snippets Groups Projects
common.wdl 2.36 KiB
Newer Older
Ruben Vorderman's avatar
Ruben Vorderman committed
version 1.0
Cats's avatar
Cats committed

Ruben Vorderman's avatar
Ruben Vorderman committed
task AppendToStringArray {
    input {
        Array[String] array
        String string
    }
Ruben Vorderman's avatar
Ruben Vorderman committed
    command {
Ruben Vorderman's avatar
Ruben Vorderman committed
        echo "~{sep='\n' array}
        ~{string}"
Ruben Vorderman's avatar
Ruben Vorderman committed
    }
Cats's avatar
Cats committed

Ruben Vorderman's avatar
Ruben Vorderman committed
    output {
Cats's avatar
Cats committed
        Array[String] outArray = read_lines(stdout())
Ruben Vorderman's avatar
Ruben Vorderman committed
    }
Cats's avatar
Cats committed

    runtime {
        memory: 1
    }
Ruben Vorderman's avatar
Ruben Vorderman committed
}

Cats's avatar
Cats committed
# This task will fail if the MD5sum doesn't match the file.
task CheckFileMD5 {
Ruben Vorderman's avatar
Ruben Vorderman committed
    input {
        File file
        String MD5sum
    }
Cats's avatar
Cats committed
    command {
        set -e -o pipefail
Ruben Vorderman's avatar
Ruben Vorderman committed
        MD5SUM=$(md5sum ~{file} | cut -d ' ' -f 1)
        [ $MD5SUM = ~{MD5sum} ]
Cats's avatar
Cats committed
    }
}

Cats's avatar
Cats committed
task ConcatenateTextFiles {
Ruben Vorderman's avatar
Ruben Vorderman committed
    input {
        Array[File] fileList
        String combinedFilePath
        Boolean unzip = false
        Boolean zip = false
Ruben Vorderman's avatar
Ruben Vorderman committed
    }
Ruben Vorderman's avatar
Ruben Vorderman committed
    command {
Cats's avatar
Cats committed
        set -e -o pipefail
Ruben Vorderman's avatar
Ruben Vorderman committed
        ~{"mkdir -p $(dirname " + combinedFilePath + ")"}
        ~{true='zcat' false= 'cat' unzip} ~{sep=' ' fileList} \
        ~{true="| gzip -c" false="" zip} > ~{combinedFilePath}
Ruben Vorderman's avatar
Ruben Vorderman committed
    }
Cats's avatar
Cats committed

Ruben Vorderman's avatar
Ruben Vorderman committed
    output {
Cats's avatar
Cats committed
        File combinedFile = combinedFilePath
Ruben Vorderman's avatar
Ruben Vorderman committed
    }
Cats's avatar
Cats committed

    runtime {
        memory: 1
    }
Ruben Vorderman's avatar
Ruben Vorderman committed
}

Cats's avatar
Cats committed
task CreateLink {
    # Making this of type File will create a link to the copy of the file in the execution
    # folder, instead of the actual file.
Ruben Vorderman's avatar
Ruben Vorderman committed
    input {
        String inputFile
        String outputPath
    }
Ruben Vorderman's avatar
Ruben Vorderman committed
    command {
Ruben Vorderman's avatar
Ruben Vorderman committed
        ln -sf ~{inputFile} ~{outputPath}
Ruben Vorderman's avatar
Ruben Vorderman committed
    }
Cats's avatar
Cats committed

Ruben Vorderman's avatar
Ruben Vorderman committed
    output {
Cats's avatar
Cats committed
        File link = outputPath
Ruben Vorderman's avatar
Ruben Vorderman committed
# DEPRECATED. USE BUILT-IN FLATTEN FUNCTION
# task FlattenStringArray {}
# Commented out to let pipelines that depend on this fail.
Ruben Vorderman's avatar
Ruben Vorderman committed

Cats's avatar
Cats committed
task MapMd5 {
Ruben Vorderman's avatar
Ruben Vorderman committed
    input {
        Map[String,String] map
    }
Cats's avatar
Cats committed

Ruben Vorderman's avatar
Ruben Vorderman committed
    command {
Ruben Vorderman's avatar
Ruben Vorderman committed
        cat ~{write_map(map)} | md5sum - | sed -e 's/  -//'
Ruben Vorderman's avatar
Ruben Vorderman committed
    }
Cats's avatar
Cats committed

Ruben Vorderman's avatar
Ruben Vorderman committed
    output {
Cats's avatar
Cats committed
        String md5sum = read_string(stdout())
Ruben Vorderman's avatar
Ruben Vorderman committed
    }
Cats's avatar
Cats committed

    runtime {
        memory: 1
    }
Ruben Vorderman's avatar
Ruben Vorderman committed
}

Cats's avatar
Cats committed

task ObjectMd5 {
Ruben Vorderman's avatar
Ruben Vorderman committed
    input {
        Object the_object
    }
Ruben Vorderman's avatar
Ruben Vorderman committed
    command {
Ruben Vorderman's avatar
Ruben Vorderman committed
        cat ~{write_object(the_object)} |  md5sum - | sed -e 's/  -//'
Ruben Vorderman's avatar
Ruben Vorderman committed
    }
Cats's avatar
Cats committed

Ruben Vorderman's avatar
Ruben Vorderman committed
    output {
Cats's avatar
Cats committed
        String md5sum = read_string(stdout())
Ruben Vorderman's avatar
Ruben Vorderman committed
    }
Cats's avatar
Cats committed

    runtime {
        memory: 1
    }
Cats's avatar
Cats committed
task StringArrayMd5 {
Ruben Vorderman's avatar
Ruben Vorderman committed
    input {
        Array[String] stringArray
    }
    command {
Cats's avatar
Cats committed
        set -eu -o pipefail
Ruben Vorderman's avatar
Ruben Vorderman committed
        echo ~{sep=',' stringArray} | md5sum - | sed -e 's/  -//'
Cats's avatar
Cats committed
        String md5sum = read_string(stdout())
Cats's avatar
Cats committed

    runtime {
        memory: 1
    }
}

struct Reference {
    File fasta
    File fai
    File dict
}