Class
BamTagsDict
Indexes start positions of BAM tags in a CharString and provides a dict-like API.
BamTagsDict
Include Headers
seqan/bam_io.h
Member Functions
BamTagsDictConstructor.
Functions
buildIndexBuild index for a BamTagsDict object.
eraseTagErase tag from BamTagsDict.
extractTagValueExtract and cast "atomic" value from tags string with index idx.
getTagKeyReturn key of a tag by index.
getTagValueReturn the value of a tag by its index in the BamTagsDict.
hasIndexReturn true if BamTagsDict has an index.
lengthThe number of items/characters.
setTagValueSet the value of a tag through a BamTagsDict.
Examples
CharString samStr = "AA:Z:value1\tAB:Z:value2\tAC:i:30";
CharString bamStr;
assignSamToBam(bamStr, samStr);
BamTagsDict tags(bamStr);
std::cerr << length(tags) << std::endl;  // #=> "3"
for (unsigned i = 0; i < length(tags); ++i)
{
    std::cerr << getTagKey(tags, i) << " -> " << getTagValue(tags, i) << std::endl;
    if (getTagValue(tags, i)[0] == 'i')  // is 32 bit integer
    {
        __int32 x = 0;
        bool res = extractTagValue(x, tags, i);
        SEQAN_ASSERT_MSG(res, "Not a valid integer at pos %u!", i);
        std::cerr << "     " << x << std::endl;
    }
}
// #=> "AA -> Zvalue1"
// #=> "AB -> Zvalue2"
// #-> "AC -> i<binary representation of 30>"
#  #-> "      30"
SeqAn - Sequence Analysis Library - www.seqan.de
 

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