From Genome Analysis Wiki
Jump to navigationJump to search
34 bytes added
, 10:00, 6 April 2010
Line 1: |
Line 1: |
| == Reading/Writing SAM/BAM Files In Your Program == | | == Reading/Writing SAM/BAM Files In Your Program == |
| + | The '''SamFile''' class allows a user to easily read/write a SAM/BAM file. |
| | | |
| === Reading/Writing Standard SAM/BAM Files === | | === Reading/Writing Standard SAM/BAM Files === |
− | The '''SamFile''' class allows a user to easily read/write a SAM/BAM file.
| |
| The methods found in this class are: | | The methods found in this class are: |
| {| style="margin: 1em 1em 1em 0; background-color: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;" border="1" | | {| style="margin: 1em 1em 1em 0; background-color: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;" border="1" |
Line 44: |
Line 44: |
| ==== Usage Example ==== | | ==== 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. | | 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. |
− | <pre> | + | <source lang="cpp"> |
| int main(int argc, char ** argv) | | int main(int argc, char ** argv) |
| { | | { |
Line 93: |
Line 93: |
| std::cout << "Number of valid records = " << numValidRecords << std::endl; | | std::cout << "Number of valid records = " << numValidRecords << std::endl; |
| } | | } |
− | </pre> | + | </source> |
| | | |
| | | |
Line 152: |
Line 152: |
| ==== Usage Example ==== | | ==== Usage Example ==== |
| This example reads in the inputFilename bam file and writes it back out section by section to the specified outputFilename, starting with section -1. It also prints a count of the number of records in each section. | | This example reads in the inputFilename bam file and writes it back out section by section to the specified outputFilename, starting with section -1. It also prints a count of the number of records in each section. |
− | <pre> | + | <source lang="cpp"> |
| int ReadIndexedBam(const char* inputFilename, | | int ReadIndexedBam(const char* inputFilename, |
| const char* outputFilename, | | const char* outputFilename, |
Line 204: |
Line 204: |
| return(0); | | return(0); |
| } | | } |
− | </pre> | + | </source> |