Changes

From Genome Analysis Wiki
Jump to navigationJump to search
no edit summary
Line 40: Line 40:     
==== Set/Add/Remove a Single Tag ====
 
==== Set/Add/Remove a Single Tag ====
NOTE: A tag is removed by setting it to ""
+
The passed in tag should be the two character SAM tag as defined in the SAM spec.
   −
NOTE: For the SQ header type, the SN tag may not be modified once it is set, and for the RG header type, the ID tag may not be modified once it is set.  That is because these values are used as a lookup key for the header record.
+
A tag is removed from the header record by setting it to "".  For the SQ and RG header types, the key tags (SN for SQ and ID for RG) may not be modified or removed once set.  This is because these values are used as a lookup key for the header record, so the entire record must be removed.
    
{| 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 110: Line 110:  
| Remove the RG record associated with the specified id.
 
| Remove the RG record associated with the specified id.
 
Returns true if successfully removed or if it didn't exist in the first place.  Returns false if the record still exists.
 
Returns true if successfully removed or if it didn't exist in the first place.  Returns false if the record still exists.
 +
|}
 +
 +
==== Add a Comment ====
 +
{| style="margin: 1em 1em 1em 0; background-color: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;" border="1"
 +
|-style="background: #f2f2f2; text-align: center;"  '''SamFileHeader Class Methods'''
 +
! Method Name !!  Description
 +
|-
 +
| <code>bool SamFileHeader::addComment(const char* comment)</code>
 +
| Add the specified comment to the header.  The comment should NOT include the "@CO" or "\n".
 +
Returns true if successfully added.
 
|}
 
|}
       
=== Getting fields from the Header ===
 
=== Getting fields from the Header ===
 +
The following sets of methods are accessors to pull information from the SAM/BAM Header.
 +
 +
==== Get the Entire Header ====
 +
Get the entire header as a single string.
    
{| 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 122: Line 136:  
| Set the passed in string to the entire header string.  Clearing its current contents.
 
| Set the passed in string to the entire header string.  Clearing its current contents.
 
Returns true if successfully set (even if set to "")
 
Returns true if successfully set (even if set to "")
 +
|}
 +
 +
==== Get the Header Record/Line by Record/Line ====
 +
The following methods are for iterating through the header.
 +
 +
{| style="margin: 1em 1em 1em 0; background-color: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;" border="1"
 +
|-style="background: #f2f2f2; text-align: center;"  '''SamFileHeader Class Methods'''
 +
! Method Name !!  Description
 +
|-
 +
| <code>SamHeaderRecord* SamFileHeader::getNextHeaderRecord()</code>
 +
| Returns the next header record.  After all headers have been retrieved, NULL is returned until a reset is called.
 +
Does not return the Comment lines.
 +
 +
NOTE: both getNextHeaderRecord and getNextHeaderLine increment the same iterator.
 +
|-
 +
| <code>const char* SamFileHeader::getNextHeaderLine()</code>
 +
| Returns the string version of the next header record.  After all headers have been retrieved, "" is returned until a reset is called.
 +
Return the comment lines.
 +
 +
NOTE: both getNextHeaderRecord and getNextHeaderLine increment the same iterator.
 +
|-
 +
| <code>void SamFileHeader::resetHeaderRecordIter()</code>
 +
| Resets to the beginning of the header records so the next call to getNextHeaderRecord/getNextHeaderLine returns the first header line.
 +
|}
 +
 +
==== Get a Specific Tag ====
 +
These methods return the value associated with the specified tag.  If the tag does not exist in the record "" is returned.
 +
 +
