Function
setTagValue
Set the value of a tag through a BamTagsDict.
setTagValue(tags, key, val[, typeC])
Include Headers
seqan/bam_io.h
Parameters
tags
The dict to modify.
key
The key of the tag.
Types: CharString
Remarks: Must be a string of length 2.
val
The value to set the the tag to.
typeC
BAM type char to use.
Types: By default, the type is inflected using getBamTypeChar.
Remarks: For portability (so the generated files are the same on all platforms), use a signed/unsigned qualified type for val or give typeC. Also see the remarks for getBamTypeChar.
Remarks
Note that setTagValue does not cast the type, so typeC only influences the type character written out but val is written out in binary without modification.
Return Values
bool indicating the success. This function can fail if the key is not a valid tag id (e.g. does not have length 2) or if the type of val is not an atomic value or a string (anything but char *, char const *, a character, integer or float type is invalid).
Member of
Examples
An example setting some atomic tag values.
CharString rawTagsText;
BamTagsDict tags(rawTagsText);
setTagValue(tags, "XA", 9);    // int
setTagValue(tags, "XB", 9u);   // unsigned int
setTagValue(tags, "XC", 'X');  // char
If char is equal to __int8 or __uint8 then the last line produces an entry with type 'c' or 'C'. To make sure that the type char 'A' (for "printable character") is written to the file, give it explicitely:
setTagValue(tags, "XC", 'X', 'A');  // Overrwrite XC, enforce type 'printable character'.
Note that on most systems ints have a width of 32 bytes, but the C++ standard leaves this open. For all types but characters, you should not give an explicit type char but use one of the types with explicit width and signed/unsigned qualifier such as __int32, __uint32 etc.
// The following is not recommended since the type of $x$ is not "unsigned 32 bit int."
__int32 x = -1;
setTagValue(tags, "XB", x, 'I');
// Instead, explicitely use an unsigned type if you need one.  Note that your compiler
// might warn you about assigning -1 to an unsigned variable so you know that you are
// probably doing something unintended.
__uint32 y = -1;
setTagValue(tags, "XB", y);
 
// Do not do this!
setTagValue(tags, "XA", 9, 'f');    // BOGUS since 9 is not a floating point number.
SeqAn - Sequence Analysis Library - www.seqan.de
 

Page built @2013/07/11 09:12:35