Line 15: |
Line 15: |
| | | |
| === 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 '''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: |
| {| class="wikitable" style="width:100%" border="1" | | {| class="wikitable" style="width:100%" border="1" |
Line 54: |
Line 54: |
| | | |
| ==== 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> | | <pre> |
| int main(int argc, char ** argv) | | int main(int argc, char ** argv) |
Line 108: |
Line 108: |
| | | |
| === Reading Indexed (and Sorted) BAM Files === | | === Reading Indexed (and Sorted) BAM Files === |
− | The IndexedBamReader class allows a user to easily read BAM files that are sorted and indexed. | + | The '''IndexedBamReader''' class allows a user to easily read BAM files that are sorted and indexed. |
| This class allows a user to read only alignments for specific reference sequence. This saves the time of having to read the entire file. | | This class allows a user to read only alignments for specific reference sequence. This saves the time of having to read the entire file. |
| It takes advantage of the seeking capability of BGZF files, using the BAM Index file to determine where in the BAM file to seek to. | | It takes advantage of the seeking capability of BGZF files, using the BAM Index file to determine where in the BAM file to seek to. |
Line 216: |
Line 216: |
| | | |
| == Setting fields in a SAM/BAM Header == | | == Setting fields in a SAM/BAM Header == |
− | The SamRecord class contains accessors to set the header lines of a SAM/BAM header. By using these set methods to setup the header, they can be pulled back out using the get accessors or the header can be later written to a SAM/BAM file. | + | The '''SamRecord''' class contains accessors to set the header lines of a SAM/BAM header. By using these set methods to setup the header, they can be pulled back out using the get accessors or the header can be later written to a SAM/BAM file. |
− | The methods found in the SamFileHeader class for setting fields are: | + | The methods found in the '''SamFileHeader''' class for setting fields are: |
| {| class="wikitable" style="width:100%" border="1" | | {| class="wikitable" style="width:100%" border="1" |
| |+ style="font-size:150%"|'''SamFileHeader Class Methods''' | | |+ style="font-size:150%"|'''SamFileHeader Class Methods''' |
Line 241: |
Line 241: |
| | | |
| == Setting fields in a SAM/BAM Record == | | == Setting fields in a SAM/BAM Record == |
− | The SamRecord class contains accessors to set the fields of a SAM/BAM record. They are used for creating a record that is not read from a SAM/BAM file. By using these set methods to setup the record, they can be pulled back out using the get accessors or the record can be later written as either a SAM/BAM record. | + | The '''SamRecord''' class contains accessors to set the fields of a SAM/BAM record. They are used for creating a record that is not read from a SAM/BAM file. By using these set methods to setup the record, they can be pulled back out using the get accessors or the record can be later written as either a SAM/BAM record. |
− | The methods found in the SamRecord class for setting fields are: | + | The methods found in the '''SamRecord''' class for setting fields are: |
| {| class="wikitable" style="width:100%" border="1" | | {| class="wikitable" style="width:100%" border="1" |
| |+ style="font-size:150%"|'''SamRecord Class Methods''' | | |+ style="font-size:150%"|'''SamRecord Class Methods''' |
Line 312: |
Line 312: |
| | | |
| == Retrieving fields from a SAM/BAM Record == | | == Retrieving fields from a SAM/BAM Record == |
− | The SamRecord class contains accessors to access the fields of a SAM/BAM record. They assume that the class has already been populated, either by using the set commands or by calling SamFile::ReadRecord. Not all of the values that can be retrieved using these get accessors have set methods. That is because they are internally calculated values if they were not read from a file. | + | The '''SamRecord''' class contains accessors to access the fields of a SAM/BAM record. They assume that the class has already been populated, either by using the set commands or by calling SamFile::ReadRecord. Not all of the values that can be retrieved using these get accessors have set methods. That is because they are internally calculated values if they were not read from a file. |
| | | |
| The methods found in the SamRecord class for setting fields are: | | The methods found in the SamRecord class for setting fields are: |