From Genome Analysis Wiki
Jump to navigationJump to search
1,656 bytes added
, 17:08, 16 March 2010
Line 228: |
Line 228: |
| | const char* getQuality() | | | const char* getQuality() |
| | Returns the SAM formatted Quality string. | | | Returns the SAM formatted Quality string. |
| + | |- |
| + | | bool getNextSamTag(char* tag, char& vtype, void** value) |
| + | | Returns true if a tag was read, false if there are no more tags. |
| + | For a true return value, tag is sent to the tag of the tag, vtype is set to the vtype of the tag, and value is a pointer to the value of the tag. You will then need to use a switch to cast value to int, double, char, or String. |
| + | |- |
| + | | bool isIntegerType(char vtype) |
| + | | Returns true if the passed in vtype is of integer ('c', 'C', 's', 'S', 'i', 'I') type. |
| + | |- |
| + | | bool isDoubleType(char vtype) |
| + | | Returns true if the passed in vtype is of double ('f') type. |
| + | |- |
| + | | bool isCharType(char vtype) |
| + | | Returns true if the passed in vtype is of char ('A') type. |
| + | |- |
| + | | bool isStringType(char vtype) |
| + | | Returns true if the passed in vtype is of String ('Z') type. |
| + | |- |
| |- | | |- |
| |} | | |} |
| + | |
| + | |
| + | Example of using getNextSamTag: |
| + | <pre> |
| + | // record is a previously setup SamRecord. |
| + | String recordString = ""; |
| + | char tag[3]; |
| + | char vtype; |
| + | void* value; |
| + | |
| + | // While there are more tags, write them to the recordString. |
| + | while(record.getNextSamTag(tag, vtype, &value) != false) |
| + | { |
| + | recordString += "\t"; |
| + | recordString += tag; |
| + | recordString += ":"; |
| + | recordString += vtype; |
| + | recordString += ":"; |
| + | if(record.isIntegerType(vtype)) |
| + | { |
| + | recordString += (int)*(int*)value; |
| + | } |
| + | else if(record.isDoubleType(vtype)) |
| + | { |
| + | recordString += (double)*(double*)value; |
| + | } |
| + | else if(record.isCharType(vtype)) |
| + | { |
| + | recordString += (char)*(char*)value; |
| + | } |
| + | else |
| + | { |
| + | // String type. |
| + | recordString += (String)*(String*)value; |
| + | } |
| + | } |
| + | |
| + | recordString += "\n"; |
| + | </pre> |