From 8cff313e03c7756e753c06097d710b8dc73b6eb7 Mon Sep 17 00:00:00 2001 From: derek Date: Mon, 13 Dec 2010 15:28:33 -0500 Subject: [PATCH] Made BamAlignment flag queries symmetrical * 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 | 12 ++++++++++-- src/api/BamAlignment.h | 19 ++++++++++++------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/api/BamAlignment.cpp b/src/api/BamAlignment.cpp index b0986df..ca0c47a 100644 --- a/src/api/BamAlignment.cpp +++ b/src/api/BamAlignment.cpp @@ -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 ) { diff --git a/src/api/BamAlignment.h b/src/api/BamAlignment.h index ce22650..9ab4164 100644 --- a/src/api/BamAlignment.h +++ b/src/api/BamAlignment.h @@ -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: -- 2.39.2