[Seqan-dev] mapQ overwritten when writing sam/bam?


Hi,

I am using the sam/bam packages to read and write sam/bam files and I noticed that a value for the mapping quality (column 5) has been changed from 255 to 0...
Is this possible? I am using the BamIOContext as in the following example:

template<typename TStream, typename TFormat>
int writeOutRecordSet(TStream &fp, StringSet<BamAlignmentRecord> recSet,
BamIOContext<StringSet<CharString> > & context, TFormat const & tag,
        ROI & roi) {

    unsigned maxC = 0;
    for (unsigned i = 0; i < length(roi.count); i++) {
        if (maxC < roi.count[i])
            maxC = roi.count[i];
    }
    roi.countMax = maxC;
    for (unsigned i = 0; i < length(recSet); i++) {
        BamTagsDict tagDict(recSet[i].tags);
        setTagValue(tagDict, "rl", roi.len);
        setTagValue(tagDict, "ri", roi.min);
        setTagValue(tagDict, "rx", roi.max);
        setTagValue(tagDict, "ry", maxC);
        setTagValue(tagDict, "rn", length(recSet), 'i');
        write2(fp, recSet[i], context, tag);
    }
    return maxC;
}

What do I have to do to keep the value?

Thanks a lot for your kind support.

Best,

Bernd