From Genome Analysis Wiki
==== Usage Example ====
The following example reads in a sam/bam file and writes it out as a sam/bam file. The file format of the input sam/bam is determined by the SamFile class based on reading the type from the file. The file format of the output sam/bam file is determined by the '''SamFile''' class based on the extension of the output file. A ".bam" extension indicates a BAM file. All other extensions indicate SAM files.
int main(int argc, char ** argv)
std::cout << "Number of valid records = " << numValidRecords << std::endl;
=== Reading Indexed (and Sorted) BAM Files ===