Skip to content
Snippets Groups Projects
star.wdl 1.93 KiB
Newer Older
Ruben Vorderman's avatar
Ruben Vorderman committed
version 1.0

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

Ruben Vorderman's avatar
Ruben Vorderman committed
        Array[File] inputR1
        Array[File]? inputR2
        String genomeDir
        String outFileNamePrefix
DavyCats's avatar
DavyCats committed

Ruben Vorderman's avatar
Ruben Vorderman committed
        String? outSAMtype
        String? readFilesCommand
        Int? runThreadN
        String? outStd
        String? twopassMode
        Array[String]? outSAMattrRGline
        Int? limitBAMsortRAM
DavyCats's avatar
DavyCats committed

Ruben Vorderman's avatar
Ruben Vorderman committed
        Int? memory
    }
Cats's avatar
Cats committed

DavyCats's avatar
DavyCats committed
    #TODO needs to be extended for all possible output extensions
    Map[String, String] samOutputNames = {"BAM SortedByCoordinate": "sortedByCoord.out.bam"}
DavyCats's avatar
DavyCats committed

Cats's avatar
Cats committed
    # converts String? to String for use as key (for the Map above) in output
    String key = select_first([outSAMtype, "BAM SortedByCoordinate"])

DavyCats's avatar
DavyCats committed
    command {
        set -e -o pipefail
Ruben Vorderman's avatar
Ruben Vorderman committed
        mkdir -p ~{sub(outFileNamePrefix, basename(outFileNamePrefix) + "$", "")}
        ~{preCommand}
DavyCats's avatar
DavyCats committed
        STAR \
Ruben Vorderman's avatar
Ruben Vorderman committed
        --readFilesIn ~{sep=',' inputR1} ~{sep="," inputR2} \
        --outFileNamePrefix ~{outFileNamePrefix} \
        --genomeDir ~{genomeDir} \
        --outSAMtype ~{default="BAM SortedByCoordinate" outSAMtype} \
        --readFilesCommand ~{default="zcat" readFilesCommand} \
        ~{"--runThreadN " + runThreadN} \
        ~{"--outStd " + outStd} \
        ~{"--twopassMode " + twopassMode} \
        ~{"--limitBAMsortRAM " + limitBAMsortRAM} \
        ~{true="--outSAMattrRGline " false="" defined(outSAMattrRGline)} ~{sep=" , " outSAMattrRGline}
DavyCats's avatar
DavyCats committed
    }

    output {
Cats's avatar
Cats committed
        File bamFile = outFileNamePrefix + "Aligned." +  samOutputNames[key]
DavyCats's avatar
DavyCats committed
    }
DavyCats's avatar
DavyCats committed

    runtime {
Cats's avatar
Cats committed
        cpu: select_first([runThreadN, 1])
Cats's avatar
Cats committed
        memory: select_first([memory, 10])
DavyCats's avatar
DavyCats committed
    }
Cats's avatar
Cats committed
}

task makeStarRGline {
Ruben Vorderman's avatar
Ruben Vorderman committed
    input {
        String sample
        String library
        String? platform
        String readgroup
    }
Cats's avatar
Cats committed
    command {
Ruben Vorderman's avatar
Ruben Vorderman committed
        printf '"ID:~{readgroup}" "LB:~{library}" "PL:~{default="ILLUMINA" platform}" "SM:~{sample}"'
Cats's avatar
Cats committed
    }

    output {
        String rgLine = read_string(stdout())
    }
}