This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Splitted sorted BAM files with samtools

Hello. I'm trying to use the command "sort" of samtools (ex: samtools sort alignment.bam -o alignment.sorted.bam), but for some reason, instead of generating one single sorted file (ex: alignment.sorted.bam) it generates many files (ex: alignment.sorted.bam.0000.bam, alignment.sorted.bam.0001.bam, alignment.sorted.bam.0002.bam, ..., alignment.sorted.bam.0020.bam). The odd thing is that I had used the exact same command before for a few data of the same batch and it generated a single file. Does anyone have any idea what could be happening and how do I solve this? I'm also thinking of merging the files, if I can't solve it. How do I find out the correct order to merge? Thanks in advance.

samtools sort

1 answer

These are intermediate/temporary files that are created once the chunk of sorted reads exceeds the allocated (-m) memory taht is used to store them in RAM. They should be automatically merged into a single file and then cleaned up unless your job got killed for any reason. Any error messages?

Log in to answer this question.