Function
setTagValue
Set the value of a tag through a BamTagsDict.
Include Headers
seqan/bam_io.h
Parameters
The dict to modify. Types: BamTagsDict | |
The key of the tag. Types: CharString 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 |
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
Member of
Examples
An example setting some atomic tag values.
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:
Note that on most systems int s 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.
See Also
SeqAn - Sequence Analysis Library - www.seqan.de