]> git.donarmstrong.com Git - bamtools.git/commitdiff
Added option for users to specifiy half-open (1-based) return value for BamAlignment...
authorDerek <derekwbarnett@gmail.com>
Wed, 15 Sep 2010 15:48:33 +0000 (11:48 -0400)
committerDerek <derekwbarnett@gmail.com>
Wed, 15 Sep 2010 15:48:33 +0000 (11:48 -0400)
src/api/BamAux.h

index c8a658570e7e5b15b6f861447d4af706096fc37b..a122b24496e74c4ffa581b646983818989545791 100644 (file)
@@ -3,7 +3,7 @@
 // Marth Lab, Department of Biology, Boston College\r
 // All rights reserved.\r
 // ---------------------------------------------------------------------------\r
-// Last modified: 13 September 2010 (DB)\r
+// Last modified: 15 September 2010 (DB)\r
 // ---------------------------------------------------------------------------\r
 // Provides the basic constants, data structures, etc. for using BAM files\r
 // ***************************************************************************\r
@@ -145,7 +145,9 @@ struct BamAlignment {
 \r
     // Additional data access methods\r
     public:\r
-       int GetEndPosition(bool usePadded = false) const;       // calculates alignment end position, based on starting position and CIGAR operations\r
+        // calculates alignment end position, based on starting position and CIGAR operations\r
+        // @zeroBased - if true, returns 0-based coordinate; else returns 1-based\r
+       int GetEndPosition(bool usePadded = false, bool zeroBased = true) const;  \r
 \r
     // 'internal' utility methods \r
     private:\r
@@ -418,7 +420,7 @@ inline void BamAlignment::SetIsUnmapped(bool ok)           { if (ok) AlignmentFl
 \r
 // calculates alignment end position, based on starting position and CIGAR operations\r
 inline \r
-int BamAlignment::GetEndPosition(bool usePadded) const {\r
+int BamAlignment::GetEndPosition(bool usePadded, bool zeroBased) const {\r
 \r
     // initialize alignment end to starting position\r
     int alignEnd = Position;\r
@@ -435,7 +437,12 @@ int BamAlignment::GetEndPosition(bool usePadded) const {
             alignEnd += (*cigarIter).Length;\r
         }\r
     }\r
-    return alignEnd - 1;\r
+    \r
+    // adjust for zeroBased, if necessary\r
+    if (zeroBased) \r
+        return alignEnd - 1;\r
+    else \r
+        return alignEnd;\r
 }\r
 \r
 inline\r