From c3a7c31347d42a926214e2508d713975d124e8c6 Mon Sep 17 00:00:00 2001 From: derek Date: Sun, 16 Oct 2011 23:30:34 -0400 Subject: [PATCH] Regression fixed: error in BamAlignment tag access methods --- CMakeLists.txt | 2 +- docs/Doxyfile | 2 +- src/api/BamAlignment.cpp | 15 ++++++++++++--- src/api/BamAlignment.h | 6 +++--- src/api/BamConstants.h | 16 ++++++++-------- src/api/CMakeLists.txt | 2 +- 6 files changed, 26 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bc61435..70f606f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,7 +32,7 @@ ensure_out_of_source_build (" # set BamTools version information set (BamTools_VERSION_MAJOR 2) set (BamTools_VERSION_MINOR 0) -set (BamTools_VERSION_BUILD 4) +set (BamTools_VERSION_BUILD 5) # set our library and executable destination dirs set (EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/bin") diff --git a/docs/Doxyfile b/docs/Doxyfile index b50929b..c99c055 100644 --- a/docs/Doxyfile +++ b/docs/Doxyfile @@ -31,7 +31,7 @@ PROJECT_NAME = BamTools # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = 2.0.4 +PROJECT_NUMBER = 2.0.5 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. diff --git a/src/api/BamAlignment.cpp b/src/api/BamAlignment.cpp index 013937a..c95e896 100644 --- a/src/api/BamAlignment.cpp +++ b/src/api/BamAlignment.cpp @@ -365,9 +365,18 @@ bool BamAlignment::FindTag(const std::string& tag, return true; // get the storage class and find the next tag - if ( *pTagStorageType == '\0' ) return false; - if ( !SkipToNextTag(*pTagStorageType, pTagData, numBytesParsed) ) return false; - if ( *pTagData == '\0' ) return false; + if ( *pTagStorageType == '\0' ) { + ErrorString = "unexpected null found - 1"; + return false; + } + if ( !SkipToNextTag(*pTagStorageType, pTagData, numBytesParsed) ) { + ErrorString = "could not skip to next tag"; + return false; + } + if ( *pTagData == '\0' ) { + ErrorString = "unexpected null found - 2"; + return false; + } } // checked all tags, none match diff --git a/src/api/BamAlignment.h b/src/api/BamAlignment.h index 22535c9..a2349ea 100644 --- a/src/api/BamAlignment.h +++ b/src/api/BamAlignment.h @@ -2,7 +2,7 @@ // BamAlignment.h (c) 2009 Derek Barnett // Marth Lab, Department of Biology, Boston College // --------------------------------------------------------------------------- -// Last modified: 12 October 2011 (DB) +// Last modified: 16 October 2011 (DB) // --------------------------------------------------------------------------- // Provides the BamAlignment data structure // *************************************************************************** @@ -427,7 +427,7 @@ inline bool BamAlignment::GetTag(const std::string& tag, T& destination) const { unsigned int numBytesParsed = 0; // return failure if tag not found - if ( FindTag(tag, pTagData, tagDataLength, numBytesParsed) ) { + if ( !FindTag(tag, pTagData, tagDataLength, numBytesParsed) ) { // TODO: set error string? return false; } @@ -508,7 +508,7 @@ inline bool BamAlignment::GetTag(const std::string& tag, unsigned int numBytesParsed = 0; // return failure if tag not found - if ( FindTag(tag, pTagData, tagDataLength, numBytesParsed) ) { + if ( !FindTag(tag, pTagData, tagDataLength, numBytesParsed) ) { // TODO: set error string? return false; } diff --git a/src/api/BamConstants.h b/src/api/BamConstants.h index a944096..47f73a9 100644 --- a/src/api/BamConstants.h +++ b/src/api/BamConstants.h @@ -2,7 +2,7 @@ // BamConstants.h (c) 2011 Derek Barnett // Marth Lab, Department of Biology, Boston College // --------------------------------------------------------------------------- -// Last modified: 10 October 2011 (DB) +// Last modified: 16 October 2011 (DB) // --------------------------------------------------------------------------- // Provides basic constants for handling BAM files. // *************************************************************************** @@ -71,12 +71,12 @@ const int BAM_CIGAR_MASK = ((1 << BAM_CIGAR_SHIFT) - 1); // BAM tag types & sizes const char BAM_TAG_TYPE_ASCII = 'A'; -const char BAM_TAG_TYPE_UINT8 = 'c'; -const char BAM_TAG_TYPE_INT8 = 'C'; -const char BAM_TAG_TYPE_UINT16 = 's'; -const char BAM_TAG_TYPE_INT16 = 'S'; -const char BAM_TAG_TYPE_UINT32 = 'i'; -const char BAM_TAG_TYPE_INT32 = 'I'; +const char BAM_TAG_TYPE_INT8 = 'c'; +const char BAM_TAG_TYPE_UINT8 = 'C'; +const char BAM_TAG_TYPE_INT16 = 's'; +const char BAM_TAG_TYPE_UINT16 = 'S'; +const char BAM_TAG_TYPE_INT32 = 'i'; +const char BAM_TAG_TYPE_UINT32 = 'I'; const char BAM_TAG_TYPE_FLOAT = 'f'; const char BAM_TAG_TYPE_STRING = 'Z'; const char BAM_TAG_TYPE_HEX = 'H'; @@ -190,7 +190,7 @@ struct TagTypeHelper { template<> struct TagTypeHelper { - static bool CanCovnertFrom(const char c) { + static bool CanConvertFrom(const char c) { return ( c == Constants::BAM_TAG_TYPE_ASCII || c == Constants::BAM_TAG_TYPE_UINT8 || c == Constants::BAM_TAG_TYPE_UINT16 ); diff --git a/src/api/CMakeLists.txt b/src/api/CMakeLists.txt index 8278f66..55f2560 100644 --- a/src/api/CMakeLists.txt +++ b/src/api/CMakeLists.txt @@ -49,7 +49,7 @@ set( BamToolsAPISources # create main BamTools API shared library add_library( BamTools SHARED ${BamToolsAPISources} ) -set_target_properties( BamTools PROPERTIES SOVERSION "2.0.4" ) +set_target_properties( BamTools PROPERTIES SOVERSION "2.0.5" ) set_target_properties( BamTools PROPERTIES OUTPUT_NAME "bamtools" ) # create main BamTools API static library -- 2.39.2