Skip to content

Commit

Permalink
Changed how SRUtils.BamToFq operates.
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
jonn-smith committed Dec 10, 2024
1 parent 3b680ce commit 38baee9
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions wdl/tasks/Utility/SRUtils.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
Expand Down

0 comments on commit 38baee9

Please sign in to comment.