Set the value of a tag through a BamTagsDict.
The dict to modify.
The key of the tag.
Remarks: Must be a string of length 2.
The value to set the the tag to.
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
setTagValue does not cast the type, so typeC only influences the type character written out but val is written out in binary without modification.
An example setting some atomic tag values.
setTagValue(tags, "XA", 9); // int
setTagValue(tags, "XB", 9u); // unsigned int
setTagValue(tags, "XC", 'X'); // char
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:
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.
__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