This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Trouble Sorting A Bam File

Hi,

I'm having trouble sorting a bam file. I give the following command.

samtools sort -m 40G -o file.bam file.sorted

But I get lot of binary code displayed. I understand that it happens sometimes when you have insufficient memory. But I have given a memory of 40G and the bam file is only 250MB.

Can anyone tell what I'm doing wrong? Thanks!

bam samtools sort

Somehow I didn't think of that simple way of doing it! And it worked. Thanks!

1 answer

You are wrongly using the -o parameter. It should be

samtools sort -m 40G file.bam file.sorted

OR

samtools sort -m 40G file.bam -o file.sorted.bam

Actually I tried that too. I stil get the same issue. Binary code is still displayed.

That binary code is sorted bam file. I think -o parameter will redirect the output to stdout. You can -o and then redirect the output using > to the new output file.

Log in to answer this question.