]> git.donarmstrong.com Git - bamtools.git/commitdiff
Made BamAlignment flag queries symmetrical
authorderek <derekwbarnett@gmail.com>
Mon, 13 Dec 2010 20:28:33 +0000 (15:28 -0500)
committerderek <derekwbarnett@gmail.com>
Mon, 13 Dec 2010 20:28:33 +0000 (15:28 -0500)
 * For example: there is now a SetIsMapped() setter to match the
IsMapped() getter.  Before you had to reverse your logic on a few of the
flags (in this case, using SetIsUnmapped()).  Not impossible to use, but
not immediately obvious and intuitive, and hard to remember when to use
the opposite setter.  These older methods will remain available, but
should be considered deprecated.

src/api/BamAlignment.cpp
src/api/BamAlignment.h

index b0986dfead689291720bb353c57752d9ee6818cd..ca0c47ab63b6413dd76527eb23be270b25363cd6 100644 (file)
@@ -3,7 +3,7 @@
 // Marth Lab, Department of Biology, Boston College
 // All rights reserved.
 // ---------------------------------------------------------------------------
-// Last modified: 19 November 2010 (DB)
+// Last modified: 13 December 2010 (DB)
 // ---------------------------------------------------------------------------
 // Provides the BamAlignment data structure
 // ***************************************************************************
@@ -69,9 +69,12 @@ bool BamAlignment::IsSecondMate(void) const        { return ( (AlignmentFlag & R
 void BamAlignment::SetIsDuplicate(bool ok)          { if (ok) AlignmentFlag |= DUPLICATE;     else AlignmentFlag &= ~DUPLICATE; }
 void BamAlignment::SetIsFailedQC(bool ok)           { if (ok) AlignmentFlag |= QC_FAILED;     else AlignmentFlag &= ~QC_FAILED; }
 void BamAlignment::SetIsFirstMate(bool ok)          { if (ok) AlignmentFlag |= READ_1;        else AlignmentFlag &= ~READ_1; }
+void BamAlignment::SetIsMapped(bool ok)             { SetIsUnmapped(!ok); }
+void BamAlignment::SetIsMateMapped(bool ok)         { SetIsMateUnmapped(!ok); }
 void BamAlignment::SetIsMateUnmapped(bool ok)       { if (ok) AlignmentFlag |= MATE_UNMAPPED; else AlignmentFlag &= ~MATE_UNMAPPED; }
 void BamAlignment::SetIsMateReverseStrand(bool ok)  { if (ok) AlignmentFlag |= MATE_REVERSE;  else AlignmentFlag &= ~MATE_REVERSE; }
 void BamAlignment::SetIsPaired(bool ok)             { if (ok) AlignmentFlag |= PAIRED;        else AlignmentFlag &= ~PAIRED; }
+void BamAlignment::SetIsPrimaryAlignment(bool ok)   { SetIsSecondaryAlignment(!ok); }
 void BamAlignment::SetIsProperPair(bool ok)         { if (ok) AlignmentFlag |= PROPER_PAIR;   else AlignmentFlag &= ~PROPER_PAIR; }
 void BamAlignment::SetIsReverseStrand(bool ok)      { if (ok) AlignmentFlag |= REVERSE;       else AlignmentFlag &= ~REVERSE; }
 void BamAlignment::SetIsSecondaryAlignment(bool ok) { if (ok) AlignmentFlag |= SECONDARY;     else AlignmentFlag &= ~SECONDARY; }
@@ -425,6 +428,7 @@ bool BamAlignment::GetTag(const string& tag, uint32_t& destination) const {
         const char type = *(pTagData - 1);
         int destinationLength = 0;
         switch (type) {
+
             // 1 byte data
             case 'A':
             case 'c':
@@ -619,7 +623,11 @@ bool BamAlignment::RemoveTag(const string& tag) {
     return false;
 }
 
-bool BamAlignment::FindTag(const string& tag, char* &pTagData, const unsigned int& tagDataLength, unsigned int& numBytesParsed) {
+bool BamAlignment::FindTag(const string& tag,
+                           char* &pTagData,
+                           const unsigned int& tagDataLength,
+                           unsigned int& numBytesParsed)
+{
 
     while ( numBytesParsed < tagDataLength ) {
 
index ce22650e3c0df0f42698989127cda60d269485df..9ab416444b31c05c5c1b130eef3e7bb5bbb7d349 100644 (file)
@@ -3,7 +3,7 @@
 // Marth Lab, Department of Biology, Boston College
 // All rights reserved.
 // ---------------------------------------------------------------------------
-// Last modified: 19 November 2010 (DB)
+// Last modified: 13 December 2010 (DB)
 // ---------------------------------------------------------------------------
 // Provides the BamAlignment data structure
 // ***************************************************************************
@@ -52,15 +52,20 @@ struct API_EXPORT BamAlignment {
     public:        
         void SetIsDuplicate(bool ok);           // Sets "PCR duplicate" flag        
         void SetIsFailedQC(bool ok);            // Sets "failed quality control" flag        
-        void SetIsFirstMate(bool ok);           // Sets "alignment is first mate" flag        
-        void SetIsMateUnmapped(bool ok);        // Sets "alignment's mate is mapped" flag        
+        void SetIsFirstMate(bool ok);           // Sets "alignment is first mate" flag
+        void SetIsMapped(bool ok);              // Sets "alignment is mapped" flag
+        void SetIsMateMapped(bool ok);          // Sets "alignment's mate is mapped" flag
         void SetIsMateReverseStrand(bool ok);   // Sets "alignment's mate mapped to reverse strand" flag        
-        void SetIsPaired(bool ok);              // Sets "alignment part of paired-end read" flag        
+        void SetIsPaired(bool ok);              // Sets "alignment part of paired-end read" flag
+        void SetIsPrimaryAlignment(bool ok);    // Sets "position is primary alignment" flag
         void SetIsProperPair(bool ok);          // Sets "alignment is part of read that satisfied paired-end resolution" flag        
         void SetIsReverseStrand(bool ok);       // Sets "alignment mapped to reverse strand" flag        
-        void SetIsSecondaryAlignment(bool ok);  // Sets "position is primary alignment" flag        
-        void SetIsSecondMate(bool ok);          // Sets "alignment is second mate on read" flag        
-        void SetIsUnmapped(bool ok);            // Sets "alignment is mapped" flag
+        void SetIsSecondMate(bool ok);          // Sets "alignment is second mate on read" flag
+
+        // legacy methods (deprecated, but available)
+        void SetIsMateUnmapped(bool ok);        // Complement of IsMateMapped() flag
+        void SetIsSecondaryAlignment(bool ok);  // Complement of IsPrimaryAlignment() flag
+        void SetIsUnmapped(bool ok);            // Complement of IsMapped() flag
 
     // Tag data access methods
     public: