Skip to content
Snippets Groups Projects
gatk.wdl 8.77 KiB
Newer Older
Ruben Vorderman's avatar
Ruben Vorderman committed
version 1.0
ffinfo's avatar
ffinfo committed
import "common.wdl"

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
ffinfo's avatar
ffinfo committed
        IndexedBamFile inputBam
Ruben Vorderman's avatar
Ruben Vorderman committed
        String outputBamPath
        File recalibrationReport
        Array[File]+ sequenceGroupInterval
ffinfo's avatar
ffinfo committed
        Reference reference
Ruben Vorderman's avatar
Ruben Vorderman committed

        Int memory = 4
        Float memoryMultiplier = 3.0
Ruben Vorderman's avatar
Ruben Vorderman committed
    }
Cats's avatar
Cats committed

    String toolCommand = if defined(gatkJar)
        then "java -Xmx" + memory + "G -jar " + gatkJar
        else "gatk --java-options -Xmx" + memory + "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} \
         ApplyBQSR \
         --create-output-bam-md5 \
         --add-output-sam-program-record \
ffinfo's avatar
ffinfo committed
         -R ~{reference.fasta} \
         -I ~{inputBam.file} \
         --use-original-qualities \
         -O ~{outputBamPath} \
         -bqsr ~{recalibrationReport} \
         --static-quantized-quals 10 \
         --static-quantized-quals 20 \
         --static-quantized-quals 30 \
         -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 {
ffinfo's avatar
ffinfo committed
        IndexedBamFile recalibratedBam = {
ffinfo's avatar
ffinfo committed
            "file": outputBamPath,
ffinfo's avatar
ffinfo committed
            "index": sub(outputBamPath, "\.bam$", ".bai"),
            "md5": outputBamPath + ".md5"
ffinfo's avatar
ffinfo committed
        }
Peter van 't Hof's avatar
Peter van 't Hof committed
    }
Cats's avatar
Cats committed

    runtime {
        memory: ceil(memory * memoryMultiplier)
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
ffinfo's avatar
ffinfo committed
        IndexedBamFile inputBam
Ruben Vorderman's avatar
Ruben Vorderman committed
        String recalibrationReportPath
        Array[File]+ sequenceGroupInterval
ffinfo's avatar
ffinfo committed
        Array[File]? knownIndelsSitesVCFs
        Array[File]? knownIndelsSitesVCFIndexes
ffinfo's avatar
ffinfo committed
        IndexedVcfFile? dbsnpVCF
        Reference reference
        Int memory = 4
        Float memoryMultiplier = 3.0
Ruben Vorderman's avatar
Ruben Vorderman committed
    }
Peter van 't Hof's avatar
Peter van 't Hof committed

Cats's avatar
Cats committed
    Array[File]+ knownIndelsSitesVCFsArg = flatten([
ffinfo's avatar
ffinfo committed
        select_first([knownIndelsSitesVCFs, []]),
        [select_first([dbsnpVCF]).file]
Cats's avatar
Cats committed
    ])
    String toolCommand = if defined(gatkJar)
        then "java -Xmx" + memory + "G -jar " + gatkJar
        else "gatk --java-options -Xmx" + memory + "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} \
        BaseRecalibrator \
ffinfo's avatar
ffinfo committed
        -R ~{reference.fasta} \
        -I ~{inputBam.file} \
        --use-original-qualities \
        -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(memory * memoryMultiplier)
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
ffinfo's avatar
ffinfo committed
        Array[File]+ gvcfFiles
        Array[File]+ gvcfFilesIndex
Ruben Vorderman's avatar
Ruben Vorderman committed
        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

ffinfo's avatar
ffinfo committed
        Reference reference
Cats's avatar
Cats committed

        Int memory = 4
        Float memoryMultiplier = 3.0
Ruben Vorderman's avatar
Ruben Vorderman committed
    }
