Skip to content
Snippets Groups Projects
bwa.wdl 1.88 KiB
Newer Older
Ruben Vorderman's avatar
Ruben Vorderman committed
version 1.0
pjvan_thof's avatar
pjvan_thof committed

Ruben Vorderman's avatar
Ruben Vorderman committed
    input {
        String? preCommand
        File inputR1
        File? inputR2
ffinfo's avatar
ffinfo committed
        BwaIndex bwaIndex
Ruben Vorderman's avatar
Ruben Vorderman committed
        String outputPath
        String? readgroup
Cats's avatar
Cats committed

Cats's avatar
Cats committed
        Int threads = 1
        Int memory = 8
Ruben Vorderman's avatar
Ruben Vorderman committed
    }
Ruben Vorderman's avatar
Ruben Vorderman committed

pjvan_thof's avatar
pjvan_thof committed
    command {
        set -e -o pipefail
Ruben Vorderman's avatar
Ruben Vorderman committed
        mkdir -p $(dirname ~{outputPath})
        ~{preCommand}
        bwa mem ~{"-t " + threads} \
        ~{"-R '" + readgroup + "'"} \
ffinfo's avatar
ffinfo committed
        ~{bwaIndex.fastaFile} \
        ~{inputR1} \
        ~{inputR2} \
        | samtools sort --output-fmt BAM - > ~{outputPath}
pjvan_thof's avatar
pjvan_thof committed
    }

    output {
        File bamFile = outputPath
    }
Cats's avatar
Cats committed
    runtime{
Cats's avatar
Cats committed
        cpu: threads
        memory: memory
Cats's avatar
Cats committed
    }
pjvan_thof's avatar
pjvan_thof committed
}
Ruben Vorderman's avatar
Ruben Vorderman committed
    input {
        File fasta
        String? preCommand
        String? constructionAlgorithm
        Int? blockSize
        String? outputDir
    }

    String fastaFilename = basename(fasta)
    String outputFile = if (defined(outputDir)) then outputDir + "/" + fastaFilename else fasta

    command {
        set -e -o pipefail
Ruben Vorderman's avatar
Ruben Vorderman committed
        ~{"mkdir -p " + outputDir}
        ~{preCommand}
        if [[ ! '~{outputDir}' =  '' ]]
Ruben Vorderman's avatar
Ruben Vorderman committed
            ln -sf ~{fasta} ~{outputDir + "/"}~{fastaFilename}
        bwa index \
Ruben Vorderman's avatar
Ruben Vorderman committed
        ~{"-a " + constructionAlgorithm} \
        ~{"-b" + blockSize} \
        ~{outputFile}
        File indexedFasta = outputFile
        Array[File] indexFiles = [outputFile + ".bwt",outputFile + ".pac",outputFile + ".sa",outputFile + ".amb",outputFile + ".ann"]
    parameter_meta {
        fasta: "Fasta file to be indexed"
        constructionAlgorithm: "-a STR    BWT construction algorithm: bwtsw, is or rb2 [auto]"
        blockSize: "-b INT    block size for the bwtsw algorithm (effective with -a bwtsw) [10000000]"
        outputDir: "index will be created in this output directory"
    }
}

ffinfo's avatar
ffinfo committed
struct BwaIndex {
    File fastaFile
    Array[File] indexFiles
}