]> git.donarmstrong.com Git - bamtools.git/commitdiff
Version 2.2.2
authorDerek Barnett <derekwbarnett@gmail.com>
Tue, 4 Dec 2012 16:42:50 +0000 (11:42 -0500)
committerDerek Barnett <derekwbarnett@gmail.com>
Tue, 4 Dec 2012 16:42:50 +0000 (11:42 -0500)
  * Added: BamAlignment::GetArrayTagType()

CMakeLists.txt
docs/Doxyfile
src/api/BamAlignment.cpp
src/api/BamAlignment.h
src/api/CMakeLists.txt
src/toolkit/CMakeLists.txt

index 27deb55c2b1ba59164fb6f50878d0d3079e022ee..9e3dc8eb3bfa4cffb5cdb695cafbf61c20d9fd62 100644 (file)
@@ -32,7 +32,7 @@ ensure_out_of_source_build( "
 # set BamTools version information
 set( BamTools_VERSION_MAJOR 2 )
 set( BamTools_VERSION_MINOR 2 )
-set( BamTools_VERSION_BUILD 1 )
+set( BamTools_VERSION_BUILD 2 )
 
 # set our library and executable destination dirs
 set( EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/bin" )
index af6daabc11225f75473ba2eb74b842601e970e3e..c2ff078849050e9d13df5a22518f2da96995b599 100644 (file)
@@ -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.2.1
+PROJECT_NUMBER         = 2.2.2
 
 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
 # base path where the generated documentation will be put. 
index b8482f69d45806156578e8d2aacb18be3ea628f6..620ba2ee72db0127db733808708318ddf05ec240 100644 (file)
@@ -2,7 +2,7 @@
 // BamAlignment.cpp (c) 2009 Derek Barnett
 // Marth Lab, Department of Biology, Boston College
 // ---------------------------------------------------------------------------
-// Last modified: 18 November 2012 (DB)
+// Last modified: 4 December 2012 (DB)
 // ---------------------------------------------------------------------------
 // Provides the BamAlignment data structure
 // ***************************************************************************
@@ -394,6 +394,72 @@ bool BamAlignment::FindTag(const std::string& tag,
     return false;
 }
 
+/*! \fn bool BamAlignment::GetArrayTagType(const std::string& tag, char& type) const
+    \brief Retrieves the BAM tag type-code for the array elements associated with requested tag name.
+
+    \param[in]  tag  2-character tag name
+    \param[out] type retrieved (1-character) type-code
+
+    \return \c true if found. False if not found, or if tag is not an array type.
+    \sa \samSpecURL for more details on reserved tag names, supported tag types, etc.
+*/
+bool BamAlignment::GetArrayTagType(const std::string& tag, char& type) const {
+
+    // skip if alignment is core-only
+    if ( SupportData.HasCoreOnly ) {
+        // TODO: set error string?
+        return false;
+    }
+
+    // skip if no tags present
+    if ( TagData.empty() ) {
+        // TODO: set error string?
+        return false;
+    }
+
+    // localize the tag data
+    char* pTagData = (char*)TagData.data();
+    const unsigned int tagDataLength = TagData.size();
+    unsigned int numBytesParsed = 0;
+
+    // if tag not found, return failure
+    if ( !FindTag(tag, pTagData, tagDataLength, numBytesParsed) ){
+        // TODO: set error string?
+        return false;
+    }
+
+    // check that tag type code is array
+    type = *(pTagData - 1);
+    if ( type != Constants::BAM_TAG_TYPE_ARRAY ) {
+        // TODO: set error string
+        return false;
+    }
+
+    // fetch element type
+    const char elementType = *pTagData;
+    switch ( elementType ) {
+
+        // allowable types
+        case (Constants::BAM_TAG_TYPE_INT8)   :
+        case (Constants::BAM_TAG_TYPE_UINT8)  :
+        case (Constants::BAM_TAG_TYPE_INT16)  :
+        case (Constants::BAM_TAG_TYPE_UINT16) :
+        case (Constants::BAM_TAG_TYPE_INT32)  :
+        case (Constants::BAM_TAG_TYPE_UINT32) :
+        case (Constants::BAM_TAG_TYPE_FLOAT)  :
+            type = elementType;
+            break;
+
+        default:
+            //TODO: set error string
+            return false;
+    }
+
+    // if we get here, return success
+    return true;
+}
+
+
 /*! \fn int BamAlignment::GetEndPosition(bool usePadded = false, bool closedInterval = false) const
     \brief Calculates alignment end position, based on its starting position and CIGAR data.
 
index d18b239d65f50b44703682184e760927fd181f81..e12aad675fe4bf5ff70a3223179c3c185a192657 100644 (file)
@@ -2,7 +2,7 @@
 // BamAlignment.h (c) 2009 Derek Barnett
 // Marth Lab, Department of Biology, Boston College
 // ---------------------------------------------------------------------------
-// Last modified: 18 November 2012 (DB)
+// Last modified: 4 December 2012 (DB)
 // ---------------------------------------------------------------------------
 // Provides the BamAlignment data structure
 // ***************************************************************************
@@ -86,6 +86,9 @@ struct API_EXPORT BamAlignment {
         // retrieves the SAM/BAM type-code for requested tag name
         bool GetTagType(const std::string& tag, char& type) const;
 
+        // retrieves the SAM/BAM type-code for the data elements in an array tag
+        bool GetArrayTagType(const std::string& tag, char& type) const;
+
         // returns true if alignment has a record for this tag name
         bool HasTag(const std::string& tag) const;
 
index 321be2391ca694007f6ba7c5b79a7988d5e7ab36..be46a7a5590c3c0a2b0ee338591579127d132578 100644 (file)
@@ -34,7 +34,7 @@ set( BamToolsAPISources
 # create main BamTools API shared library
 add_library( BamTools SHARED ${BamToolsAPISources} )
 set_target_properties( BamTools PROPERTIES
-                       SOVERSION "2.2.1"
+                       SOVERSION "2.2.2"
                        OUTPUT_NAME "bamtools" )
 
 # create main BamTools API static library
index d9c92d426c777f339998118f9129bb70c9814ba9..ba5b640f6e327551b9d70ca7971b221c4d46ebe8 100644 (file)
@@ -31,7 +31,7 @@ add_executable( bamtools_cmd
 
 # set BamTools application properties
 set_target_properties( bamtools_cmd PROPERTIES
-                       VERSION  2.2.1
+                       VERSION  2.2.2
                        OUTPUT_NAME "bamtools"
                      )
 # make version info available in application