Skip to content
Snippets Groups Projects
common.wdl 3 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
ffinfo's avatar
ffinfo committed
        File md5
Ruben Vorderman's avatar
Ruben Vorderman committed
    }
Cats's avatar
Cats committed
    command {
        set -e -o pipefail
Ruben Vorderman's avatar
Ruben Vorderman committed
        MD5SUM=$(md5sum ~{file} | cut -d ' ' -f 1)
Peter van 't Hof's avatar
Peter van 't Hof committed
        MD5SUM_CORRECT=$(cat ~{md5} | grep ~{basename(file)} | cut -d ' ' -f 1)
ffinfo's avatar
ffinfo committed
        [ $MD5SUM = $MD5SUM_CORRECT ]
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
    }
    # When input and output is both compressed decompression is not needed
ffinfo's avatar
ffinfo committed
    String cmdPrefix = if (unzip && !zip) then "zcat " else "cat "
    String cmdSuffix = if (!unzip && zip) then " | gzip -c " else ""
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 + ")"}
ffinfo's avatar
ffinfo committed
        ~{cmdPrefix} ~{sep=' ' fileList} ~{cmdSuffix} > ~{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
    }
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
}
ffinfo's avatar
ffinfo committed

struct IndexedVcfFile {
    File file
    File index
ffinfo's avatar
ffinfo committed
    File? md5sum
ffinfo's avatar
ffinfo committed
}

struct IndexedBamFile {
    File file
    File index
ffinfo's avatar
ffinfo committed
    File? md5sum
ffinfo's avatar
ffinfo committed
}
ffinfo's avatar
ffinfo committed

struct FastqPair {
    File R1
ffinfo's avatar
ffinfo committed
    File? R1_md5
ffinfo's avatar
ffinfo committed
    File? R2
ffinfo's avatar
ffinfo committed
    File? R2_md5
ffinfo's avatar
ffinfo committed
}

struct CaseControl {
    String inputName
    IndexedBamFile inputBam
    String controlName
    IndexedBamFile controlBam
}
Peter van 't Hof's avatar
Peter van 't Hof committed

struct CaseControls {
    Array[CaseControl] caseControls
Peter van 't Hof's avatar
Peter van 't Hof committed
}