Skip to content
Snippets Groups Projects
fastqc.wdl 3.91 KiB
Newer Older
Ruben Vorderman's avatar
Ruben Vorderman committed
task fastqc {
    File seqFile
    String outdirPath
Ruben Vorderman's avatar
Ruben Vorderman committed
    String? preCommand
Ruben Vorderman's avatar
Ruben Vorderman committed
    Boolean? casava
    Boolean? nano
    Boolean? noFilter
    Boolean? extract = true
    Boolean? nogroup
    Int? minLength
    String? format
    Int? threads = 1
    File? contaminants
    File? adapters
    File? limits
    Int? kmers
    String? dir

    command {
    set -e -o pipefail
Ruben Vorderman's avatar
Ruben Vorderman committed
    ${preCommand}
Ruben Vorderman's avatar
Ruben Vorderman committed
    mkdir -p ${outdirPath}
    fastqc \
Ruben Vorderman's avatar
Ruben Vorderman committed
    ${"--outdir " + outdirPath} \
Ruben Vorderman's avatar
Ruben Vorderman committed
    ${true="--casava" false="" casava} \
    ${true="--nano" false="" nano} \
    ${true="--nofilter" false="" noFilter} \
    ${true="--extract" false="" extract} \
    ${true="--nogroup" false="" nogroup} \
    ${"--min_length " + minLength } \
    ${"--format " + format} \
    ${"--threads " + threads} \
    ${"--contaminants " + contaminants} \
    ${"--adapters " + adapters} \
    ${"--limits " + limits} \
    ${"--kmers " + kmers} \
    ${"--dir " + dir} \
    ${seqFile}
Ruben Vorderman's avatar
Ruben Vorderman committed
    }

    output {
Ruben Vorderman's avatar
Ruben Vorderman committed
        # Chops of the .gz extension if present.
        String name = sub(seqFile, "\\.gz$","")
Ruben Vorderman's avatar
Ruben Vorderman committed
        # This regex chops of the extension and replaces it with _fastqc for the reportdir.
        # Just as fastqc does it.
Ruben Vorderman's avatar
Ruben Vorderman committed
        String reportDir = outdirPath + "/" + sub(basename(name), "\\.[^\\.]*$", "_fastqc")
Ruben Vorderman's avatar
Ruben Vorderman committed
        File rawReport = reportDir + "/fastqc_data.txt"
Ruben Vorderman's avatar
Ruben Vorderman committed
        File htmlReport = reportDir + "/fastqc_report.html"
Ruben Vorderman's avatar
Ruben Vorderman committed
        File summary = reportDir + "/summary.txt"
        File adapterContent = reportDir + "/Images/adapter_content.png"
        File duplicationLevels = reportDir + "/Images/duplication_levels.png"
        File perBaseNContent = reportDir + "/Images/per_base_n_content.png"
        File perBaseQuality = reportDir + "/Images/per_base_quality.png"
        File perBaseSequenceContent = reportDir + "/Images/per_base_sequence_content.png"
        File perSequenceGCContent = reportDir + "/Images/per_sequence_gc_content.png"
        File perSequenceQuality = reportDir + "/Images/per_sequence_quality.png"
Ruben Vorderman's avatar
Ruben Vorderman committed
        #File perTileQuality = reportDir + "/Images/per_tile_quality.png"
Ruben Vorderman's avatar
Ruben Vorderman committed
        File sequenceLengthDistribution = reportDir + "/Images/sequence_length_distribution.png"
    }

    runtime {
Ruben Vorderman's avatar
Ruben Vorderman committed
        cpu: select_first([threads])

task extractAdapters {
    File extractAdaptersFastqcJar
    File inputFile
Ruben Vorderman's avatar
Ruben Vorderman committed
    String outputDir
    String? adapterOutputFilePath = outputDir + "/adapter.list"
    String? contamsOutputFilePath = outputDir + "/contaminations.list"
    Boolean? skipContams
    File? knownContamFile
    File? knownAdapterFile
    Float? adapterCutoff
    Boolean? outputAsFasta
    command {
Ruben Vorderman's avatar
Ruben Vorderman committed
    set -e
    mkdir -p ${outputDir}
    java -jar ${extractAdaptersFastqcJar} \
    --inputFile ${inputFile} \
    ${"--adapterOutputFile " + adapterOutputFilePath } \
    ${"--contamsOutputFile " + contamsOutputFilePath } \
    ${"--knownContamFile " + knownContamFile} \
    ${"--knownAdapterFile " + knownAdapterFile} \
    ${"--adapterCutoff " + adapterCutoff} \
    ${true="--skipContams" false="" skipContams} \
    ${true="--outputAsFasta" false="" outputAsFasta}
    }

    output {
Ruben Vorderman's avatar
Ruben Vorderman committed
        File adapterOutputFile = select_first([adapterOutputFilePath])
        File contamsOutputFile = select_first([contamsOutputFilePath])
        Array[String] adapterList = read_lines(select_first([adapterOutputFilePath]))
        Array[String] contamsList = read_lines(select_first([contamsOutputFilePath]))
Ruben Vorderman's avatar
Ruben Vorderman committed
}

task getConfiguration {
    String? preCommand
    String? fastqcDirFile = "fastqcDir.txt"
    command {
        set -e -o pipefail
        ${preCommand}
        echo $(dirname $(readlink -f $(which fastqc))) > ${fastqcDirFile}
    }
    output {
        String fastqcDir = read_string(fastqcDirFile)
        File adapterList = fastqcDir + "/Configuration/adapter_list.txt"
        File contaminantList = fastqcDir + "/Configuration/contaminant_list.txt"
        File limits = fastqcDir + "/Configuration/limits.txt"
    }