]> git.donarmstrong.com Git - bamtools.git/commitdiff
Fixed: error in FilterTool - mishandling of ASCII tag values
authorDerek Barnett <derekwbarnett@gmail.com>
Sun, 28 Apr 2013 02:51:32 +0000 (22:51 -0400)
committerDerek Barnett <derekwbarnett@gmail.com>
Sun, 28 Apr 2013 02:51:32 +0000 (22:51 -0400)
src/toolkit/bamtools_filter.cpp

index 1189981452cd2cae582eda14283fde483bf2eca9..8334b59c6d3863b5cda49f9d4697a1a431a73cae 100644 (file)
@@ -2,7 +2,7 @@
 // bamtools_filter.cpp (c) 2010 Derek Barnett, Erik Garrison
 // Marth Lab, Department of Biology, Boston College
 // ---------------------------------------------------------------------------
-// Last modified: 10 December 2012
+// Last modified: 27 April 2013
 // ---------------------------------------------------------------------------
 // Filters BAM file(s) according to some user-specified criteria
 // ***************************************************************************
@@ -157,6 +157,7 @@ struct BamAlignmentChecker {
         string tagFilterString = entireTagFilterString.substr(3);
 
         // switch on tag type to set tag query value & parse filter token
+        int8_t   asciiFilterValue,   asciiQueryValue;
         int32_t  intFilterValue,    intQueryValue;
         uint32_t uintFilterValue,   uintQueryValue;
         float    realFilterValue,   realQueryValue;
@@ -167,6 +168,17 @@ struct BamAlignmentChecker {
         bool keepAlignment = false;
         switch (tagType) {
 
+            // ASCII tag type
+            case 'A':
+                if ( al.GetTag(tagName, asciiQueryValue) ) {
+                    if ( FilterEngine<BamAlignmentChecker>::parseToken(tagFilterString, asciiFilterValue, compareType) ) {
+                        tagFilter.Value = asciiFilterValue;
+                        tagFilter.Type  = compareType;
+                        keepAlignment   = tagFilter.check(asciiQueryValue);
+                    }
+                }
+                break;
+
             // signed int tag type
             case 'c' :
             case 's' :
@@ -205,7 +217,7 @@ struct BamAlignmentChecker {
                 break;
 
             // string tag type
-            case 'A':
+
             case 'Z':
             case 'H':
                 if ( al.GetTag(tagName, stringQueryValue) ) {