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.
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.
If you see the .bai file, indexing is successful.