samtools idxstats on indexed BAM failed
1
5
Entering edit mode
10.5 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 • 13k views
ADD COMMENT
1
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)
ADD REPLY
1
Entering edit mode

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

ADD REPLY
0
Entering edit mode

Thanks, that's what I'll do.

ADD REPLY
5
Entering edit mode
10.2 years ago
johnds ▴ 50

Try leave out the last argument that worked for

samtools index -b file.bam

/john

ADD COMMENT
4
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
ADD REPLY
0
Entering edit mode

worked for me too

ADD REPLY

Login before adding your answer.

Traffic: 1563 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