From 6f110ab8488bc8c6073561028dd5f386f9b4172a Mon Sep 17 00:00:00 2001 From: barnett Date: Thu, 1 Oct 2009 04:11:55 +0000 Subject: [PATCH] Modified BamAlignment data members to match BAM specs (signed vs unsigned ints) git-svn-id: svn+ssh://gene.bc.edu/home/subversion/Derek/BamTools/trunk@28 9efb377e-2e27-44b9-b91a-ec4abb80ed8b --- BamAux.h | 16 ++++++++++------ BamReader.cpp | 12 ++++++++---- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/BamAux.h b/BamAux.h index 7e46bd7..5784198 100644 --- a/BamAux.h +++ b/BamAux.h @@ -3,7 +3,7 @@ // Marth Lab, Department of Biology, Boston College // All rights reserved. // --------------------------------------------------------------------------- -// Last modified: 24 June 2009 (DB) +// Last modified: 1 October 2009 (DB) // --------------------------------------------------------------------------- // The BGZF routines were adapted from the bgzf.c code developed at the Broad // Institute. @@ -272,16 +272,20 @@ namespace BamTools { std::string AlignedBases; //!< 'Aligned' sequence (includes any indels, padding, clipping) std::string Qualities; //!< FASTQ qualities (ASCII characters, not numeric values) std::string TagData; //!< Tag data (accessor methods will pull the requested information out) - unsigned int RefID; //!< ID number for reference sequence - unsigned int Position; //!< Position (0-based) where alignment starts + //unsigned int RefID; //!< ID number for reference sequence + //unsigned int Position; //!< Position (0-based) where alignment starts + signed int RefID; //!< ID number for reference sequence (-1) + signed int Position; //!< Position (0-based) where alignment starts (-1) unsigned int Bin; //!< Bin in BAM file where this alignment resides unsigned int MapQuality; //!< Mapping quality score unsigned int AlignmentFlag; //!< Alignment bit-flag - see Is() methods for available queries std::vector CigarData; //!< CIGAR operations for this alignment - unsigned int MateRefID; //!< ID number for reference sequence where alignment's mate was aligned - unsigned int MatePosition; //!< Position (0-based) where alignment's mate starts + //unsigned int MateRefID; //!< ID number for reference sequence where alignment's mate was aligned + //unsigned int MatePosition; //!< Position (0-based) where alignment's mate starts //unsigned int InsertSize; //!< Mate-pair insert size - signed int InsertSize; //!< Mate-pair insert size + signed int MateRefID; //!< ID number for reference sequence where alignment's mate was aligned (-1) + signed int MatePosition; //!< Position (0-based) where alignment's mate starts (-1) + signed int InsertSize; //!< Mate-pair insert size(0) // Alignment flag query constants private: diff --git a/BamReader.cpp b/BamReader.cpp index f9df5cf..cdcf753 100644 --- a/BamReader.cpp +++ b/BamReader.cpp @@ -557,8 +557,10 @@ bool BamReader::LoadNextAlignment(BamAlignment& bAlignment) { unsigned int numCigarOperations; unsigned int querySequenceLength; - bAlignment.RefID = BgzfUnpackUnsignedInt(&x[0]); - bAlignment.Position = BgzfUnpackUnsignedInt(&x[4]); + //bAlignment.RefID = BgzfUnpackUnsignedInt(&x[0]); + //bAlignment.Position = BgzfUnpackUnsignedInt(&x[4]); + bAlignment.RefID = BgzfUnpackSignedInt(&x[0]); + bAlignment.Position = BgzfUnpackSignedInt(&x[4]); tempValue = BgzfUnpackUnsignedInt(&x[8]); bAlignment.Bin = tempValue >> 16; @@ -570,9 +572,11 @@ bool BamReader::LoadNextAlignment(BamAlignment& bAlignment) { numCigarOperations = tempValue & 0xffff; querySequenceLength = BgzfUnpackUnsignedInt(&x[16]); - bAlignment.MateRefID = BgzfUnpackUnsignedInt(&x[20]); - bAlignment.MatePosition = BgzfUnpackUnsignedInt(&x[24]); + //bAlignment.MateRefID = BgzfUnpackUnsignedInt(&x[20]); + //bAlignment.MatePosition = BgzfUnpackUnsignedInt(&x[24]); //bAlignment.InsertSize = BgzfUnpackUnsignedInt(&x[28]); + bAlignment.MateRefID = BgzfUnpackSignedInt(&x[20]); + bAlignment.MatePosition = BgzfUnpackSignedInt(&x[24]); bAlignment.InsertSize = BgzfUnpackSignedInt(&x[28]); // calculate lengths/offsets -- 2.39.5