Cats's avatar
Cats committed

    String toolCommand = if defined(gatkJar)
        then "java -Xmx" + memory + "G -jar " + gatkJar
        else "gatk --java-options -Xmx" + memory + "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 \
ffinfo's avatar
ffinfo committed
             -R ~{reference.fasta} \
Ruben Vorderman's avatar
Ruben Vorderman committed
             -O ~{outputPath} \
             -V ~{sep=' -V ' gvcfFiles} \
             -L ~{sep=' -L ' intervals}
Cats's avatar
Cats committed
        else # TODO this should be handeled in wdl
ffinfo's avatar
ffinfo committed
            ln -sf ~{gvcfFiles[0]} ~{outputPath}
            ln -sf ~{gvcfFiles[0]} ~{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 {
ffinfo's avatar
ffinfo committed
        IndexedVcfFile outputVCF = {
            "file": outputPath,
            "index": outputPath + ".tbi"
        }
Peter van 't Hof's avatar
Peter van 't Hof committed
    }
Cats's avatar
Cats committed

    runtime {
        memory: ceil(memory * memoryMultiplier)
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

        Int memory = 4
        Float memoryMultiplier = 3.0
Ruben Vorderman's avatar
Ruben Vorderman committed
    }
Cats's avatar
Cats committed

    String toolCommand = if defined(gatkJar)
        then "java -Xmx" + memory + "G -jar " + gatkJar
        else "gatk --java-options -Xmx" + memory + "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(memory * memoryMultiplier)
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
ffinfo's avatar
ffinfo committed
        Array[File]+ gvcfFiles
Peter van 't Hof's avatar
Peter van 't Hof committed
        Array[File]+ gvcfFilesIndex
Ruben Vorderman's avatar
Ruben Vorderman committed
        Array[File]+ intervals
Ruben Vorderman's avatar
Ruben Vorderman committed
        String outputPath
Ruben Vorderman's avatar
Ruben Vorderman committed
        String? gatkJar
ffinfo's avatar
ffinfo committed
        Reference reference
ffinfo's avatar
ffinfo committed
        IndexedVcfFile? dbsnpVCF
        Int memory = 4
        Float memoryMultiplier =3.0
Ruben Vorderman's avatar
Ruben Vorderman committed
    }
ffinfo's avatar
ffinfo committed
    String dbsnpArg = if defined(dbsnpVCF) then "-D " + select_first([dbsnpVCF]).file else ""

    String toolCommand = if defined(gatkJar)
        then "java -Xmx" + memory + "G -jar " + gatkJar
        else "gatk --java-options -Xmx" + memory + "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} \
ffinfo's avatar
ffinfo committed
        -R ~{reference.fasta} \
        -O ~{outputPath} \
ffinfo's avatar
ffinfo committed
        ~{dbsnpArg} \
        -G StandardAnnotation \
        --only-output-calls-starting-in-intervals \
        -new-qual \
ffinfo's avatar
ffinfo committed
        -V ~{sep=' -V ' gvcfFiles} \
        -L ~{sep=' -L ' intervals}
