Question: Samtools Index Problem
gravatar for Bioscientist
8.5 years ago by
Bioscientist1.7k wrote:

I've tried to index the sorted bam files using samtools. And one .bam.bai file is created.

191M 101127_2.0000.bam         
5.6M 101127_2.0000.bam.bai

I'm just wondering if there anyway to visualize the .bam.bai file? Or anyway to test if the indexing is successful or not? I tried to use /samtools view .bam.bai, However I got:

[bam_header_read] EOF marker is absent.
[main_samview] fail to read the header.

I don't know this is because samtools cannot visualize .bam.bai file; or my indexing has failed.

btw, what's the use of this .bam.bai file? THanks

samtools index • 6.8k views
ADD COMMENTlink written 8.5 years ago by Bioscientist1.7k

If you see the .bai file, indexing is successful.

ADD REPLYlink written 8.5 years ago by lh332k
gravatar for Gww
8.5 years ago by
Gww2.7k wrote:

The bam index (bai) is useful if you want to pull out all the reads mapping to a region of interest. For example:

samtools view aln.sorted.bam chr2:20,100,000-21,200,000

Samtools will use the index to quickly pull out the reads that align across the specified regions. If you are interested in learning more about the structure of the index and how it is implemented I suggest you check out the samtools format specification.

I assume that if the bam file was not indexed successfully samtools would either give you an error message or you would get a segmentation fault. Furthermore, as far as I know samtools does not have any facilities to view the bam index directly.

ADD COMMENTlink written 8.5 years ago by Gww2.7k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1953 users visited in the last hour