Samtools error - Fail to load BAM index when using samtools view
1
1
Entering edit mode
9.4 years ago
alvastrand ▴ 10

Hi,

I am trying to split my bam file into individual files containing data for each chromosome, and I know how to do that. The problem is that when I write:

samtools view myfile.bam 1

(for example, to just view the data for chromosome 1)

I get the following error message:

[bam_index_load] fail to load BAM index. 
[main_samview] random alignment retrieval only works for indexed BAM files.

The strange thing is that I already have indexed myfile.bam, so I don't understand why it would fail to load the index if it's there, ready to use.

If anyone could help, that would be great.

Thanks,
Alva

samtools bam • 26k views
ADD COMMENT
0
Entering edit mode

Maybe the index file does not follow the expected naming. What is the name of the index file? It should be myfile.bai

ADD REPLY
0
Entering edit mode

It shouldn't fail if you have a myfile.bam.bai in the same folder. Other than that, if you want to view data from chr1,

samtools view myfile.bam chr1
ADD REPLY
0
Entering edit mode

Someone else had indexed the bam file using another method; when I copied the file and usedsamtools index myfile.bam, it worked. Thanks for the help, both here and below.

ADD REPLY
4
Entering edit mode
9.4 years ago

your BAM file was not indexed.

Run

samtools index your.bam
ADD COMMENT
0
Entering edit mode

Thanks Mr.Pierre, It worked.

ADD REPLY

Login before adding your answer.

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