samtools arror: [E::hts_idx_push] NO_COOR reads not in a single block at the end 0 -1
1
2
Entering edit mode
3.9 years ago

Dear all,

I have aligned a file with the command:

bwa mem -t 10 <refFile> <input_1.fq.gz> <input_2.fq.gz> -o <output>.sam

then I converted the SAM to BAM with:

samtools view -Sb  <output>.sam   > <output>.bam

and I wanted to make the index of it with:

samtools index <output>.bam

but I got the error:

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

To check if the error was due to missing alignment I checked the number of mapped reads with:

samtools -c -F 4 <output>.bam

but I got the error:

[main] unrecognized command '-c'

and when removing the flag -c I got:

samtools -F 4 <output>.bam

[main] unrecognized command '-F'

Why I got the [E::hts_idx_push] error? maybe a missing heading?

And why the flags are not recognized?

Thank you.

software error alignment • 5.2k views
ADD COMMENT
4
Entering edit mode
3.9 years ago
ATpoint 60k

There are two things:

1) Indexing requires coordinate-sorted files.

bwa mem idx file_1.fq.gz file_2.fq.gz | samtools sort -o file_sorted.bam -
samtools index file_sorted.bam

Directly pipe the sam file to the sort, there is no need to keep the uncompressed and unsorted sam files. They only take up space.

2) Your -c -f -F etc... commands must be used like samtools view -f -F -c (...). You did not specify the subcommand they belong to.

ADD COMMENT
0
Entering edit mode

thanks, you are right, now it works!

ADD REPLY
0
Entering edit mode

If the answer helped you, please consider to mark it as accepted to help others in the future.

ADD REPLY
0
Entering edit mode

Well done bro!

ADD REPLY

Login before adding your answer.

Traffic: 2144 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6