LibStatGen: BAM

From Genome Analysis Wiki
Revision as of 13:42, 16 March 2010 by Mktrost (talk | contribs) (Created page with '= SAM/BAM File= == Reading/Writing SAM/BAM Files == The SamFile class allows a user to easily read/write a SAM/BAM file. This methods found in this class are: {| class="wikitabl…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

SAM/BAM File

Reading/Writing SAM/BAM Files

The SamFile class allows a user to easily read/write a SAM/BAM file. This methods found in this class are:

SamFile Class Methods
Method Name Description
bool OpenForRead(const char* filename) Opens the specified file for reading.

Determines if it is a BAM/SAM file by reading the beginning of the file. Returns true if successfully opened reading, false if not.

bool OpenForWrite(const char * filename) bool: true if successfully opened, false if not.

Opens as BAM file if the specified filename ends in .bam. Otherwise it is opened as a SAM file. Returns true if successfully opened for writing, false if not.

bool ReadHeader(SamFileHeader& header) Reads the header section from the file and stores it in the passed in header.

Returns true if successfully read, false if not.

bool WriteHeader(const SamFileHeader& header) Writes the specified header into the file.

Returns true if successfully written, false if not.

bool ReadRecord(SamFileHeader& header, SamRecord& record) Reads the next record from the file and stores it in the passed in record.

Returns true if successfully read, false if not.

bool WriteRecord(SamFileHeader& header, SamRecord& record) Writes the specified record into the file.

Returns true if successfully written, false if not.