Skip to content
Snippets Groups Projects
gatk.wdl 8.27 KiB
Newer Older
Ruben Vorderman's avatar
Ruben Vorderman committed
version 1.0
Cats's avatar
Cats committed
# Apply Base Quality Score Recalibration (BQSR) model
task ApplyBQSR {
Ruben Vorderman's avatar
Ruben Vorderman committed
    input {
        String? preCommand
        File? gatkJar
        File inputBam
        File inputBamIndex
        String outputBamPath
        File recalibrationReport
        Array[File]+ sequenceGroupInterval
        File refDict
        File refFasta
        File refFastaIndex
        Int? compressionLevel

        Float? memory
        Float? memoryMultiplier
    }
Cats's avatar
Cats committed

Cats's avatar
Cats committed
    Int mem = ceil(select_first([memory, 4.0]))

    String toolCommand = if defined(gatkJar)
    then "java -Xmx" + mem + "G -jar " + gatkJar
pjvan_thof's avatar
pjvan_thof committed
    else "gatk --java-options -Xmx" + mem + "G"
Peter van 't Hof's avatar
Peter van 't Hof committed
    command {
Peter van 't Hof's avatar
Peter van 't Hof committed
        set -e -o pipefail
Ruben Vorderman's avatar
Ruben Vorderman committed
        ~{preCommand}
        ~{toolCommand} \
Cats's avatar
Cats committed
          ApplyBQSR \
          --create-output-bam-md5 \
          --add-output-sam-program-record \
Ruben Vorderman's avatar
Ruben Vorderman committed
          -R ~{refFasta} \
          -I ~{inputBam} \
Peter van 't Hof's avatar
Peter van 't Hof committed
          --use-original-qualities \
Ruben Vorderman's avatar
Ruben Vorderman committed
          -O ~{outputBamPath} \
          -bqsr ~{recalibrationReport} \
Cats's avatar
Cats committed
          --static-quantized-quals 10 --static-quantized-quals 20 --static-quantized-quals 30 \
Ruben Vorderman's avatar
Ruben Vorderman committed
          -L ~{sep=" -L " sequenceGroupInterval}
Peter van 't Hof's avatar
Peter van 't Hof committed
    }
Cats's avatar
Cats committed

Peter van 't Hof's avatar
Peter van 't Hof committed
    output {
Cats's avatar
Cats committed
        File recalibrated_bam = outputBamPath
        File recalibrated_bam_checksum = outputBamPath + ".md5"
Peter van 't Hof's avatar
Peter van 't Hof committed
    }
Cats's avatar
Cats committed

    runtime {
        memory: ceil(mem * select_first([memoryMultiplier, 3.0]))
Cats's avatar
Cats committed
    }
Peter van 't Hof's avatar
Peter van 't Hof committed
}

