bool checkAlignmentTag(const PropertyFilterValue& valueFilter, const BamAlignment& al) { // ensure filter contains string data Variant entireTagFilter = valueFilter.Value; if ( !entireTagFilter.is_type<string>() ) return false; // localize string from variant const string& entireTagFilterString = entireTagFilter.get<string>(); // ensure we have at least "XX:x" if ( entireTagFilterString.length() < 4 ) return false; // get tagName & lookup in alignment // if found, set tagType to tag type character // if not found, return false const string& tagName = entireTagFilterString.substr(0,2); char tagType = '\0'; if ( !al.GetTagType(tagName, tagType) ) return false; // remove tagName & ":" from beginning tagFilter string tagFilterString = entireTagFilterString.substr(3); // switch on tag type to set tag query value & parse filter token int32_t intFilterValue, intQueryValue; uint32_t uintFilterValue, uintQueryValue; float realFilterValue, realQueryValue; string stringFilterValue, stringQueryValue; PropertyFilterValue tagFilter; PropertyFilterValue::ValueCompareType compareType; bool keepAlignment = false; switch (tagType) { // signed int tag type case 'c' : case 's' : case 'i' : if ( al.GetTag(tagName, intQueryValue) ) { if ( FilterEngine<BamAlignmentChecker>::parseToken(tagFilterString, intFilterValue, compareType) ) { tagFilter.Value = intFilterValue; tagFilter.Type = compareType; keepAlignment = tagFilter.check(intQueryValue); } } break; // unsigned int tag type case 'C' : case 'S' : case 'I' : if ( al.GetTag(tagName, uintQueryValue) ) { if ( FilterEngine<BamAlignmentChecker>::parseToken(tagFilterString, uintFilterValue, compareType) ) { tagFilter.Value = uintFilterValue; tagFilter.Type = compareType; keepAlignment = tagFilter.check(uintQueryValue); } } break; // 'real' tag type case 'f' : if ( al.GetTag(tagName, realQueryValue) ) { if ( FilterEngine<BamAlignmentChecker>::parseToken(tagFilterString, realFilterValue, compareType) ) { tagFilter.Value = realFilterValue; tagFilter.Type = compareType; keepAlignment = tagFilter.check(realQueryValue); } } break; // string tag type case 'A': case 'Z': case 'H': if ( al.GetTag(tagName, stringQueryValue) ) { if ( FilterEngine<BamAlignmentChecker>::parseToken(tagFilterString, stringFilterValue, compareType) ) { tagFilter.Value = stringFilterValue; tagFilter.Type = compareType; keepAlignment = tagFilter.check(stringQueryValue); } } break; // unknown tag type default : keepAlignment = false; } return keepAlignment; }