SAM/BAM Classes FAQs
From Genome Analysis Wiki
Jump to navigationJump to searchThe printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
How Do I?
Q: What is SAM/BAM?
Q: Map between a query/read sequence and a reference sequence to do things like looking up a base/quality at a given reference position or looking up a reference base for a given read position?
Q: Read only portions of a sorted & indexed BAM file that fall within a specified region?
- A:
- open a sorted and indexed BAM file for reading (
SamFile::OpenForRead
) - read the BAM Index file (
SamFile::ReadBamIndex
) - read the header (
SamFile::ReadHeader
) - set the region to be read (
SamFile::SetReadSection
) - Loop calling
SamFile::ReadRecord
until it returns false - indicating there are no more reads within this region.
- open a sorted and indexed BAM file for reading (
These methods are found in C++ Class: SamFile.
NOTE: ReadRecord will also return false on an error - use SamFile::GetStatus()
to determine if it was an error or the end of the region. GetStatus
returns SamStatus::NO_MORE_RECS for the end of the region.
See the library usage page for an Example.
- Q: How do I read multiple regions?
- A: Use the above solution, but loop on the SetReadSection/ReadRecord steps until all sections have been processed.
Q: Get additional information on this library?
- A: If you have any questions or comments, please raise issue in our GitHub repositories.