Java Library For Reading Bai Files And Understanding Index With Respect To Bam
2
2
Entering edit mode
12.9 years ago
User 9906 ▴ 50

Hi,

  1. Is there a library in java which allows me to read BAM index files(.bai) ?

  2. I want to understand how the index maps to BAM files' particular location. How do I get to directly reach a particular file location to read instead of parsing from the start of the file. Please suggest a good read for this.

  3. Is it possible to deduce a particular byte to read in the BAM file by reading the index in the BAI ?

Thank You for your help.

bam • 6.5k views
ADD COMMENT
4
Entering edit mode
12.9 years ago
Gww ★ 2.7k

The picard library implements samtools in java. For more specific information about how BAM files are indexed check out the samtools format specification.

ADD COMMENT
3
Entering edit mode
12.9 years ago

Don't reinvent the wheel an use the picard API. see this post for a simple code. You can get an iterator for a given genomic segment using http://picard.sourceforge.net/javadoc/net/sf/samtools/SAMFileReader.html#queryOverlapping%28java.lang.String,%20int,%20int%29

the SAM specs describes the bai indexes as a bin index ( see this post)

ADD COMMENT

Login before adding your answer.

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