This is a test version of Biostars. For the public version, visit https://www.biostars.org.
how to correct this Error while building index from .bam file?

Hello all,

I encountered an error while trying to make index for a bam file. How do I correct it? by the way, my bam was generated from sam after mapping with bowtied2. Thanks

samtools index file.bam

[E::hts_idx_push] NO_COOR reads not in a single block at the end 38 -1
samtools index: failed to create index for "file.bam"
bam samtools

validate your bam file.

what is the output of samtools view -c file.bam ?

if there is an error, it doesn't come from index but from your upstream workflow.

Thanks for your response, the problem was I did not sort the bam. I sorted it now and I dont get the error anymore. Thank you

1 answer

Did you sort the bam file? What was the command used to create the bam file?

Oh. I did not sort it. I am sorting it now so I can make index off the sorted file. I think that should work.

Are you using a very old version of samtools? I'd expect a more explicit error message.

Thank you, this was my mistake, Its good now. again thanks

Log in to answer this question.