Samtools Index Problem
1
1
Entering edit mode
12.4 years ago
Bioscientist ★ 1.7k

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 • 8.5k views
ADD COMMENT
0
Entering edit mode

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

ADD REPLY
3
Entering edit mode
12.4 years ago
Gww ★ 2.7k

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 COMMENT

Login before adding your answer.

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