From 38baee980a926e75b7d9911ed2b1f0ee3fc36ad0 Mon Sep 17 00:00:00 2001 From: Jonn Smith Date: Tue, 10 Dec 2024 08:26:30 -0500 Subject: [PATCH] Changed how SRUtils.BamToFq operates. - Now BamToFq sorts and converts in 2 separate commands. - Now BamToFq utilizes all available processors. - Set BamToFq number of processors and ram to 8 and 24 respectively. --- wdl/tasks/Utility/SRUtils.wdl | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/wdl/tasks/Utility/SRUtils.wdl b/wdl/tasks/Utility/SRUtils.wdl index 995221742..235d1ec6a 100644 --- a/wdl/tasks/Utility/SRUtils.wdl +++ b/wdl/tasks/Utility/SRUtils.wdl @@ -18,18 +18,33 @@ task BamToFq { String ref_arg = if defined(reference_fasta) then " --reference " else "" - Int disk_size = 1 + 4*ceil(size(bam, "GB")) + Int disk_size = 1 + 20*ceil(size(bam, "GB")) command <<< + + # Make sure we use all our proocesors: + np=$(cat /proc/cpuinfo | grep ^processor | tail -n1 | awk '{print $NF+1}') + if [[ ${np} -gt 2 ]] ; then + np=$((np-1)) + fi + set -euxo pipefail - samtools sort -n ~{ref_arg} ~{reference_fasta} ~{bam} | samtools bam2fq -@2 \ + # Have samtools sort use all but one of our processors: + # NOTE: the `@` options is for ADDITIONAL threads, not the total number of threads. + samtools sort -@$((np-1)) -n ~{ref_arg} ~{reference_fasta} ~{bam} -O bam -o tmp.bam + + # Have samtools bam2fq use all but one of our processors: + # NOTE: the `@` options is for ADDITIONAL threads, not the total number of threads. + samtools bam2fq -@$((np-1)) \ -n \ -s /dev/null \ + -c 2 \ ~{ref_arg} ~{reference_fasta} \ -1 ~{prefix}.end1.fq.gz \ -2 ~{prefix}.end2.fq.gz \ - -0 ~{prefix}.unpaired.fq.gz + -0 ~{prefix}.unpaired.fq.gz \ + tmp.bam >>> output { @@ -40,8 +55,8 @@ task BamToFq { ######################### RuntimeAttr default_attr = object { - cpu_cores: 4, - mem_gb: 32, + cpu_cores: 8, + mem_gb: 24, disk_gb: disk_size, boot_disk_gb: 25, preemptible_tries: 1,