Skip to content
Snippets Groups Projects
star.wdl 1.74 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

        String outSAMtype = "BAM SortedByCoordinate"
        String readFilesCommand = "zcat"
        Int runThreadN = 1
Ruben Vorderman's avatar
Ruben Vorderman committed
        String? outStd
        String? twopassMode
        Array[String]? outSAMattrRGline
        Int? limitBAMsortRAM
DavyCats's avatar
DavyCats committed

Ruben Vorderman's avatar
Ruben Vorderman committed
    }
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

    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 ~{outSAMtype} \
        --readFilesCommand ~{readFilesCommand} \
Ruben Vorderman's avatar
Ruben Vorderman committed
        ~{"--runThreadN " + runThreadN} \
        ~{"--outStd " + outStd} \
        ~{"--twopassMode " + twopassMode} \
        ~{"--limitBAMsortRAM " + limitBAMsortRAM} \
        ~{true="--outSAMattrRGline " false="" defined(outSAMattrRGline)} ~{sep=" , " outSAMattrRGline}
DavyCats's avatar
DavyCats committed
    }

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

    runtime {
        cpu: runThreadN
        memory: memory
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 = "ILLUMINA"
Ruben Vorderman's avatar
Ruben Vorderman committed
        String readgroup
    }
Cats's avatar
Cats committed
    command {
        printf '"ID:~{readgroup}" "LB:~{library}" "PL:~{platform}" "SM:~{sample}"'
Cats's avatar
Cats committed
    }

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