Hi All,

Is it possible to convert a bam index (.bai) to human readable format? I'm asking mostly for learning, I don't plan to do anything special with it.

There is a good description of the bam index in the [sam spec][1] document, session 5.2 but I would like to see a "real" example of an index in plain text.

Thanks

Dario

 [1]: https://samtools.github.io/hts-specs/SAMv1.pdf
You can write such a tool yourself using R (just as an example):

    > x = file('/Users/sdavis2/Downloads/vcfanno_0.0.7_darwin_386/example/ex.bam.bai')
    > open(x,'rb')
    > readChar(x,4) # Magic number
    [1] "BAI\001"
    > readBin(x,integer(),size=1,signed=FALSE) # Number of Ref Sequences
    [1] 86

At this point, you can use loops to loop over each of the blocks, reading in data as described in the spec.