Peter van 't Hof's avatar
Peter van 't Hof committed
    }

    output {
ffinfo's avatar
ffinfo committed
        IndexedVcfFile outputVCF = {
            "file": outputPath,
            "index": outputPath + ".tbi"
        }
Cats's avatar
Cats committed

    runtime{
        memory: ceil(memory * memoryMultiplier)
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
        String? preCommand
ffinfo's avatar
ffinfo committed
        Array[File]+ inputBams
        Array[File]+ inputBamsIndex
Ruben Vorderman's avatar
Ruben Vorderman committed
        Array[File]+ intervalList
        String gvcfPath
ffinfo's avatar
ffinfo committed
        Reference reference
        Float contamination = 0.0
Ruben Vorderman's avatar
Ruben Vorderman committed
        String? gatkJar

ffinfo's avatar
ffinfo committed
        IndexedVcfFile? dbsnpVCF
Ruben Vorderman's avatar
Ruben Vorderman committed

        Int memory = 4
        Float memoryMultiplier = 3
Ruben Vorderman's avatar
Ruben Vorderman committed
    }
ffinfo's avatar
ffinfo committed
    String dbsnpArg = if (defined(dbsnpVCF)) then "-D " + select_first([dbsnpVCF]).file else ""

    String toolCommand = if defined(gatkJar)
        then "java -Xmx" + memory + "G -jar " + gatkJar
        else "gatk --java-options -Xmx" + memory + "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} \
ffinfo's avatar
ffinfo committed
        -R ~{reference.fasta} \
ffinfo's avatar
ffinfo committed
        -I ~{sep=" -I " inputBams} \
        -L ~{sep=' -L ' intervalList} \
ffinfo's avatar
ffinfo committed
        ~{dbsnpArg} \
        -contamination ~{contamination} \
        -ERC GVCF
Peter van 't Hof's avatar
Peter van 't Hof committed
    }

    output {
ffinfo's avatar
ffinfo committed
        IndexedVcfFile outputGVCF = {
            "file": gvcfPath,
            "index": gvcfPath + ".tbi"
        }
Cats's avatar
Cats committed

    runtime {
        memory: ceil(memory * memoryMultiplier)
Cats's avatar
Cats committed
    }
Cats's avatar
Cats committed

Cats's avatar
Cats committed
task MuTect2 {
    input {
        String? preCommand

ffinfo's avatar
ffinfo committed
        Array[File]+ inputBams
        Array[File]+ inputBamsIndex
ffinfo's avatar
ffinfo committed
        Reference reference
Cats's avatar
Cats committed
        String outputVcf
        String tumorSample
        String? normalSample
        Array[File]+ intervals

        String? gatkJar
        Int memory = 4
        Float memoryMultiplier = 3
    }

    String toolCommand = if defined(gatkJar)
        then "java -Xmx" + memory + "G -jar " + gatkJar
        else "gatk --java-options -Xmx" + memory + "G"

    command {
        set -e -o pipefail
        ~{preCommand}
        ~{toolCommand} \
        Mutect2 \
ffinfo's avatar
ffinfo committed
        -R ~{reference.fasta} \
ffinfo's avatar
ffinfo committed
        -I ~{sep=" -I " inputBams} \
Cats's avatar
Cats committed
        -tumor ~{tumorSample} \
        ~{"-normal " + normalSample} \
        -O ~{outputVcf} \
        -L ~{sep=" -L " intervals}
    }

    output {
ffinfo's avatar
ffinfo committed
        IndexedVcfFile vcfFile = {
            "file": outputVcf,
            "index": outputVcf + ".tbi"
        }
Cats's avatar
Cats committed
    }

    runtime {
        memory: ceil(memory * memoryMultiplier)
    }
}

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

ffinfo's avatar
ffinfo committed
        IndexedBamFile inputBam
        Reference reference
Ruben Vorderman's avatar
Ruben Vorderman committed
        String outputBam
        String? gatkJar
        Array[File]+ intervals

        Int memory = 4
        Float memoryMultiplier = 3
Ruben Vorderman's avatar
Ruben Vorderman committed
    }
pjvan_thof's avatar
pjvan_thof committed
    String toolCommand = if defined(gatkJar)
        then "java -Xmx" + memory + "G -jar " + gatkJar
        else "gatk --java-options -Xmx" + memory + "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 \
ffinfo's avatar
ffinfo committed
        -I ~{inputBam.file} \
        -R ~{reference.fasta} \
Ruben Vorderman's avatar
Ruben Vorderman committed
        -O ~{outputBam} \
        -L ~{sep=' -L ' intervals}
Cats's avatar
Cats committed
    }

    output {
ffinfo's avatar
ffinfo committed
        IndexedBamFile bam = {
            "file": outputBam,
            "index": sub(outputBam, "\.bam$", ".bai")
        }
Cats's avatar
Cats committed
    }
Cats's avatar
Cats committed

    runtime {
        memory: ceil(memory * memoryMultiplier)
Cats's avatar
Cats committed
    }
Cats's avatar
Cats committed
}