]> git.donarmstrong.com Git - bamtools.git/blobdiff - src/api/BamAlignment.h
Updated BamAlignment documentation, re: QueryBases field (issue #12)
[bamtools.git] / src / api / BamAlignment.h
index daea418228a7bf4759a946b8aa4d78d64278073f..0f4fe7366dd3f8096b9f7c775f673188d81d1d41 100644 (file)
@@ -2,7 +2,7 @@
 // BamAlignment.h (c) 2009 Derek Barnett
 // Marth Lab, Department of Biology, Boston College
 // ---------------------------------------------------------------------------
-// Last modified: 10 October 2011 (DB)
+// Last modified: 25 July 2013 (DB)
 // ---------------------------------------------------------------------------
 // Provides the BamAlignment data structure
 // ***************************************************************************
@@ -10,9 +10,9 @@
 #ifndef BAMALIGNMENT_H
 #define BAMALIGNMENT_H
 
-#include <api/api_global.h>
-#include <api/BamAux.h>
-#include <api/BamConstants.h>
+#include "api/api_global.h"
+#include "api/BamAux.h"
+#include "api/BamConstants.h"
 #include <cstdlib>
 #include <cstring>
 #include <string>
@@ -80,9 +80,15 @@ struct API_EXPORT BamAlignment {
         template<typename T> bool GetTag(const std::string& tag, T& destination) const;
         template<typename T> bool GetTag(const std::string& tag, std::vector<T>& destination) const;
 
+        // retrieves all current tag names
+        std::vector<std::string> GetTagNames(void) const;
+
         // 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;
 
@@ -100,12 +106,18 @@ struct API_EXPORT BamAlignment {
         // returns a description of the last error that occurred
         std::string GetErrorString(void) const;
 
+        // retrieves the size, read locations and reference locations of soft-clip operations
+        bool GetSoftClips(std::vector<int>& clipSizes,
+                          std::vector<int>& readPositions,
+                          std::vector<int>& genomePositions,
+                          bool usePadded = false) const;
+
     // public data fields
     public:
         std::string Name;               // read name
         int32_t     Length;             // length of query sequence
-        std::string QueryBases;         // 'original' sequence (as reported from sequencing machine)
-        std::string AlignedBases;       // 'aligned' sequence (includes any indels, padding, clipping)
+        std::string QueryBases;         // 'original' sequence (contained in BAM file)
+        std::string AlignedBases;       // 'aligned' sequence (QueryBases plus deletion, padding, clipping chars)
         std::string Qualities;          // FASTQ qualities (ASCII characters, not numeric values)
         std::string TagData;            // tag data (use provided methods to query/modify)
         int32_t     RefID;              // ID number for reference sequence
@@ -421,7 +433,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;
     }
@@ -502,7 +514,7 @@ inline bool BamAlignment::GetTag<std::string>(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;
     }