Go Back   SEQanswers > Bioinformatics > Bioinformatics

Similar Threads
Thread Thread Starter Forum Replies Last Post
Fluidigm Access Array nickloman 454 Pyrosequencing 7 11-20-2015 09:54 AM
NEw to Chip-seq and have .bam/.sam/.bam.bai files... then what? NGS newbie Bioinformatics 11 05-25-2011 07:48 AM
purpose of faidx and bai bioxyz Bioinformatics 6 09-08-2010 08:14 AM
What is the reference sequence? ( can I find it in a .bai index?) keebs42 Bioinformatics 5 07-13-2010 12:22 PM
SAM to .bai conversion wdt Bioinformatics 6 04-15-2010 08:00 AM

Thread Tools
Old 12-19-2011, 11:55 AM   #1
Senior Member
Location: USA

Join Date: Jan 2011
Posts: 104
Default Using the .bai to access the BAM

If you knew a range of reads in a BAM file you wanted data for,
say 1:1000-2000, and had its .BAI file- how could you determine the byte range of the .bam file to get?
oiiio is offline   Reply With Quote
Old 12-20-2011, 02:23 AM   #2
Peter (Biopython etc)
Location: Dundee, Scotland, UK

Join Date: Jul 2009
Posts: 1,541

Normally this is handled by a library (the samtools C API, or Picard for Java).

If you are looking for low level information on the BAI file format in order to write your own code to do this, you should read the text on the BGZF format, virtual offsets, and the BAM indexing format in the SAM/BAM specification -
maubp is offline   Reply With Quote
Old 12-20-2011, 12:12 PM   #3
Senior Member
Location: Germany

Join Date: Feb 2011
Posts: 108

The bamtools API provides the functionality for efficient access using BAM and BAI files. This is what most of the tools that inter-operate between SAM and BAM files use in the backend, I suppose. However, this is if you'd want to write a tool yourself. As maubp mentions, why reinvent the wheel? You can just use samtools as follows:

samtools view myfile.bam chr:start-end

Last edited by cedance; 12-20-2011 at 12:16 PM.
cedance is offline   Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

All times are GMT -8. The time now is 04:41 PM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Single Sign On provided by vBSSO