For SQ and RG the value returned is for the tag associated with the specified key (name/id).  If a record with that key does not exist or if the tag does not exist for the record with that key, "" is returned.
 +
 +
{| style="margin: 1em 1em 1em 0; background-color: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;" border="1"
 +
|-style="background: #f2f2f2; text-align: center;"  '''SamFileHeader Class Methods'''
 +
! Method Name !!  Description
 +
|-
 +
| <code>const char* SamFileHeader::getHDTagValue(const char* tag)</code>
 +
| Returns the value associated with the specified HD tag.  Returns "" if the tag does not exist in the header.
 +
|-
 +
| <code>const char* SamFileHeader::getPGTagValue(const char* tag)</code>
 +
| Returns the value associated with the specified PG tag.  Returns "" if the tag does not exist in the header.
 +
|-
 +
| <code>const char* SamFileHeader::getSQTagValue(const char* tag, const char* name)</code>
 +
| Returns the value associated with the specified tag on the SQ line with the specified sequence name.  Returns "" if the tag does not exist in the specified line or if the specified line does not exist.
 +
|-
 +
| <code>const char* SamFileHeader::getRGTagValue(const char* tag, const char* id)</code>
 +
| Returns the value associated with the specified tag on the RG line with the specified sequence name.  Returns "" if the tag does not exist in the specified line or if the specified line does not exist.
 +
|}
 +
 +
==== Get a Specific Record ====
 +
These methods return a reference to the specific record that was requested.  They return NULL if that record does not exist in the header.
 +
 +
The returned record can be modified to add/remove some tags.  Since a reference is returned, the SamHeaderFile automatically reflects these changes.
 +
 +
{| style="margin: 1em 1em 1em 0; background-color: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;" border="1"
 +
|-style="background: #f2f2f2; text-align: center;"  '''SamFileHeader Class Methods'''
 +
! Method Name !!  Description
 +
|-
 +
| <code>SamHeaderHD* SamFileHeader::getHD()</code>
 +
| Get the HD object.  Returns NULL if there is no HD record.
 +
|-
 +
| <code>SamHeaderPG* SamFileHeader::getPG()</code>
 +
| Get the PG object.  Returns NULL if there is no PG record.
 +
|-
 +
| <code>SamHeaderSQ* SamFileHeader::getSQ(const char* name)</code>
 +
| Get the SQ object with the specified sequence name.  Returns NULL if there is no SQ object with that key.
 +
|-
 +
| <code>SamHeaderRG* SamFileHeader::getRG(const char* id)</code>
 +
| Get the RG object with the specified sequence name.  Returns NULL if there is no RG object with that key.
 +
|}
 +
 +
==== Get Just Comments ====
 +
These methods just access the header comments.
 +
 +
{| style="margin: 1em 1em 1em 0; background-color: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;" border="1"
 +
|-style="background: #f2f2f2; text-align: center;"  '''SamFileHeader Class Methods'''
 +
! Method Name !!  Description
 +
|-
 +
| <code>const char* SamFileHeader::getNextComment()</code>
 +
| Returns the comment on the next comment.  Does not include the "@CO" or the "\n"
 +
Returns "" if all comment lines have been returned, until resetCommentIter is called.
 +
|-
 +
| <code>void SamFileHeader::resetCommentIter()</code>
 +
| Resets to the beginning of the comments so getNextComment returns the first comment.
 +
|}
 +
 +
==== Additional Accessors ====
 +
{| style="margin: 1em 1em 1em 0; background-color: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;" border="1"
 +
|-style="background: #f2f2f2; text-align: center;"  '''SamFileHeader Class Methods'''
 +
! Method Name !!  Description
 
|-
 
|-
 
| <code>const char* SamFileHeader::getTagSO()</code>
 
| <code>const char* SamFileHeader::getTagSO()</code>
| Return the value of the SO tag.  If the field does not exist, "unsorted" is returned.
+
| Return the value of the SO tag in the HD record.  If the field does not exist, "unsorted" is returned.
 
|}
 
|}
      −
==== Proposed Accessors ====
+
==== Additional Proposed Accessors ====
 
* HD
 
* HD
 
** getVersion - returns the VN field (will only be one)
 
** getVersion - returns the VN field (will only be one)

Navigation menu