Cats's avatar
Cats committed
# Generate Base Quality Score Recalibration (BQSR) model
task BaseRecalibrator {
Ruben Vorderman's avatar
Ruben Vorderman committed
    input {
        String? preCommand
        File? gatkJar
        File inputBam
        File inputBamIndex
        String recalibrationReportPath
        Array[File]+ sequenceGroupInterval
        Array[File]? knownIndelsSitesVCFs
        Array[File]? knownIndelsSitesIndices
        File? dbsnpVCF
        File? dbsnpVCFindex
        File refDict
        File refFasta
        File refFastaIndex
        Float? memory
        Float? memoryMultiplier
    }
Peter van 't Hof's avatar
Peter van 't Hof committed

Cats's avatar
Cats committed
    Array[File]+ knownIndelsSitesVCFsArg = flatten([
        select_first([knownIndelsSitesVCFs, []]),
        select_all([dbsnpVCF])
    ])
    Array[File]+ knownIndelsSitesIndicesArg = flatten([
        select_first([knownIndelsSitesIndices, []]),
        select_all([dbsnpVCFindex])
    ])
Cats's avatar
Cats committed
    Int mem = ceil(select_first([memory, 4.0]))

    String toolCommand = if defined(gatkJar)
    then "java -Xmx" + mem + "G -jar " + gatkJar
pjvan_thof's avatar
pjvan_thof committed
    else "gatk --java-options -Xmx" + mem + "G"
Peter van 't Hof's avatar
Peter van 't Hof committed
    command {
Peter van 't Hof's avatar
Peter van 't Hof committed
        set -e -o pipefail
Ruben Vorderman's avatar
Ruben Vorderman committed
        ~{preCommand}
        ~{toolCommand} \
Cats's avatar
Cats committed
          BaseRecalibrator \
Ruben Vorderman's avatar
Ruben Vorderman committed
          -R ~{refFasta} \
          -I ~{inputBam} \
Peter van 't Hof's avatar
Peter van 't Hof committed
          --use-original-qualities \
Ruben Vorderman's avatar
Ruben Vorderman committed
          -O ~{recalibrationReportPath} \
          --known-sites ~{sep=" --known-sites " knownIndelsSitesVCFsArg} \
          -L ~{sep=" -L " sequenceGroupInterval}
Peter van 't Hof's avatar
Peter van 't Hof committed
    }
Cats's avatar
Cats committed

Peter van 't Hof's avatar
Peter van 't Hof committed
    output {
Cats's avatar
Cats committed
        File recalibrationReport = recalibrationReportPath
Peter van 't Hof's avatar
Peter van 't Hof committed
    }
Cats's avatar
Cats committed

    runtime {
        memory: ceil(mem * select_first([memoryMultiplier, 3.0]))
Cats's avatar
Cats committed
    }
Peter van 't Hof's avatar
Peter van 't Hof committed
}

