Skip to content
Snippets Groups Projects
Commit fef9b644 authored by Thamer Alsulaiman's avatar Thamer Alsulaiman
Browse files

in convert_reads.py: assigned memory to working thread in damtool sort, similar to map_reads.py

parent 8a65eeba
2 merge requests!3Containerized version of chip-seq analysis,!2Added new Docker file for motif search (named meme-5.5.4) installed from...
Pipeline #14468 failed with stages
......@@ -106,9 +106,16 @@ def convert_mapped_pe(bam, bam_basename):
# Name sort bam to make BEDPE
nmsrt_bam_filename = bam_basename + ".nmsrt.bam"
# Allocate memory for each thread used during samtools sort.
# Determine the available memory on the host system (kB).
avail_sys_mem = int(subprocess.check_output("grep MemTotal /proc/meminfo | grep -o '[0-9]*'", shell=True).decode("utf-8").strip())
# Divide the total by the number of processors and apply a scaling factor (0.85) to not use all memory.
mem_per_thread = math.floor((avail_sys_mem // cpu_count()) * 0.85)
# DEBUGGING
mem_per_thread = mem_per_thread * 4
samtools_sort_command = \
"samtools sort -n -@%d -o %s %s" \
% (cpu_count(), nmsrt_bam_filename, bam)
"samtools sort -m %d -n -@%d -o %s %s" \
% (mem_per_thread, cpu_count(), nmsrt_bam_filename, bam)
logger.info(samtools_sort_command)
subprocess.check_output(shlex.split(samtools_sort_command))
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment