]> git.donarmstrong.com Git - bamtools.git/blobdiff - src/toolkit/bamtools_resolve.cpp
Further fixes for ISIZE-handling in ResolveTool
[bamtools.git] / src / toolkit / bamtools_resolve.cpp
index fa278a3a530e464a10932d2b60265c1b115e8afb..97eefcf18c8c0f1354436eaa75a975d267dce0c4 100644 (file)
@@ -3,7 +3,7 @@
 // Marth Lab, Department of Biology, Boston College
 // All rights reserved.
 // ---------------------------------------------------------------------------
-// Last modified: 13 June 2011
+// Last modified: 14 June 2011
 // ---------------------------------------------------------------------------
 // Resolves paired-end reads (marking the IsProperPair flag as needed).
 // ***************************************************************************
@@ -182,9 +182,10 @@ ReadGroupResolver::ReadGroupResolver(void)
         Models.push_back( ModelType(i+1) );
 }
 
-bool ReadGroupResolver::IsValidInsertSize(const BamAlignment& al) const {
-    return ( al.InsertSize >= MinFragmentLength &&
-             al.InsertSize <= MaxFragmentLength );
+bool ReadGroupResolver::IsValidInsertSize(const BamAlignment& al) const {  
+    const int32_t absInsertSize = abs(al.InsertSize);
+    return ( absInsertSize >= MinFragmentLength &&
+             absInsertSize <= MaxFragmentLength );
 }
 
 bool ReadGroupResolver::IsValidOrientation(const BamAlignment& al) const {
@@ -805,6 +806,10 @@ bool ResolveTool::ResolveToolPrivate::MakeStats(void) {
         // skip if map quality is 0
         if ( al.MapQuality == 0 ) continue;
 
+        // skip if insert size is less than (we'll count its mate)
+        // or equal to zero (single-end or missing data)
+        if ( al.InsertSize <= 0 ) continue;
+
         // determine model type, skip if model unknown
         const uint16_t currentModelType = CalculateModelType(al);
         assert( currentModelType != ModelType::DUMMY_ID );