Cats's avatar
Cats committed
task CombineGVCFs {
Ruben Vorderman's avatar
Ruben Vorderman committed
    input {
        String? preCommand
        Array[File]+ gvcfFiles
        Array[File]+ gvcfFileIndexes
        Array[File]+ intervals
Peter van 't Hof's avatar
Peter van 't Hof committed

Ruben Vorderman's avatar
Ruben Vorderman committed
        String outputPath
Cats's avatar
Cats committed

Ruben Vorderman's avatar
Ruben Vorderman committed
        String? gatkJar
Cats's avatar
Cats committed

Ruben Vorderman's avatar
Ruben Vorderman committed
        File refFasta
        File refFastaIndex
        File refDict
Cats's avatar
Cats committed

Ruben Vorderman's avatar
Ruben Vorderman committed
        Int? compressionLevel
        Float? memory
        Float? memoryMultiplier
    }
Cats's avatar
Cats committed

Cats's avatar
Cats committed
    Int mem = ceil(select_first([memory, 4.0]))

    String toolCommand = if defined(gatkJar)
    then "java -Xmx" + mem + "G -jar " + gatkJar
pjvan_thof's avatar
pjvan_thof committed
    else "gatk --java-options -Xmx" + mem + "G"
Peter van 't Hof's avatar
Peter van 't Hof committed
    command {
Peter van 't Hof's avatar
Peter van 't Hof committed
        set -e -o pipefail
Ruben Vorderman's avatar
Ruben Vorderman committed
        ~{preCommand}
Cats's avatar
Cats committed

Ruben Vorderman's avatar
Ruben Vorderman committed
        if [ ~{length(gvcfFiles)} -gt 1 ]; then
            ~{toolCommand} \
Cats's avatar
Cats committed
             CombineGVCFs \
Ruben Vorderman's avatar
Ruben Vorderman committed
             -R ~{refFasta} \
             -O ~{outputPath} \
             -V ~{sep=' -V ' gvcfFiles} \
             -L ~{sep=' -L ' intervals}
Cats's avatar
Cats committed
        else # TODO this should be handeled in wdl
Ruben Vorderman's avatar
Ruben Vorderman committed
            ln -sf ~{select_first(gvcfFiles)} ~{outputPath}
            ln -sf ~{select_first(gvcfFileIndexes)} ~{outputPath}.tbi
Cats's avatar
Cats committed
        fi
Peter van 't Hof's avatar
Peter van 't Hof committed
    }
Cats's avatar
Cats committed

Peter van 't Hof's avatar
Peter van 't Hof committed
    output {
Cats's avatar
Cats committed
        File outputGVCF = outputPath
        File outputGVCFindex = outputPath + ".tbi"
Peter van 't Hof's avatar
Peter van 't Hof committed
    }
Cats's avatar
Cats committed

    runtime {
        memory: ceil(mem * select_first([memoryMultiplier, 3.0]))
Cats's avatar
Cats committed
    }
Peter van 't Hof's avatar
Peter van 't Hof committed
}
Cats's avatar
Cats committed
# Combine multiple recalibration tables from scattered BaseRecalibrator runs
task GatherBqsrReports {
Ruben Vorderman's avatar
Ruben Vorderman committed
    input {
        String? preCommand
        String? gatkJar
        Array[File] inputBQSRreports
        String outputReportPath

        Float? memory
        Float? memoryMultiplier
    }
Cats's avatar
Cats committed

Cats's avatar
Cats committed
    Int mem = ceil(select_first([memory, 4.0]))

    String toolCommand = if defined(gatkJar)
    then "java -Xmx" + mem + "G -jar " + gatkJar
pjvan_thof's avatar
pjvan_thof committed
    else "gatk --java-options -Xmx" + mem + "G"
Peter van 't Hof's avatar
Peter van 't Hof committed
    command {
        set -e -o pipefail
Ruben Vorderman's avatar
Ruben Vorderman committed
        ~{preCommand}
        ~{toolCommand} \
Cats's avatar
Cats committed
        GatherBQSRReports \
Ruben Vorderman's avatar
Ruben Vorderman committed
        -I ~{sep=' -I ' inputBQSRreports} \
        -O ~{outputReportPath}
Cats's avatar
Cats committed

Peter van 't Hof's avatar
Peter van 't Hof committed
    output {
Cats's avatar
Cats committed
        File outputBQSRreport = outputReportPath
Cats's avatar
Cats committed

    runtime {
        memory: ceil(mem * select_first([memoryMultiplier, 3.0]))
Cats's avatar
Cats committed
    }
Peter van 't Hof's avatar
Peter van 't Hof committed

task GenotypeGVCFs {
Ruben Vorderman's avatar
Ruben Vorderman committed
    input {
        String? preCommand
        File gvcfFiles
        File gvcfFileIndexes
        Array[File]+ intervals
Ruben Vorderman's avatar
Ruben Vorderman committed
        String outputPath
Ruben Vorderman's avatar
Ruben Vorderman committed
        String? gatkJar
Ruben Vorderman's avatar
Ruben Vorderman committed
        File refFasta
        File refFastaIndex
        File refDict
Ruben Vorderman's avatar
Ruben Vorderman committed
        File? dbsnpVCF
        File? dbsnpVCFindex
Ruben Vorderman's avatar
Ruben Vorderman committed
        Int? compressionLevel
        Float? memory
        Float? memoryMultiplier
    }
Cats's avatar
Cats committed
    Int mem = ceil(select_first([memory, 4.0]))

    String toolCommand = if defined(gatkJar)
    then "java -Xmx" + mem + "G -jar " + gatkJar
pjvan_thof's avatar
pjvan_thof committed
    else "gatk --java-options -Xmx" + mem + "G"
Peter van 't Hof's avatar
Peter van 't Hof committed
    command {
        set -e -o pipefail
Ruben Vorderman's avatar
Ruben Vorderman committed
        ~{preCommand}
Ruben Vorderman's avatar
Ruben Vorderman committed
        ~{toolCommand} \
Peter van 't Hof's avatar
Peter van 't Hof committed
         GenotypeGVCFs \
Ruben Vorderman's avatar
Ruben Vorderman committed
         -R ~{refFasta} \
         -O ~{outputPath} \
         ~{"-D " + dbsnpVCF} \
Peter van 't Hof's avatar
Peter van 't Hof committed
         -G StandardAnnotation \
         --only-output-calls-starting-in-intervals \
         -new-qual \
Ruben Vorderman's avatar
Ruben Vorderman committed
         -V ~{gvcfFiles} \
         -L ~{sep=' -L ' intervals}
Peter van 't Hof's avatar
Peter van 't Hof committed
    }

    output {
Cats's avatar
Cats committed
        File outputVCF = outputPath
        File outputVCFindex = outputPath + ".tbi"
Cats's avatar
Cats committed

    runtime{
        memory: ceil(mem * select_first([memoryMultiplier, 3.0]))
Cats's avatar
Cats committed
    }
Cats's avatar
Cats committed
# Call variants on a single sample with HaplotypeCaller to produce a GVCF
task HaplotypeCallerGvcf {
Ruben Vorderman's avatar
Ruben Vorderman committed
     input {
        String? preCommand
        Array[File]+ inputBams
        Array[File]+ inputBamsIndex
        Array[File]+ intervalList
        String gvcfPath
        File refDict
        File refFasta
        File refFastaIndex
        Float? contamination
        Int? compressionLevel
        String? gatkJar

        File? dbsnpVCF
        File? dbsnpVCFindex

        Float? memory
        Float? memoryMultiplier
    }
Cats's avatar
Cats committed
    Int mem = ceil(select_first([memory, 4.0]))

    String toolCommand = if defined(gatkJar)
    then "java -Xmx" + mem + "G -jar " + gatkJar
pjvan_thof's avatar
pjvan_thof committed
    else "gatk --java-options -Xmx" + mem + "G"
Peter van 't Hof's avatar
Peter van 't Hof committed
    command {
        set -e -o pipefail
Ruben Vorderman's avatar
Ruben Vorderman committed
        ~{preCommand}
        ~{toolCommand} \
Cats's avatar
Cats committed
          HaplotypeCaller \
Ruben Vorderman's avatar
Ruben Vorderman committed
          -R ~{refFasta} \
          -O ~{gvcfPath} \
          -I ~{sep=" -I " inputBams} \
          -L ~{sep=' -L ' intervalList} \
          ~{"-D " + dbsnpVCF} \
          -contamination ~{default=0 contamination} \
Cats's avatar
Cats committed
          -ERC GVCF
Peter van 't Hof's avatar
Peter van 't Hof committed
    }

    output {
Cats's avatar
Cats committed
        File outputGVCF = gvcfPath
        File outputGVCFindex = gvcfPath + ".tbi"
Cats's avatar
Cats committed

    runtime {
        memory: ceil(mem * select_first([memoryMultiplier, 3.0]))
Cats's avatar
Cats committed
    }
Cats's avatar
Cats committed

task SplitNCigarReads {
Ruben Vorderman's avatar
Ruben Vorderman committed
    input {
        String? preCommand

        File inputBam
        File inputBamIndex
        File refFasta
        File refFastaIndex
        File refDict
        String outputBam
        String? gatkJar
        Array[File]+ intervals

        Float? memory
        Float? memoryMultiplier
    }
Cats's avatar
Cats committed
    Int mem = ceil(select_first([memory, 4.0]))
pjvan_thof's avatar
pjvan_thof committed

    String toolCommand = if defined(gatkJar)
    then "java -Xmx" + mem + "G -jar " + gatkJar
pjvan_thof's avatar
pjvan_thof committed
    else "gatk --java-options -Xmx" + mem + "G"
Cats's avatar
Cats committed
    command {
        set -e -o pipefail
Ruben Vorderman's avatar
Ruben Vorderman committed
        ~{preCommand}
        ~{toolCommand} \
Cats's avatar
Cats committed
        SplitNCigarReads \
Ruben Vorderman's avatar
Ruben Vorderman committed
        -I ~{inputBam} \
        -R ~{refFasta} \
        -O ~{outputBam} \
        -L ~{sep=' -L ' intervals}
Cats's avatar
Cats committed
    }

    output {
Cats's avatar
Cats committed
        File bam = outputBam
Cats's avatar
Cats committed
        File bamIndex = sub(outputBam, "\\.bam$", ".bai")
Cats's avatar
Cats committed
    }
Cats's avatar
Cats committed

    runtime {
        memory: ceil(mem * select_first([memoryMultiplier, 3.0]))
Cats's avatar
Cats committed
    }
Cats's avatar
Cats committed
}