This is a test version of Biostars. For the public version, visit https://www.biostars.org.
[bam_sort_core] merging from 32 files and 16 in-memory blocks... samtools sort: failed to write header to "-"

Hi,

When I run script samtools sort -@ 16 -T "path/to/temp" "$bamfile" > "$_sorted.bam, I get this error message:

[bam_sort_core] merging from 112 files and 16 in-memory blocks...
samtools sort: failed to write header to "-"

and the output file is empty. I believe have sufficient memory (249G memory and my files are big around 70G pacbio reads)

Any help is appreciated.

samtools pacbio

1 answer

Please use -o sorted.bam to save the sorted BAM in your command line. This is standard option with all recent versions of samtools.

samtools sort -@ 16 -T "path/to/temp" -o sorted.bam "$bamfile"

Thanks, I used the commands you suggested and it did sorting without an issue, I also resized my drive, so probably a bit of both helped? :). Thanks for your help

Log in to answer this question.