samtools idxstats on indexed BAM failed
1
5
Entering edit mode
8.2 years ago

I have an indexed BAM file foo.bam and its index foo.bam.bai. When I run samtools idxstats to get information about the index, I get the following error:

samtools idxstats foo.bam [bam_idxstats] fail to load the index.  Both foo.bam and its index file are in the same directory. Is there anything I'm missing about this command? Here is the version of samtools I am running: Program: samtools (Tools for alignments in the SAM format) Version: 0.2.0-rc8-60-g2455fd2-dirty (using htslib 0.2.0-rc8-20-g34082df)  index samtools bam • 11k views ADD COMMENT 0 Entering edit mode No, you are not missing anything in the command. Needless to ask but have you tried recreating the "index" file and running idxstats again. ADD REPLY 0 Entering edit mode No, I don't own the directory these files are located in. I can make a copy to test locally but it will take time. Are there issues accessing indexed BAM files with a newer version of samtools, when it is almost certain the index was generated with an older tool? ADD REPLY 0 Entering edit mode Perhaps there is a bug with this version of samtools?  samtools sort foo.bam foo.resorted.bam
[bam_sort_core] merging from 18 files...
\$ samtools index foo.resorted.bam
Samtools-htslib-API: bam_index_build2() not yet implemented
Aborted (core dumped)

1
Entering edit mode

Yeah, you'll want to use the version on sourceforge still.

0
Entering edit mode

Thanks, that's what I'll do.

4
Entering edit mode
7.9 years ago
johnds ▴ 40

Try leave out the last argument that worked for

samtools index -b file.bam


/john

3
Entering edit mode

leaving out last argument worked for me. I used sorted bam file to make an index.

samtools index -b file.sorted.bam

0
Entering edit mode

worked for me too