diff --git a/bwa.wdl b/bwa.wdl index 3b092e8c9dbd497e06999f2c0d3a3e33e1ffd4d5..4cfd6fbe3863df222f626ecd8161b0ea460507de 100644 --- a/bwa.wdl +++ b/bwa.wdl @@ -29,12 +29,14 @@ task Mem { String? readgroup Int threads = 4 - String memory = "~{5 + ceil(size(bwaIndex.indexFiles, "G"))}G" - String picardXmx = "4G" + Int sortThreads = 1 + Int sortMemoryPerThreadGb = 4 + Int compressionLevel = 1 + # BWA needs slightly more memory than the size of the index files (~10%). Add a margin for safety here. + Int memoryGb = 1 + ceil(size(bwaIndex.indexFiles, "G") * 1.2) + sortMemoryPerThreadGb * sortThreads Int timeMinutes = 1 + ceil(size([read1, read2], "G") * 200 / threads) - # A mulled container is needed to have both picard and bwa in one container. - # This container contains: picard (2.18.7), bwa (0.7.17-r1188) - String dockerImage = "quay.io/biocontainers/mulled-v2-002f51ea92721407ef440b921fb5940f424be842:43ec6124f9f4f875515f9548733b8b4e5fed9aa6-0" + # This container contains: samtools (1.10), bwa (0.7.17-r1188) + String dockerImage = "quay.io/biocontainers/mulled-v2-fe8faa35dbf6dc65a0f7f5d4ea12e31a79f73e40:eabfac3657eda5818bae4090db989e3d41b01542-0" } command { @@ -46,21 +48,21 @@ task Mem { ~{bwaIndex.fastaFile} \ ~{read1} \ ~{read2} \ - | picard -Xmx~{picardXmx} -XX:ParallelGCThreads=1 SortSam \ - INPUT=/dev/stdin \ - OUTPUT=~{outputPath} \ - SORT_ORDER=coordinate \ - CREATE_INDEX=true + | samtools sort \ + ~{"-@ " + sortThreads} \ + -m ~{sortMemoryPerThreadGb}G \ + -l ~{compressionLevel} \ + - \ + -o ~{outputPath} } output { File outputBam = outputPath - File outputBamIndex = sub(outputPath, "\.bam$", ".bai") } runtime { cpu: threads - memory: memory + memory: "~{memoryGb}G" time_minutes: timeMinutes docker: dockerImage } @@ -73,9 +75,9 @@ task Mem { readgroup: {description: "The readgroup to be assigned to the reads. See BWA mem's `-R` option.", category: "common"} threads: {description: "The number of threads to use.", category: "advanced"} - memory: {description: "The amount of memory this job will use.", category: "advanced"} - picardXmx: {description: "The maximum memory available to picard SortSam. Should be lower than `memory` to accommodate JVM overhead and BWA mem's memory usage.", - category: "advanced"} + memoryGb: {description: "The amount of memory this job will use in gigabytes.", category: "advanced"} + sortThreads: {description: "The number of threads to use for sorting.", category: "advanced"} + sortMemoryPerThreadGb: {description: "The amount of memory for each sorting thread in gigabytes.", category: "advanced"} timeMinutes: {description: "The maximum amount of time the job will run in minutes.", category: "advanced"} dockerImage: {description: "The docker image used for this task. Changing this may result in errors which the developers may choose not to address.", category: "advanced"} @@ -93,14 +95,13 @@ task Kit { Int threads = 4 Int sortThreads = 1 - # Compression uses zlib. Higher than level 2 causes enormous slowdowns. - # GATK/Picard default is level 2. Int sortMemoryPerThreadGb = 4 Int compressionLevel = 1 # BWA needs slightly more memory than the size of the index files (~10%). Add a margin for safety here. Int memoryGb = 1 + ceil(size(bwaIndex.indexFiles, "G") * 1.2) + sortMemoryPerThreadGb * sortThreads Int timeMinutes = 1 + ceil(size([read1, read2], "G") * 220 / threads) - String dockerImage = "biowdl/bwakit:0.7.17-dev-experimental" + # Contains bwa 0.7.17 bwakit 0.7.17.dev1 and samtools + String dockerImage = "quay.io/biocontainers/mulled-v2-ad317f19f5881324e963f6a6d464d696a2825ab6:c59b7a73c87a9fe81737d5d628e10a3b5807f453-0" } command { @@ -122,12 +123,10 @@ task Kit { -l ~{compressionLevel} \ - \ -o ~{outputPrefix}.aln.bam - samtools index ~{outputPrefix}.aln.bam ~{outputPrefix}.aln.bai } output { File outputBam = outputPrefix + ".aln.bam" - File outputBamIndex = outputPrefix + ".aln.bai" } runtime { @@ -158,7 +157,6 @@ task Kit { # outputs outputBam: "The produced BAM file." - outputBamIndex: "The index of the produced BAM file." } }