Hello guys. I met some problems when I tried to follow the tutorial of Nanopolish in https://nanopolish.readthedocs.io/en/latest/quickstart_eventalign.html
One of the steps is to use samtools to sort alignments. Here I got a reads.bam file, and try to sort it into reads.sorted.bam file. My environment is Utubun and the version of samtools is 1.9 (the most recent one).
I run the following command
samtools sort -o reads.sorted.bam reads.bam
Error: samtools sort: couldn't allocate memory for bam_mem
Folowing the suggetion from https://github.com/samtools/samtools/issues/831 Then I try to run
samtools sort -m GALAXY_MEMORY_MB / GALAXY_SLOTS -o reads.sorted.bam reads.bam
Output information:
Usage: samtools sort [options...] [in.bam]
Options:
-l INT Set compression level, from 0 (uncompressed) to 9 (best)
-m INT Set maximum memory per thread; suffix K/M/G recognized [768M]
-n Sort by read name
-t TAG Sort by value of TAG. Uses position as secondary index (or read name if -n is set)
-o FILE Write final output to FILE rather than standard output
-T PREFIX Write temporary files to PREFIX.nnnn.bam
--input-fmt-option OPT[=VAL]
Specify a single input file format option in the form
of OPTION or OPTION=VALUE
-O, --output-fmt FORMAT[,OPT[=VAL]]...
Specify output format (SAM, BAM, CRAM)
--output-fmt-option OPT[=VAL]
Specify a single output file format option in the form
of OPTION or OPTION=VALUE
--reference FILE
Reference sequence FASTA FILE [null]
-@, --threads INT
Number of additional threads to use [0]
For me, now it seems no error occur... However, I could not find the reads.sorted.bam in the current directory... so when I run the next step,
samtools index reads.sorted.bam
Expected error occurs: samtools index: failed to open "reads.sorted.bam"; No such file or directory.
I really dont understand what happened. Can anyone help me to find out why I could not create the sorted bam file? Thank you.
Thank you! I changed to 10M and can have an output file now. Yes... I have checked the free memory, only 87M are left... I use VirtualBox for operating Ubuntu...
If an answer was helpful, you should upvote it; if the answer resolved your question, you should mark it as accepted. You can accept more than one if they work.
Noted with thanks, I have accepted the answer from Pierre :)