Skip to content

Commit

Permalink
Leave some spare memory for samtools. See nf-core#81
Browse files Browse the repository at this point in the history
  • Loading branch information
ewels committed Mar 16, 2019
1 parent 3048667 commit 263fa01
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -666,10 +666,11 @@ if( params.aligner == 'bwameth' ){
file "where_are_my_files.txt"

script:
def avail_mem = task.memory ? (task.memory.toBytes() - 6000000000) / task.cpus) : false
def sort_mem = avail_mem && avail_mem > 2000000000 ? "-m $avail_mem" : ''
"""
samtools sort $bam \\
-m ${task.memory.toBytes() / task.cpus} \\
-@ ${task.cpus} \\
-@ ${task.cpus} $sort_mem \\
-o ${bam.baseName}.sorted.bam
samtools index ${bam.baseName}.sorted.bam
samtools flagstat ${bam.baseName}.sorted.bam > ${bam.baseName}_flagstat_report.txt
Expand Down Expand Up @@ -770,10 +771,11 @@ process qualimap {
script:
gcref = params.genome == 'GRCh37' ? '-gd HUMAN' : ''
gcref = params.genome == 'GRCm38' ? '-gd MOUSE' : ''
def avail_mem = task.memory ? (task.memory.toBytes() - 6000000000) / task.cpus) : false
def sort_mem = avail_mem && avail_mem > 2000000000 ? "-m $avail_mem" : ''
"""
samtools sort $bam \\
-m ${task.memory.toBytes() / task.cpus} \\
-@ ${task.cpus} \\
-@ ${task.cpus} $sort_mem \\
-o ${bam.baseName}.sorted.bam
qualimap bamqc $gcref \\
-bam ${bam.baseName}.sorted.bam \\
Expand All @@ -798,10 +800,11 @@ process preseq {
file "${bam.baseName}.ccurve.txt" into preseq_results

script:
def avail_mem = task.memory ? (task.memory.toBytes() - 6000000000) / task.cpus) : false
def sort_mem = avail_mem && avail_mem > 2000000000 ? "-m $avail_mem" : ''
"""
samtools sort $bam \\
-m ${task.memory.toBytes() / task.cpus} \\
-@ ${task.cpus} \\
-@ ${task.cpus} $sort_mem \\
-o ${bam.baseName}.sorted.bam
preseq lc_extrap -v -B ${bam.baseName}.sorted.bam -o ${bam.baseName}.ccurve.txt
"""
Expand Down

0 comments on commit 263fa01

Please sign in to comment.