]> git.donarmstrong.com Git - bamtools.git/commitdiff
Changed BamAlignment::InsertSize to signed int... need to test
authorbarnett <barnett@9efb377e-2e27-44b9-b91a-ec4abb80ed8b>
Fri, 25 Sep 2009 17:59:46 +0000 (17:59 +0000)
committerbarnett <barnett@9efb377e-2e27-44b9-b91a-ec4abb80ed8b>
Fri, 25 Sep 2009 17:59:46 +0000 (17:59 +0000)
git-svn-id: svn+ssh://gene.bc.edu/home/subversion/Derek/BamTools/trunk@26 9efb377e-2e27-44b9-b91a-ec4abb80ed8b

BamAux.h
BamDumpMain.cpp
BamReader.cpp
BamReader.h

index 701f35a3527f41ae56f08a6d58e3e88ed931c88a..7f47afeb2f0f53bb065a6d3077d11609de90afbf 100644 (file)
--- a/BamAux.h
+++ b/BamAux.h
@@ -280,7 +280,8 @@ namespace BamTools {
                        std::vector<CigarOp> CigarData; //!< CIGAR operations for this alignment\r
                        unsigned int MateRefID;         //!< ID number for reference sequence where alignment's mate was aligned\r
                        unsigned int MatePosition;      //!< Position (0-based) where alignment's mate starts\r
-                       unsigned int InsertSize;        //!< Mate-pair insert size\r
+                       //unsigned int InsertSize;        //!< Mate-pair insert size\r
+                       signed int   InsertSize;                //!< Mate-pair insert size\r
                \r
                // Alignment flag query constants\r
                private:\r
index f76852af1827a9f9caa1e8290a4859df1d64f8db..2c31015a7a22540d28f1a8316524dd1ab9de457a 100644 (file)
@@ -50,6 +50,7 @@ int main(int argc, char* argv[]) {
 // Spit out basic BamAlignment data \r
 void PrintAlignment(const BamAlignment& alignment) {\r
        cout << "---------------------------------" << endl;\r
-       cout << "Name: " << alignment.Name << endl;\r
-       cout << "Aligned to: " << alignment.RefID << ":" << alignment.Position << endl;\r
+       cout << "Name: "       << alignment.Name << endl;\r
+       cout << "Aligned to: " << alignment.RefID;\r
+       cout << ":"            << alignment.Position << endl;\r
 }\r
index 4f0f36116000fce31c4e200b72cf9eaa6c1f2191..f9df5cf95dd93cf4398bcad277bbc0c77505f15b 100644 (file)
@@ -572,7 +572,8 @@ bool BamReader::LoadNextAlignment(BamAlignment& bAlignment) {
        querySequenceLength     = BgzfUnpackUnsignedInt(&x[16]);
        bAlignment.MateRefID    = BgzfUnpackUnsignedInt(&x[20]);
        bAlignment.MatePosition = BgzfUnpackUnsignedInt(&x[24]);
-       bAlignment.InsertSize   = BgzfUnpackUnsignedInt(&x[28]);
+       //bAlignment.InsertSize   = BgzfUnpackUnsignedInt(&x[28]);
+       bAlignment.InsertSize   = BgzfUnpackSignedInt(&x[28]);
 
        // calculate lengths/offsets
        const unsigned int dataLength      = blockLength - BAM_CORE_SIZE;
index a4a82e4f0a4182e79dbb92aaca0115d6eae505a9..ed8397db71d2c8719ab9857960b21e180a29c6c8 100644 (file)
@@ -181,6 +181,8 @@ namespace BamTools {
                        static inline unsigned int BgzfUnpackUnsignedInt(char* buffer);
                        // unpacks a buffer into an unsigned short
                        static inline unsigned short BgzfUnpackUnsignedShort(char* buffer);
+                       // unpacks a buffer into a signed int
+                       static inline signed int BgzfUnpackSignedInt(char* buffer);
                        // calculate bins that overlap region ( left to reference end for now )
                        int BinsFromRegion(int, unsigned int, uint16_t[MAX_BIN]);
                        // calculates alignment end position based on starting position and provided CIGAR operations
@@ -244,6 +246,16 @@ namespace BamTools {
                un.valueBuffer[1] = buffer[1];
                return un.value;
        }
+       
+       // unpacks a buffer into a signed int
+       inline signed int BamReader::BgzfUnpackSignedInt(char* buffer) {
+               union { signed int value; unsigned char valueBuffer[sizeof(signed int)]; } un;
+               un.valueBuffer[0] = buffer[0];
+               un.valueBuffer[1] = buffer[1];
+               un.valueBuffer[2] = buffer[2];
+               un.valueBuffer[3] = buffer[3];
+               return un.value;
+       }
 
        // --------------------------------------------------------------------------------------
        // template classes/methods (internal - can exclude from main documentation)