From 31708e4a1ebc33e1171d027094e80440ae58e7fc Mon Sep 17 00:00:00 2001 From: Aaron <aaronquinlan@gmail.com> Date: Wed, 29 Jun 2011 10:22:54 -0400 Subject: [PATCH] Don't track BamTools/include --- src/utils/BamTools/include/api/BamAlignment.h | 207 -------- src/utils/BamTools/include/api/BamAux.h | 457 ------------------ src/utils/BamTools/include/api/BamConstants.h | 128 ----- src/utils/BamTools/include/api/BamIndex.h | 80 --- .../BamTools/include/api/BamMultiReader.h | 127 ----- src/utils/BamTools/include/api/BamReader.h | 118 ----- src/utils/BamTools/include/api/BamWriter.h | 64 --- src/utils/BamTools/include/api/SamConstants.h | 96 ---- src/utils/BamTools/include/api/SamHeader.h | 69 --- src/utils/BamTools/include/api/SamProgram.h | 62 --- .../BamTools/include/api/SamProgramChain.h | 86 ---- src/utils/BamTools/include/api/SamReadGroup.h | 69 --- .../include/api/SamReadGroupDictionary.h | 87 ---- src/utils/BamTools/include/api/SamSequence.h | 61 --- .../include/api/SamSequenceDictionary.h | 89 ---- src/utils/BamTools/include/api/api_global.h | 22 - .../BamTools/include/shared/bamtools_global.h | 79 --- 17 files changed, 1901 deletions(-) delete mode 100644 src/utils/BamTools/include/api/BamAlignment.h delete mode 100644 src/utils/BamTools/include/api/BamAux.h delete mode 100644 src/utils/BamTools/include/api/BamConstants.h delete mode 100644 src/utils/BamTools/include/api/BamIndex.h delete mode 100644 src/utils/BamTools/include/api/BamMultiReader.h delete mode 100644 src/utils/BamTools/include/api/BamReader.h delete mode 100644 src/utils/BamTools/include/api/BamWriter.h delete mode 100644 src/utils/BamTools/include/api/SamConstants.h delete mode 100644 src/utils/BamTools/include/api/SamHeader.h delete mode 100644 src/utils/BamTools/include/api/SamProgram.h delete mode 100644 src/utils/BamTools/include/api/SamProgramChain.h delete mode 100644 src/utils/BamTools/include/api/SamReadGroup.h delete mode 100644 src/utils/BamTools/include/api/SamReadGroupDictionary.h delete mode 100644 src/utils/BamTools/include/api/SamSequence.h delete mode 100644 src/utils/BamTools/include/api/SamSequenceDictionary.h delete mode 100644 src/utils/BamTools/include/api/api_global.h delete mode 100644 src/utils/BamTools/include/shared/bamtools_global.h diff --git a/src/utils/BamTools/include/api/BamAlignment.h b/src/utils/BamTools/include/api/BamAlignment.h deleted file mode 100644 index 7535d93f..00000000 --- a/src/utils/BamTools/include/api/BamAlignment.h +++ /dev/null @@ -1,207 +0,0 @@ -// *************************************************************************** -// BamAlignment.h (c) 2009 Derek Barnett -// Marth Lab, Department of Biology, Boston College -// All rights reserved. -// --------------------------------------------------------------------------- -// Last modified: 22 April 2011 (DB) -// --------------------------------------------------------------------------- -// Provides the BamAlignment data structure -// *************************************************************************** - -#ifndef BAMALIGNMENT_H -#define BAMALIGNMENT_H - -#include <api/api_global.h> -#include <api/BamAux.h> -#include <string> -#include <vector> - -namespace BamTools { - -// forward declaration of BamAlignment's friend classes -namespace Internal { - class BamReaderPrivate; - class BamWriterPrivate; -} // namespace Internal - -// BamAlignment data structure -struct API_EXPORT BamAlignment { - - // constructors & destructor - public: - BamAlignment(void); - BamAlignment(const BamAlignment& other); - ~BamAlignment(void); - - // queries against alignment flags - public: - bool IsDuplicate(void) const; // returns true if this read is a PCR duplicate - bool IsFailedQC(void) const; // returns true if this read failed quality control - bool IsFirstMate(void) const; // returns true if alignment is first mate on read - bool IsMapped(void) const; // returns true if alignment is mapped - bool IsMateMapped(void) const; // returns true if alignment's mate is mapped - bool IsMateReverseStrand(void) const; // returns true if alignment's mate mapped to reverse strand - bool IsPaired(void) const; // returns true if alignment part of paired-end read - bool IsPrimaryAlignment(void) const; // returns true if reported position is primary alignment - bool IsProperPair(void) const; // returns true if alignment is part of read that satisfied paired-end resolution - bool IsReverseStrand(void) const; // returns true if alignment mapped to reverse strand - bool IsSecondMate(void) const; // returns true if alignment is second mate on read - - // manipulate alignment flags - public: - void SetIsDuplicate(bool ok); // sets value of "PCR duplicate" flag - void SetIsFailedQC(bool ok); // sets value of "failed quality control" flag - void SetIsFirstMate(bool ok); // sets value of "alignment is first mate" flag - void SetIsMapped(bool ok); // sets value of "alignment is mapped" flag - void SetIsMateMapped(bool ok); // sets value of "alignment's mate is mapped" flag - void SetIsMateReverseStrand(bool ok); // sets value of "alignment's mate mapped to reverse strand" flag - void SetIsPaired(bool ok); // sets value of "alignment part of paired-end read" flag - void SetIsPrimaryAlignment(bool ok); // sets value of "position is primary alignment" flag - void SetIsProperPair(bool ok); // sets value of "alignment is part of read that satisfied paired-end resolution" flag - void SetIsReverseStrand(bool ok); // sets value of "alignment mapped to reverse strand" flag - void SetIsSecondMate(bool ok); // sets value of "alignment is second mate on read" flag - - // legacy methods (consider deprecated, but still available) - void SetIsMateUnmapped(bool ok); // complement of using SetIsMateMapped() - void SetIsSecondaryAlignment(bool ok); // complement of using SetIsPrimaryAlignment() - void SetIsUnmapped(bool ok); // complement of using SetIsMapped() - - // tag data access methods - public: - - // ------------------------------------------------------------------------------------- - // N.B. - The following tag access methods may not be used on BamAlignments fetched - // using BamReader::GetNextAlignmentCore(). Attempting to use them will not result in - // error message (to keep output clean) but will ALWAYS return false. Only user-created - // BamAlignments or those retrieved using BamReader::GetNextAlignment() are valid here. - // - // You can call BuildCharData() on such an alignment retrieved by GetNextAlignmentCore(). - // This populates all the character data, and will enable subsequent queries on tag data. - // ------------------------------------------------------------------------------------- - - // adds a tag - bool AddTag(const std::string& tag, const std::string& type, const std::string& value); - bool AddTag(const std::string& tag, const std::string& type, const uint32_t& value); - bool AddTag(const std::string& tag, const std::string& type, const int32_t& value); - bool AddTag(const std::string& tag, const std::string& type, const float& value); - - // adds a "binary array" tag - bool AddTag(const std::string& tag, const std::vector<uint8_t>& values); - bool AddTag(const std::string& tag, const std::vector<int8_t>& values); - bool AddTag(const std::string& tag, const std::vector<uint16_t>& values); - bool AddTag(const std::string& tag, const std::vector<int16_t>& values); - bool AddTag(const std::string& tag, const std::vector<uint32_t>& values); - bool AddTag(const std::string& tag, const std::vector<int32_t>& values); - bool AddTag(const std::string& tag, const std::vector<float>& values); - - // edits a tag - bool EditTag(const std::string& tag, const std::string& type, const std::string& value); - bool EditTag(const std::string& tag, const std::string& type, const uint32_t& value); - bool EditTag(const std::string& tag, const std::string& type, const int32_t& value); - bool EditTag(const std::string& tag, const std::string& type, const float& value); - - // edits a "binary array" tag - bool EditTag(const std::string& tag, const std::vector<uint8_t>& values); - bool EditTag(const std::string& tag, const std::vector<int8_t>& values); - bool EditTag(const std::string& tag, const std::vector<uint16_t>& values); - bool EditTag(const std::string& tag, const std::vector<int16_t>& values); - bool EditTag(const std::string& tag, const std::vector<uint32_t>& values); - bool EditTag(const std::string& tag, const std::vector<int32_t>& values); - bool EditTag(const std::string& tag, const std::vector<float>& values); - - // retrieves data for a tag - bool GetTag(const std::string& tag, std::string& destination) const; - bool GetTag(const std::string& tag, uint32_t& destination) const; - bool GetTag(const std::string& tag, int32_t& destination) const; - bool GetTag(const std::string& tag, float& destination) const; - - // retrieves data for a "binary array" tag - bool GetTag(const std::string& tag, std::vector<uint32_t>& destination) const; - bool GetTag(const std::string& tag, std::vector<int32_t>& destination) const; - bool GetTag(const std::string& tag, std::vector<float>& destination) const; - - // retrieves the BAM tag-type character for a tag - bool GetTagType(const std::string& tag, char& type) const; - - // legacy methods (consider deprecated, but still available) - bool GetEditDistance(uint32_t& editDistance) const; // retrieves value of "NM" tag - bool GetReadGroup(std::string& readGroup) const; // retrieves value of "RG" tag - - // returns true if alignment has a record for this tag name - bool HasTag(const std::string& tag) const; - - // removes a tag - bool RemoveTag(const std::string& tag); - - // additional methods - public: - // populates alignment string fields - bool BuildCharData(void); - // calculates alignment end position - int GetEndPosition(bool usePadded = false, bool zeroBased = true) 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 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 - int32_t Position; // position (0-based) where alignment starts - uint16_t Bin; // BAM (standard) index bin number for this alignment - uint16_t MapQuality; // mapping quality score - uint32_t AlignmentFlag; // alignment bit-flag (use provided methods to query/modify) - std::vector<CigarOp> CigarData; // CIGAR operations for this alignment - int32_t MateRefID; // ID number for reference sequence where alignment's mate was aligned - int32_t MatePosition; // position (0-based) where alignment's mate starts - int32_t InsertSize; // mate-pair insert size - std::string Filename; // name of BAM file which this alignment comes from - - //! \cond - // internal utility methods - private: - bool FindTag(const std::string& tag, - char*& pTagData, - const unsigned int& tagDataLength, - unsigned int& numBytesParsed) const; - bool IsValidSize(const std::string& tag, - const std::string& type) const; - bool SkipToNextTag(const char storageType, - char*& pTagData, - unsigned int& numBytesParsed) const; - - // internal data - private: - - struct BamAlignmentSupportData { - - // data members - std::string AllCharData; - uint32_t BlockLength; - uint32_t NumCigarOperations; - uint32_t QueryNameLength; - uint32_t QuerySequenceLength; - bool HasCoreOnly; - - // constructor - BamAlignmentSupportData(void) - : BlockLength(0) - , NumCigarOperations(0) - , QueryNameLength(0) - , QuerySequenceLength(0) - , HasCoreOnly(false) - { } - }; - BamAlignmentSupportData SupportData; - friend class Internal::BamReaderPrivate; - friend class Internal::BamWriterPrivate; - //! \endcond -}; - -typedef std::vector<BamAlignment> BamAlignmentVector; - -} // namespace BamTools - -#endif // BAMALIGNMENT_H diff --git a/src/utils/BamTools/include/api/BamAux.h b/src/utils/BamTools/include/api/BamAux.h deleted file mode 100644 index d171e706..00000000 --- a/src/utils/BamTools/include/api/BamAux.h +++ /dev/null @@ -1,457 +0,0 @@ -// *************************************************************************** -// BamAux.h (c) 2009 Derek Barnett, Michael Str�mberg -// Marth Lab, Department of Biology, Boston College -// All rights reserved. -// --------------------------------------------------------------------------- -// Last modified: 4 March 2011 (DB) -// --------------------------------------------------------------------------- -// Provides data structures & utility methods that are used throughout the API. -// *************************************************************************** - -#ifndef BAMAUX_H -#define BAMAUX_H - -#include <api/api_global.h> -#include <fstream> -#include <iostream> -#include <string> -#include <vector> - -/*! \file BamAux.h - - Provides data structures & utility methods that are used throughout the API. -*/ -/*! \namespace BamTools - \brief Contains all BamTools classes & methods. - - The BamTools API contained in this namespace contains classes and methods - for reading, writing, and manipulating BAM alignment files. -*/ -namespace BamTools { - -// ---------------------------------------------------------------- -// CigarOp - -/*! \struct BamTools::CigarOp - \brief Represents a CIGAR alignment operation. - - \sa http://samtools.sourceforge.net/SAM-1.3.pdf for more details on using CIGAR operations. -*/ -struct API_EXPORT CigarOp { - - char Type; //!< CIGAR operation type (MIDNSHP) - uint32_t Length; //!< CIGAR operation length (number of bases) - - //! constructor - CigarOp(const char type = '\0', - const uint32_t& length = 0) - : Type(type) - , Length(length) - { } -}; - -// ---------------------------------------------------------------- -// RefData - -/*! \struct BamTools::RefData - \brief Represents a reference sequence entry -*/ -struct API_EXPORT RefData { - - std::string RefName; //!< name of reference sequence - int32_t RefLength; //!< length of reference sequence - - //! constructor - RefData(const std::string& name = "", - const int32_t& length = 0) - : RefName(name) - , RefLength(length) - { } -}; - -//! convenience typedef for vector of RefData entries -typedef std::vector<RefData> RefVector; - -// ---------------------------------------------------------------- -// BamRegion - -/*! \struct BamTools::BamRegion - \brief Represents a sequential genomic region - - Allowed to span multiple (sequential) references. -*/ -struct API_EXPORT BamRegion { - - int LeftRefID; //!< reference ID for region's left boundary - int LeftPosition; //!< position for region's left boundary - int RightRefID; //!< reference ID for region's right boundary - int RightPosition; //!< position for region's right boundary - - //! constructor - BamRegion(const int& leftID = -1, - const int& leftPos = -1, - const int& rightID = -1, - const int& rightPos = -1) - : LeftRefID(leftID) - , LeftPosition(leftPos) - , RightRefID(rightID) - , RightPosition(rightPos) - { } - - //! copy constructor - BamRegion(const BamRegion& other) - : LeftRefID(other.LeftRefID) - , LeftPosition(other.LeftPosition) - , RightRefID(other.RightRefID) - , RightPosition(other.RightPosition) - { } - - //! Clears region boundaries - void clear(void) { - LeftRefID = -1; LeftPosition = -1; - RightRefID = -1; RightPosition = -1; - } - - //! Returns true if region has a left boundary - bool isLeftBoundSpecified(void) const { - return ( LeftRefID >= 0 && LeftPosition >= 0 ); - } - - //! Returns true if region boundaries are not defined - bool isNull(void) const { - return ( !isLeftBoundSpecified() && !isRightBoundSpecified() ); - } - - //! Returns true if region has a right boundary - bool isRightBoundSpecified(void) const { - return ( RightRefID >= 0 && RightPosition >= 0 ); - } -}; - -// ---------------------------------------------------------------- -// General utility methods - -/*! \fn bool FileExists(const std::string& filename) - \brief checks if file exists - - Attempts to open file in a read-only mode. - - \return \c true if file can be opened successfully -*/ -API_EXPORT inline bool FileExists(const std::string& filename) { - std::ifstream f(filename.c_str(), std::ifstream::in); - return !f.fail(); -} - -/*! \fn void SwapEndian_16(int16_t& x) - \brief swaps endianness of signed 16-bit integer, in place - - Swaps endian representation of value in \a x. -*/ -API_EXPORT inline void SwapEndian_16(int16_t& x) { - x = ((x >> 8) | (x << 8)); -} - -/*! \fn void SwapEndian_16(uint16_t& x) - \brief swaps endianness of unsigned 16-bit integer, in place - - Swaps endian representation of value in \a x. -*/ -API_EXPORT inline void SwapEndian_16(uint16_t& x) { - x = ((x >> 8) | (x << 8)); -} - -/*! \fn void SwapEndian_32(int32_t& x) - \brief swaps endianness of signed 32-bit integer, in place - - Swaps endian representation of value in \a x. -*/ -API_EXPORT inline void SwapEndian_32(int32_t& x) { - x = ( (x >> 24) | - ((x << 8) & 0x00FF0000) | - ((x >> 8) & 0x0000FF00) | - (x << 24) - ); -} - -/*! \fn void SwapEndian_32(uint32_t& x) - \brief swaps endianness of unsigned 32-bit integer, in place - - Swaps endian representation of value in \a x. -*/ -API_EXPORT inline void SwapEndian_32(uint32_t& x) { - x = ( (x >> 24) | - ((x << 8) & 0x00FF0000) | - ((x >> 8) & 0x0000FF00) | - (x << 24) - ); -} - -/*! \fn void SwapEndian_64(int64_t& x) - \brief swaps endianness of signed 64-bit integer, in place - - Swaps endian representation of value in \a x. -*/ -API_EXPORT inline void SwapEndian_64(int64_t& x) { - x = ( (x >> 56) | - ((x << 40) & 0x00FF000000000000ll) | - ((x << 24) & 0x0000FF0000000000ll) | - ((x << 8) & 0x000000FF00000000ll) | - ((x >> 8) & 0x00000000FF000000ll) | - ((x >> 24) & 0x0000000000FF0000ll) | - ((x >> 40) & 0x000000000000FF00ll) | - (x << 56) - ); -} - -/*! \fn void SwapEndian_64(uint64_t& x) - \brief swaps endianness of unsigned 64-bit integer, in place - - Swaps endian representation of value in \a x. -*/ -API_EXPORT inline void SwapEndian_64(uint64_t& x) { - x = ( (x >> 56) | - ((x << 40) & 0x00FF000000000000ll) | - ((x << 24) & 0x0000FF0000000000ll) | - ((x << 8) & 0x000000FF00000000ll) | - ((x >> 8) & 0x00000000FF000000ll) | - ((x >> 24) & 0x0000000000FF0000ll) | - ((x >> 40) & 0x000000000000FF00ll) | - (x << 56) - ); -} - -/*! \fn void SwapEndian_16p(char* data) - \brief swaps endianness of the next 2 bytes in a buffer, in place - - Swaps endian representation the next 2 bytes in \a data. -*/ -API_EXPORT inline void SwapEndian_16p(char* data) { - uint16_t& value = (uint16_t&)*data; - SwapEndian_16(value); -} - -/*! \fn void SwapEndian_32p(char* data) - \brief swaps endianness of the next 4 bytes in a buffer, in place - - Swaps endian representation the next 4 bytes in \a data. -*/ -API_EXPORT inline void SwapEndian_32p(char* data) { - uint32_t& value = (uint32_t&)*data; - SwapEndian_32(value); -} - -/*! \fn void SwapEndian_64p(char* data) - \brief swaps endianness of the next 8 bytes in a buffer, in place - - Swaps endian representation the next 8 bytes in \a data. -*/ -API_EXPORT inline void SwapEndian_64p(char* data) { - uint64_t& value = (uint64_t&)*data; - SwapEndian_64(value); -} - -/*! \fn bool SystemIsBigEndian(void) - \brief checks host architecture's byte order - \return \c true if system uses big-endian ordering -*/ -API_EXPORT inline bool SystemIsBigEndian(void) { - const uint16_t one = 0x0001; - return ((*(char*) &one) == 0 ); -} - -/*! \fn void PackUnsignedInt(char* buffer, unsigned int value) - \brief stores unsigned integer value in a byte buffer - - \param buffer destination buffer - \param value unsigned integer to 'pack' in buffer -*/ -API_EXPORT inline void PackUnsignedInt(char* buffer, unsigned int value) { - buffer[0] = (char)value; - buffer[1] = (char)(value >> 8); - buffer[2] = (char)(value >> 16); - buffer[3] = (char)(value >> 24); -} - -/*! \fn void PackUnsignedShort(char* buffer, unsigned short value) - \brief stores unsigned short integer value in a byte buffer - - \param buffer destination buffer - \param value unsigned short integer to 'pack' in buffer -*/ -API_EXPORT inline void PackUnsignedShort(char* buffer, unsigned short value) { - buffer[0] = (char)value; - buffer[1] = (char)(value >> 8); -} - -/*! \fn double UnpackDouble(const char* buffer) - \brief reads a double value from byte buffer - - \param buffer source byte buffer - \return the (double) value read from the buffer -*/ -API_EXPORT inline double UnpackDouble(const char* buffer) { - union { double value; unsigned char valueBuffer[sizeof(double)]; } un; - un.value = 0; - un.valueBuffer[0] = buffer[0]; - un.valueBuffer[1] = buffer[1]; - un.valueBuffer[2] = buffer[2]; - un.valueBuffer[3] = buffer[3]; - un.valueBuffer[4] = buffer[4]; - un.valueBuffer[5] = buffer[5]; - un.valueBuffer[6] = buffer[6]; - un.valueBuffer[7] = buffer[7]; - return un.value; -} - -/*! \fn double UnpackDouble(char* buffer) - \brief reads a double value from byte buffer - - This is an overloaded function. - - \param buffer source byte buffer - \return the (double) value read from the buffer -*/ -API_EXPORT inline double UnpackDouble(char* buffer) { - return UnpackDouble( (const char*)buffer ); -} - -/*! \fn double UnpackFloat(const char* buffer) - \brief reads a float value from byte buffer - - \param buffer source byte buffer - \return the (float) value read from the buffer -*/ -API_EXPORT inline float UnpackFloat(const char* buffer) { - union { float value; unsigned char valueBuffer[sizeof(float)]; } un; - un.value = 0; - un.valueBuffer[0] = buffer[0]; - un.valueBuffer[1] = buffer[1]; - un.valueBuffer[2] = buffer[2]; - un.valueBuffer[3] = buffer[3]; - return un.value; -} - -/*! \fn double UnpackFloat(char* buffer) - \brief reads a float value from byte buffer - - This is an overloaded function. - - \param buffer source byte buffer - \return the (float) value read from the buffer -*/ -API_EXPORT inline float UnpackFloat(char* buffer) { - return UnpackFloat( (const char*)buffer ); -} - -/*! \fn signed int UnpackSignedInt(const char* buffer) - \brief reads a signed integer value from byte buffer - - \param buffer source byte buffer - \return the (signed int) value read from the buffer -*/ -API_EXPORT inline signed int UnpackSignedInt(const char* buffer) { - union { signed int value; unsigned char valueBuffer[sizeof(signed int)]; } un; - un.value = 0; - un.valueBuffer[0] = buffer[0]; - un.valueBuffer[1] = buffer[1]; - un.valueBuffer[2] = buffer[2]; - un.valueBuffer[3] = buffer[3]; - return un.value; -} - -/*! \fn signed int UnpackSignedInt(char* buffer) - \brief reads a signed integer value from byte buffer - - This is an overloaded function. - - \param buffer source byte buffer - \return the (signed int) value read from the buffer -*/ -API_EXPORT inline signed int UnpackSignedInt(char* buffer) { - return UnpackSignedInt( (const char*) buffer ); -} - -/*! \fn signed short UnpackSignedShort(const char* buffer) - \brief reads a signed short integer value from byte buffer - - \param buffer source byte buffer - \return the (signed short) value read from the buffer -*/ -API_EXPORT inline signed short UnpackSignedShort(const char* buffer) { - union { signed short value; unsigned char valueBuffer[sizeof(signed short)]; } un; - un.value = 0; - un.valueBuffer[0] = buffer[0]; - un.valueBuffer[1] = buffer[1]; - return un.value; -} - -/*! \fn signed short UnpackSignedShort(char* buffer) - \brief reads a signed short integer value from byte buffer - - This is an overloaded function. - - \param buffer source byte buffer - \return the (signed short) value read from the buffer -*/ -API_EXPORT inline signed short UnpackSignedShort(char* buffer) { - return UnpackSignedShort( (const char*)buffer ); -} - -/*! \fn unsigned int UnpackUnsignedInt(const char* buffer) - \brief reads an unsigned integer value from byte buffer - - \param buffer source byte buffer - \return the (unsigned int) value read from the buffer -*/ -API_EXPORT inline unsigned int UnpackUnsignedInt(const char* buffer) { - union { unsigned int value; unsigned char valueBuffer[sizeof(unsigned int)]; } un; - un.value = 0; - un.valueBuffer[0] = buffer[0]; - un.valueBuffer[1] = buffer[1]; - un.valueBuffer[2] = buffer[2]; - un.valueBuffer[3] = buffer[3]; - return un.value; -} - -/*! \fn unsigned int UnpackUnsignedInt(char* buffer) - \brief reads an unsigned integer value from byte buffer - - This is an overloaded function. - - \param buffer source byte buffer - \return the (unsigned int) value read from the buffer -*/ -API_EXPORT inline unsigned int UnpackUnsignedInt(char* buffer) { - return UnpackUnsignedInt( (const char*)buffer ); -} - -/*! \fn unsigned short UnpackUnsignedShort(const char* buffer) - \brief reads an unsigned short integer value from byte buffer - - \param buffer source byte buffer - \return the (unsigned short) value read from the buffer -*/ -API_EXPORT inline unsigned short UnpackUnsignedShort(const char* buffer) { - union { unsigned short value; unsigned char valueBuffer[sizeof(unsigned short)]; } un; - un.value = 0; - un.valueBuffer[0] = buffer[0]; - un.valueBuffer[1] = buffer[1]; - return un.value; -} - -/*! \fn unsigned short UnpackUnsignedShort(char* buffer) - \brief reads an unsigned short integer value from byte buffer - - This is an overloaded function. - - \param buffer source byte buffer - \return the (unsigned short) value read from the buffer -*/ -API_EXPORT inline unsigned short UnpackUnsignedShort(char* buffer) { - return UnpackUnsignedShort( (const char*)buffer ); -} - -} // namespace BamTools - -#endif // BAMAUX_H diff --git a/src/utils/BamTools/include/api/BamConstants.h b/src/utils/BamTools/include/api/BamConstants.h deleted file mode 100644 index e433c8e7..00000000 --- a/src/utils/BamTools/include/api/BamConstants.h +++ /dev/null @@ -1,128 +0,0 @@ -// *************************************************************************** -// BamConstants.h (c) 2011 Derek Barnett -// Marth Lab, Department of Biology, Boston College -// All rights reserved. -// --------------------------------------------------------------------------- -// Last modified: 19 April 2011 (DB) -// --------------------------------------------------------------------------- -// Provides basic constants for handling BAM files. -// *************************************************************************** - -#ifndef BAM_CONSTANTS_H -#define BAM_CONSTANTS_H - -#include <string> - -/*! \namespace BamTools::Constants - \brief Provides basic constants for handling BAM files. -*/ - -namespace BamTools { -namespace Constants { - -const int BAM_SIZEOF_INT = 4; - -// header magic number -const char* const BAM_HEADER_MAGIC = "BAM\1"; -const unsigned int BAM_HEADER_MAGIC_LENGTH = 4; - -// BAM alignment core size -const int BAM_CORE_SIZE = 32; -const int BAM_CORE_BUFFER_SIZE = 8; - -// BAM alignment flags -const int BAM_ALIGNMENT_PAIRED = 0x0001; -const int BAM_ALIGNMENT_PROPER_PAIR = 0x0002; -const int BAM_ALIGNMENT_UNMAPPED = 0x0004; -const int BAM_ALIGNMENT_MATE_UNMAPPED = 0x0008; -const int BAM_ALIGNMENT_REVERSE_STRAND = 0x0010; -const int BAM_ALIGNMENT_MATE_REVERSE_STRAND = 0x0020; -const int BAM_ALIGNMENT_READ_1 = 0x0040; -const int BAM_ALIGNMENT_READ_2 = 0x0080; -const int BAM_ALIGNMENT_SECONDARY = 0x0100; -const int BAM_ALIGNMENT_QC_FAILED = 0x0200; -const int BAM_ALIGNMENT_DUPLICATE = 0x0400; - -// CIGAR constants -const char* const BAM_CIGAR_LOOKUP = "MIDNSHP=X"; -const int BAM_CIGAR_MATCH = 0; -const int BAM_CIGAR_INS = 1; -const int BAM_CIGAR_DEL = 2; -const int BAM_CIGAR_REFSKIP = 3; -const int BAM_CIGAR_SOFTCLIP = 4; -const int BAM_CIGAR_HARDCLIP = 5; -const int BAM_CIGAR_PAD = 6; -const int BAM_CIGAR_SEQMATCH = 7; -const int BAM_CIGAR_MISMATCH = 8; - -const char BAM_CIGAR_MATCH_CHAR = 'M'; -const char BAM_CIGAR_INS_CHAR = 'I'; -const char BAM_CIGAR_DEL_CHAR = 'D'; -const char BAM_CIGAR_REFSKIP_CHAR = 'N'; -const char BAM_CIGAR_SOFTCLIP_CHAR = 'S'; -const char BAM_CIGAR_HARDCLIP_CHAR = 'H'; -const char BAM_CIGAR_PAD_CHAR = 'P'; -const char BAM_CIGAR_SEQMATCH_CHAR = '='; -const char BAM_CIGAR_MISMATCH_CHAR = 'X'; - -const int BAM_CIGAR_SHIFT = 4; -const int BAM_CIGAR_MASK = ((1 << BAM_CIGAR_SHIFT) - 1); - -// BAM tag types -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_FLOAT = 'f'; -const char BAM_TAG_TYPE_STRING = 'Z'; -const char BAM_TAG_TYPE_HEX = 'H'; -const char BAM_TAG_TYPE_ARRAY = 'B'; - -const size_t BAM_TAG_TAGSIZE = 2; -const size_t BAM_TAG_TYPESIZE = 1; -const int BAM_TAG_ARRAYBASE_SIZE = 8; - -// DNA bases -const char* const BAM_DNA_LOOKUP = "=ACMGRSVTWYHKDBN"; -const unsigned char BAM_BASECODE_EQUAL = 0; -const unsigned char BAM_BASECODE_A = 1; -const unsigned char BAM_BASECODE_C = 2; -const unsigned char BAM_BASECODE_G = 4; -const unsigned char BAM_BASECODE_T = 8; -const unsigned char BAM_BASECODE_N = 15; - -const char BAM_DNA_EQUAL = '='; -const char BAM_DNA_A = 'A'; -const char BAM_DNA_C = 'C'; -const char BAM_DNA_G = 'G'; -const char BAM_DNA_T = 'T'; -const char BAM_DNA_N = 'N'; -const char BAM_DNA_DEL = '-'; -const char BAM_DNA_PAD = '*'; - -// zlib constants -const int GZIP_ID1 = 31; -const int GZIP_ID2 = 139; -const int CM_DEFLATE = 8; -const int FLG_FEXTRA = 4; -const int OS_UNKNOWN = 255; -const int BGZF_XLEN = 6; -const int BGZF_ID1 = 66; -const int BGZF_ID2 = 67; -const int BGZF_LEN = 2; -const int GZIP_WINDOW_BITS = -15; -const int Z_DEFAULT_MEM_LEVEL = 8; - -// BZGF constants -const int BGZF_BLOCK_HEADER_LENGTH = 18; -const int BGZF_BLOCK_FOOTER_LENGTH = 8; -const int BGZF_MAX_BLOCK_SIZE = 65536; -const int BGZF_DEFAULT_BLOCK_SIZE = 65536; - -} // namespace Constants -} // namespace BamTools - -#endif // BAM_CONSTANTS_H diff --git a/src/utils/BamTools/include/api/BamIndex.h b/src/utils/BamTools/include/api/BamIndex.h deleted file mode 100644 index 00a8f017..00000000 --- a/src/utils/BamTools/include/api/BamIndex.h +++ /dev/null @@ -1,80 +0,0 @@ -// *************************************************************************** -// BamIndex.h (c) 2009 Derek Barnett -// Marth Lab, Department of Biology, Boston College -// All rights reserved. -// --------------------------------------------------------------------------- -// Last modified: 5 April 2011 (DB) -// --------------------------------------------------------------------------- -// Provides basic BAM index interface -// *************************************************************************** - -#ifndef BAM_INDEX_H -#define BAM_INDEX_H - -#include <api/api_global.h> -#include <api/BamAux.h> -#include <string> - -namespace BamTools { - -namespace Internal { - class BamReaderPrivate; -} // namespace Internal - -/*! \class BamTools::BamIndex - \brief Provides methods for generating & loading BAM index files. - - This class straddles the line between public API and internal - implementation detail. Most client code should never have to use this - class directly. - - It is exposed to the public API to allow advanced users to implement - their own custom indexing schemes. - - More documentation on methods & enums coming soon. -*/ - -class API_EXPORT BamIndex { - - // enums - public: - // specify index-caching behavior - enum IndexCacheMode { FullIndexCaching = 0 // store entire index file contents in memory - , LimitedIndexCaching // store only index data for current reference - , NoIndexCaching // do not store any index data between jumps - }; - - // list of supported BamIndex types - enum IndexType { BAMTOOLS = 0 - , STANDARD - }; - - // ctor & dtor - public: - BamIndex(Internal::BamReaderPrivate* reader) : m_reader(reader) { } - virtual ~BamIndex(void) { } - - // index interface - public: - // builds index from associated BAM file & writes out to index file - virtual bool Create(void) =0; // creates index file from BAM file - // returns whether reference has alignments or no - virtual bool HasAlignments(const int& referenceID) const =0; - // attempts to use index data to jump to @region, returns success/fail - // a "successful" jump indicates no error, but not whether this region has data - // * thus, the method sets a flag to indicate whether there are alignments - // available after the jump position - virtual bool Jump(const BamTools::BamRegion& region, bool* hasAlignmentsInRegion) =0; - // loads existing data from file into memory - virtual bool Load(const std::string& filename) =0; - // change the index caching behavior - virtual void SetCacheMode(const BamIndex::IndexCacheMode& mode) =0; - - // data members - protected: - Internal::BamReaderPrivate* m_reader; // copy, not ownedprivate: -}; - -} // namespace BamTools - -#endif // BAM_INDEX_H diff --git a/src/utils/BamTools/include/api/BamMultiReader.h b/src/utils/BamTools/include/api/BamMultiReader.h deleted file mode 100644 index cc49ec8e..00000000 --- a/src/utils/BamTools/include/api/BamMultiReader.h +++ /dev/null @@ -1,127 +0,0 @@ -// *************************************************************************** -// BamMultiReader.h (c) 2010 Erik Garrison, Derek Barnett -// Marth Lab, Department of Biology, Boston College -// All rights reserved. -// --------------------------------------------------------------------------- -// Last modified: 15 March 2011 (DB) -// --------------------------------------------------------------------------- -// Convenience class for reading multiple BAM files. -// *************************************************************************** - -#ifndef BAMMULTIREADER_H -#define BAMMULTIREADER_H - -#include <api/api_global.h> -#include <api/BamReader.h> -#include <map> -#include <sstream> -#include <string> -#include <utility> - -namespace BamTools { - -namespace Internal { - class BamMultiReaderPrivate; -} // namespace Internal - -class API_EXPORT BamMultiReader { - - public: - enum SortOrder { SortedByPosition = 0 - , SortedByReadName - , Unsorted - }; - - // constructor / destructor - public: - BamMultiReader(void); - ~BamMultiReader(void); - - // public interface - public: - - // ---------------------- - // BAM file operations - // ---------------------- - - // closes all open BAM files - void Close(void); - // close only the requested BAM file - void CloseFile(const std::string& filename); - // returns list of filenames for all open BAM files - const std::vector<std::string> Filenames(void) const; - // returns true if multireader has any open BAM files - bool HasOpenReaders(void) const; - // performs random-access jump within current BAM files - bool Jump(int refID, int position = 0); - // opens BAM files - bool Open(const std::vector<std::string>& filenames); - // opens a single BAM file, adding to any other current BAM files - bool OpenFile(const std::string& filename); - // returns file pointers to beginning of alignments - bool Rewind(void); - // sets the target region of interest - bool SetRegion(const BamRegion& region); - // sets the target region of interest - bool SetRegion(const int& leftRefID, - const int& leftPosition, - const int& rightRefID, - const int& rightPosition); - - // ---------------------- - // access alignment data - // ---------------------- - - // retrieves next available alignment - bool GetNextAlignment(BamAlignment& alignment); - // retrieves next available alignmnet (without populating the alignment's string data fields) - bool GetNextAlignmentCore(BamAlignment& alignment); - - // sets the expected sorting order for reading across multiple BAM files - void SetSortOrder(const SortOrder& order); - - // ---------------------- - // access auxiliary data - // ---------------------- - - // returns unified SAM header for all files - SamHeader GetHeader(void) const; - // returns unified SAM header text for all files - std::string GetHeaderText(void) const; - // returns number of reference sequences - int GetReferenceCount(void) const; - // returns all reference sequence entries. - const BamTools::RefVector GetReferenceData(void) const; - // returns the ID of the reference with this name. - int GetReferenceID(const std::string& refName) const; - - // ---------------------- - // BAM index operations - // ---------------------- - - // creates index files for current BAM files - bool CreateIndexes(const BamIndex::IndexType& type = BamIndex::STANDARD); - // returns true if all BAM files have index data available - bool HasIndexes(void) const; - // looks for index files that match current BAM files - bool LocateIndexes(const BamIndex::IndexType& preferredType = BamIndex::STANDARD); - // opens index files for current BAM files. - bool OpenIndexes(const std::vector<std::string>& indexFilenames); - // changes the caching behavior of the index data - void SetIndexCacheMode(const BamIndex::IndexCacheMode& mode); - - // deprecated methods - public: - // returns \c true if all BAM files have index data available. - bool IsIndexLoaded(void) const; - // convenience method for printing filenames to stdout - void PrintFilenames(void) const; - - // private implementation - private: - Internal::BamMultiReaderPrivate* d; -}; - -} // namespace BamTools - -#endif // BAMMULTIREADER_H diff --git a/src/utils/BamTools/include/api/BamReader.h b/src/utils/BamTools/include/api/BamReader.h deleted file mode 100644 index 85b0c0d5..00000000 --- a/src/utils/BamTools/include/api/BamReader.h +++ /dev/null @@ -1,118 +0,0 @@ -// *************************************************************************** -// BamReader.h (c) 2009 Derek Barnett, Michael Str�mberg -// Marth Lab, Department of Biology, Boston College -// All rights reserved. -// --------------------------------------------------------------------------- -// Last modified: 4 March 2011 (DB) -// --------------------------------------------------------------------------- -// Provides read access to BAM files. -// *************************************************************************** - -#ifndef BAMREADER_H -#define BAMREADER_H - -#include <api/api_global.h> -#include <api/BamAlignment.h> -#include <api/BamIndex.h> -#include <api/SamHeader.h> -#include <string> - -namespace BamTools { - -namespace Internal { - class BamReaderPrivate; -} // namespace Internal - -class API_EXPORT BamReader { - - // constructor / destructor - public: - BamReader(void); - ~BamReader(void); - - // public interface - public: - - // ---------------------- - // BAM file operations - // ---------------------- - - // closes the current BAM file - void Close(void); - // returns filename of current BAM file - const std::string GetFilename(void) const; - // returns true if a BAM file is open for reading - bool IsOpen(void) const; - // performs random-access jump within BAM file - bool Jump(int refID, int position = 0); - // opens a BAM file - bool Open(const std::string& filename); - // returns internal file pointer to beginning of alignment data - bool Rewind(void); - // sets the target region of interest - bool SetRegion(const BamRegion& region); - // sets the target region of interest - bool SetRegion(const int& leftRefID, - const int& leftPosition, - const int& rightRefID, - const int& rightPosition); - - // ---------------------- - // access alignment data - // ---------------------- - - // retrieves next available alignment - bool GetNextAlignment(BamAlignment& alignment); - // retrieves next available alignmnet (without populating the alignment's string data fields) - bool GetNextAlignmentCore(BamAlignment& alignment); - - // ---------------------- - // access header data - // ---------------------- - - // returns SAM header data - SamHeader GetHeader(void) const; - // returns SAM header data, as SAM-formatted text - std::string GetHeaderText(void) const; - - // ---------------------- - // access reference data - // ---------------------- - - // returns the number of reference sequences - int GetReferenceCount(void) const; - // returns all reference sequence entries - const RefVector& GetReferenceData(void) const; - // returns the ID of the reference with this name - int GetReferenceID(const std::string& refName) const; - - // ---------------------- - // BAM index operations - // ---------------------- - - // creates an index file for current BAM file, using the requested index type - bool CreateIndex(const BamIndex::IndexType& type = BamIndex::STANDARD); - // returns true if index data is available - bool HasIndex(void) const; - // looks in BAM file's directory for a matching index file - bool LocateIndex(const BamIndex::IndexType& preferredType = BamIndex::STANDARD); - // opens a BAM index file - bool OpenIndex(const std::string& indexFilename); - // sets a custom BamIndex on this reader - void SetIndex(BamIndex* index); - // changes the caching behavior of the index data - void SetIndexCacheMode(const BamIndex::IndexCacheMode& mode); - - // deprecated methods - public: - // returns true if index data is available - bool IsIndexLoaded(void) const; - - // private implementation - private: - Internal::BamReaderPrivate* d; -}; - -} // namespace BamTools - -#endif // BAMREADER_H diff --git a/src/utils/BamTools/include/api/BamWriter.h b/src/utils/BamTools/include/api/BamWriter.h deleted file mode 100644 index 476dbecf..00000000 --- a/src/utils/BamTools/include/api/BamWriter.h +++ /dev/null @@ -1,64 +0,0 @@ -// *************************************************************************** -// BamWriter.h (c) 2009 Michael Str�mberg, Derek Barnett -// Marth Lab, Department of Biology, Boston College -// All rights reserved. -// --------------------------------------------------------------------------- -// Last modified: 4 March 2011 (DB) -// --------------------------------------------------------------------------- -// Provides the basic functionality for producing BAM files -// *************************************************************************** - -#ifndef BAMWRITER_H -#define BAMWRITER_H - -#include <api/api_global.h> -#include <api/BamAux.h> -#include <string> - -namespace BamTools { - -class BamAlignment; -class SamHeader; - -namespace Internal { - class BamWriterPrivate; -} // namespace Internal - -class API_EXPORT BamWriter { - - public: enum CompressionMode { Compressed = 0 - , Uncompressed - }; - - // ctor & dtor - public: - BamWriter(void); - ~BamWriter(void); - - // public interface - public: - // closes the current BAM file - void Close(void); - // returns true if BAM file is open for writing - bool IsOpen(void) const; - // opens a BAM file for writing - bool Open(const std::string& filename, - const std::string& samHeaderText, - const RefVector& referenceSequences); - // opens a BAM file for writing - bool Open(const std::string& filename, - const SamHeader& samHeader, - const RefVector& referenceSequences); - // saves the alignment to the alignment archive - void SaveAlignment(const BamAlignment& alignment); - // sets the output compression mode - void SetCompressionMode(const CompressionMode& compressionMode); - - // private implementation - private: - Internal::BamWriterPrivate* d; -}; - -} // namespace BamTools - -#endif // BAMWRITER_H diff --git a/src/utils/BamTools/include/api/SamConstants.h b/src/utils/BamTools/include/api/SamConstants.h deleted file mode 100644 index d3459202..00000000 --- a/src/utils/BamTools/include/api/SamConstants.h +++ /dev/null @@ -1,96 +0,0 @@ -// *************************************************************************** -// SamConstants.h (c) 2010 Derek Barnett -// Marth Lab, Department of Biology, Boston College -// All rights reserved. -// --------------------------------------------------------------------------- -// Last modified: 19 April 2011 (DB) -// --------------------------------------------------------------------------- -// Provides constants for SAM header -// *************************************************************************** - -#ifndef SAM_CONSTANTS_H -#define SAM_CONSTANTS_H - -#include <api/api_global.h> -#include <string> - -namespace BamTools { -namespace Constants { - -// basic char constants used in SAM format -const char SAM_COLON = ':'; -const char SAM_EQUAL = '='; -const char SAM_PERIOD = '.'; -const char SAM_STAR = '*'; -const char SAM_TAB = '\t'; -const std::string SAM_DIGITS = "0123456789"; - -// HD entries -const std::string SAM_HD_BEGIN_TOKEN = "@HD"; -const std::string SAM_HD_VERSION_TAG = "VN"; -const std::string SAM_HD_SORTORDER_TAG = "SO"; -const std::string SAM_HD_GROUPORDER_TAG = "GO"; - -// SQ entries -const std::string SAM_SQ_BEGIN_TOKEN = "@SQ"; -const std::string SAM_SQ_ASSEMBLYID_TAG = "AS"; -const std::string SAM_SQ_CHECKSUM_TAG = "M5"; -const std::string SAM_SQ_LENGTH_TAG = "LN"; -const std::string SAM_SQ_NAME_TAG = "SN"; -const std::string SAM_SQ_SPECIES_TAG = "SP"; -const std::string SAM_SQ_URI_TAG = "UR"; - -// RG entries -const std::string SAM_RG_BEGIN_TOKEN = "@RG"; -const std::string SAM_RG_DESCRIPTION_TAG = "DS"; -const std::string SAM_RG_FLOWORDER_TAG = "FO"; -const std::string SAM_RG_ID_TAG = "ID"; -const std::string SAM_RG_KEYSEQUENCE_TAG = "KS"; -const std::string SAM_RG_LIBRARY_TAG = "LB"; -const std::string SAM_RG_PLATFORMUNIT_TAG = "PU"; -const std::string SAM_RG_PREDICTEDINSERTSIZE_TAG = "PI"; -const std::string SAM_RG_PRODUCTIONDATE_TAG = "DT"; -const std::string SAM_RG_PROGRAM_TAG = "PG"; -const std::string SAM_RG_SAMPLE_TAG = "SM"; -const std::string SAM_RG_SEQCENTER_TAG = "CN"; -const std::string SAM_RG_SEQTECHNOLOGY_TAG = "PL"; - -// PG entries -const std::string SAM_PG_BEGIN_TOKEN = "@PG"; -const std::string SAM_PG_COMMANDLINE_TAG = "CL"; -const std::string SAM_PG_ID_TAG = "ID"; -const std::string SAM_PG_NAME_TAG = "PN"; -const std::string SAM_PG_PREVIOUSPROGRAM_TAG = "PP"; -const std::string SAM_PG_VERSION_TAG = "VN"; - -// CO entries -const std::string SAM_CO_BEGIN_TOKEN = "@CO"; - -// HD:SO values -const std::string SAM_HD_SORTORDER_COORDINATE = "coordinate"; -const std::string SAM_HD_SORTORDER_QUERYNAME = "queryname"; -const std::string SAM_HD_SORTORDER_UNKNOWN = "unknown"; -const std::string SAM_HD_SORTORDER_UNSORTED = "unsorted"; - -// HD:GO values -const std::string SAM_HD_GROUPORDER_NONE = "none"; -const std::string SAM_HD_GROUPORDER_QUERY = "query"; -const std::string SAM_HD_GROUPORDER_REFERENCE = "reference"; - -// SQ:LN values -const unsigned int SAM_SQ_LENGTH_MIN = 1; -const unsigned int SAM_SQ_LENGTH_MAX = 536870911; // 2^29 - 1 - -// RG:PL values -const std::string SAM_RG_SEQTECHNOLOGY_CAPILLARY = "CAPILLARY"; -const std::string SAM_RG_SEQTECHNOLOGY_HELICOS = "HELICOS"; -const std::string SAM_RG_SEQTECHNOLOGY_ILLUMINA = "ILLUMINA"; -const std::string SAM_RG_SEQTECHNOLOGY_IONTORRENT = "IONTORRENT"; -const std::string SAM_RG_SEQTECHNOLOGY_LS454 = "LS454"; -const std::string SAM_RG_SEQTECHNOLOGY_PACBIO = "PACBIO"; -const std::string SAM_RG_SEQTECHNOLOGY_SOLID = "SOLID"; - -} // namespace Constants -} // namespace BamTools - -#endif // SAM_CONSTANTS_H diff --git a/src/utils/BamTools/include/api/SamHeader.h b/src/utils/BamTools/include/api/SamHeader.h deleted file mode 100644 index 5c7a1019..00000000 --- a/src/utils/BamTools/include/api/SamHeader.h +++ /dev/null @@ -1,69 +0,0 @@ -// *************************************************************************** -// SamHeader.h (c) 2010 Derek Barnett -// Marth Lab, Department of Biology, Boston College -// All rights reserved. -// --------------------------------------------------------------------------- -// Last modified: 18 April 2011 (DB) -// --------------------------------------------------------------------------- -// Provides direct read/write access to the SAM header data fields. -// *************************************************************************** - -#ifndef SAM_HEADER_H -#define SAM_HEADER_H - -#include <api/api_global.h> -#include <api/SamProgramChain.h> -#include <api/SamReadGroupDictionary.h> -#include <api/SamSequenceDictionary.h> -#include <string> -#include <vector> - -namespace BamTools { - -struct API_EXPORT SamHeader { - - // ctor & dtor - SamHeader(const std::string& headerText = ""); - SamHeader(const SamHeader& other); - ~SamHeader(void); - - // query/modify entire SamHeader - void Clear(void); // clears all header contents - bool IsValid(bool verbose = false) const; // returns true if SAM header is well-formed - void SetHeaderText(const std::string& headerText); // replaces data fields with contents of SAM-formatted text - std::string ToString(void) const; // returns the printable, SAM-formatted header text - - // convenience query methods - bool HasVersion(void) const; // returns true if header contains format version entry - bool HasSortOrder(void) const; // returns true if header contains sort order entry - bool HasGroupOrder(void) const; // returns true if header contains group order entry - bool HasSequences(void) const; // returns true if header contains any sequence entries - bool HasReadGroups(void) const; // returns true if header contains any read group entries - bool HasPrograms(void) const; // returns true if header contains any program record entries - bool HasComments(void) const; // returns true if header contains comments - - // -------------- - // data members - // -------------- - - // header metadata (@HD line) - std::string Version; // VN:<Version> *Required for valid SAM header, if @HD record is present* - std::string SortOrder; // SO:<SortOrder> - std::string GroupOrder; // GO:<GroupOrder> - - // header sequences (@SQ entries) - SamSequenceDictionary Sequences; - - // header read groups (@RG entries) - SamReadGroupDictionary ReadGroups; - - // header program data (@PG entries) - SamProgramChain Programs; - - // header comments (@CO entries) - std::vector<std::string> Comments; -}; - -} // namespace BamTools - -#endif // SAM_HEADER_H diff --git a/src/utils/BamTools/include/api/SamProgram.h b/src/utils/BamTools/include/api/SamProgram.h deleted file mode 100644 index 3c89059b..00000000 --- a/src/utils/BamTools/include/api/SamProgram.h +++ /dev/null @@ -1,62 +0,0 @@ -// *************************************************************************** -// SamProgram.h (c) 2011 Derek Barnett -// Marth Lab, Department of Biology, Boston College -// All rights reserved. -// --------------------------------------------------------------------------- -// Last modified: 19 April 2011 (DB) -// --------------------------------------------------------------------------- -// Provides direct read/write access to the SAM header program records. -// *************************************************************************** - -#ifndef SAM_PROGRAM_H -#define SAM_PROGRAM_H - -#include "api/api_global.h" -#include <string> - -namespace BamTools { - -class SamProgramChain; - -struct API_EXPORT SamProgram { - - // ctor & dtor - SamProgram(void); - SamProgram(const std::string& id); - SamProgram(const SamProgram& other); - ~SamProgram(void); - - // query/modify entire program record - void Clear(void); // clears all data fields - - // convenience query methods - bool HasCommandLine(void) const; // returns true if program record has a command line entry - bool HasID(void) const; // returns true if program record has an ID - bool HasName(void) const; // returns true if program record has a name - bool HasPreviousProgramID(void) const; // returns true if program record has a 'previous program ID' - bool HasVersion(void) const; // returns true if program record has a version - - // data members - std::string CommandLine; // CL:<CommandLine> - std::string ID; // ID:<ID> *Required for valid SAM header* - std::string Name; // PN:<Name> - std::string PreviousProgramID; // PP:<PreviousProgramID> - std::string Version; // VN:<Version> - - // internal (non-standard) methods & fields - private: - bool HasNextProgramID(void) const; - std::string NextProgramID; - friend class BamTools::SamProgramChain; -}; - -/*! \fn bool operator==(const SamProgram& lhs, const SamProgram& rhs) - \brief tests equality by comparing program IDs -*/ -API_EXPORT inline bool operator==(const SamProgram& lhs, const SamProgram& rhs) { - return lhs.ID == rhs.ID; -} - -} // namespace BamTools - -#endif // SAM_PROGRAM_H diff --git a/src/utils/BamTools/include/api/SamProgramChain.h b/src/utils/BamTools/include/api/SamProgramChain.h deleted file mode 100644 index 4cb16fc3..00000000 --- a/src/utils/BamTools/include/api/SamProgramChain.h +++ /dev/null @@ -1,86 +0,0 @@ -// *************************************************************************** -// SamProgramChain.h (c) 2011 Derek Barnett -// Marth Lab, Department of Biology, Boston College -// All rights reserved. -// --------------------------------------------------------------------------- -// Last modified: 19 April 2011 (DB) -// --------------------------------------------------------------------------- -// Provides methods for operating on a SamProgram record "chain" -// *************************************************************************** - -#ifndef SAM_PROGRAMCHAIN_H -#define SAM_PROGRAMCHAIN_H - -#include <api/api_global.h> -#include <api/SamProgram.h> -#include <string> -#include <vector> - -namespace BamTools { - -// chain is *NOT* sorted in any order -// use First()/Last() to retrieve oldest/newest programs, respectively -typedef std::vector<SamProgram> SamProgramContainer; -typedef SamProgramContainer::iterator SamProgramIterator; -typedef SamProgramContainer::const_iterator SamProgramConstIterator; - -class API_EXPORT SamProgramChain { - - // ctor & dtor - public: - SamProgramChain(void); - SamProgramChain(const SamProgramChain& other); - ~SamProgramChain(void); - - // query/modify program data - public: - // appends a program record to the chain - void Add(SamProgram& program); - void Add(std::vector<SamProgram>& programs); - - // clears all read group entries - void Clear(void); - - // returns true if chain contains this program record (matches on ID) - bool Contains(const SamProgram& program) const; - bool Contains(const std::string& programId) const; - - // returns the first (oldest) program in the chain - SamProgram& First(void); - const SamProgram& First(void) const; - - // returns true if chain is empty - bool IsEmpty(void) const; - - // returns last (most recent) program in the chain - SamProgram& Last(void); - const SamProgram& Last(void) const; - - // returns number of program records in the chain - int Size(void) const; - - // retrieves a modifiable reference to the SamProgram object associated with this ID - SamProgram& operator[](const std::string& programId); - - // retrieve STL-compatible iterators - public: - SamProgramIterator Begin(void); // returns iterator to begin() - SamProgramConstIterator Begin(void) const; // returns const_iterator to begin() - SamProgramConstIterator ConstBegin(void) const; // returns const_iterator to begin() - SamProgramIterator End(void); // returns iterator to end() - SamProgramConstIterator End(void) const; // returns const_iterator to end() - SamProgramConstIterator ConstEnd(void) const; // returns const_iterator to end() - - // internal methods - private: - int IndexOf(const std::string& programId) const; - const std::string NextIdFor(const std::string& programId) const; - - // data members - private: - SamProgramContainer m_data; -}; - -} // namespace BamTools - -#endif // SAM_PROGRAMCHAIN_H diff --git a/src/utils/BamTools/include/api/SamReadGroup.h b/src/utils/BamTools/include/api/SamReadGroup.h deleted file mode 100644 index b203d3cd..00000000 --- a/src/utils/BamTools/include/api/SamReadGroup.h +++ /dev/null @@ -1,69 +0,0 @@ -// *************************************************************************** -// SamReadGroup.h (c) 2010 Derek Barnett -// Marth Lab, Department of Biology, Boston College -// All rights reserved. -// --------------------------------------------------------------------------- -// Last modified: 18 April 2011 (DB) -// --------------------------------------------------------------------------- -// Provides direct read/write access to the SAM read group data fields. -// *************************************************************************** - -#ifndef SAM_READGROUP_H -#define SAM_READGROUP_H - -#include "api/api_global.h" -#include <string> - -namespace BamTools { - -struct API_EXPORT SamReadGroup { - - // ctor & dtor - SamReadGroup(void); - SamReadGroup(const std::string& id); - SamReadGroup(const SamReadGroup& other); - ~SamReadGroup(void); - - // query/modify entire read group - void Clear(void); // clears all data fields - - // convenience query methods - bool HasDescription(void) const; // returns true if read group has a description - bool HasFlowOrder(void) const; // returns true if read group has a flow order entry - bool HasID(void) const; // returns true if read group has a group ID - bool HasKeySequence(void) const; // returns true if read group has a key sequence - bool HasLibrary(void) const; // returns true if read group has a library name - bool HasPlatformUnit(void) const; // returns true if read group has a platform unit ID - bool HasPredictedInsertSize(void) const; // returns true if read group has a predicted insert size - bool HasProductionDate(void) const; // returns true if read group has a production date - bool HasProgram(void) const; // returns true if read group has a program entry - bool HasSample(void) const; // returns true if read group has a sample name - bool HasSequencingCenter(void) const; // returns true if read group has a sequencing center ID - bool HasSequencingTechnology(void) const; // returns true if read group has a sequencing technology ID - - - // data fields - std::string Description; // DS:<Description> - std::string FlowOrder; // FO:<FlowOrder> - std::string ID; // ID:<ID> *Required for valid SAM header* - std::string KeySequence; // KS:<KeySequence> - std::string Library; // LB:<Library> - std::string PlatformUnit; // PU:<PlatformUnit> - std::string PredictedInsertSize; // PI:<PredictedInsertSize> - std::string ProductionDate; // DT:<ProductionDate> - std::string Program; // PG:<Program> - std::string Sample; // SM:<Sample> - std::string SequencingCenter; // CN:<SequencingCenter> - std::string SequencingTechnology; // PL:<SequencingTechnology> -}; - -/*! \fn bool operator==(const SamReadGroup& lhs, const SamReadGroup& rhs) - \brief tests equality by comparing read group IDs -*/ -API_EXPORT inline bool operator==(const SamReadGroup& lhs, const SamReadGroup& rhs) { - return lhs.ID == rhs.ID; -} - -} // namespace BamTools - -#endif // SAM_READGROUP_H diff --git a/src/utils/BamTools/include/api/SamReadGroupDictionary.h b/src/utils/BamTools/include/api/SamReadGroupDictionary.h deleted file mode 100644 index 8ec40e22..00000000 --- a/src/utils/BamTools/include/api/SamReadGroupDictionary.h +++ /dev/null @@ -1,87 +0,0 @@ -// *************************************************************************** -// SamReadGroupDictionary.h (c) 2010 Derek Barnett -// Marth Lab, Department of Biology, Boston College -// All rights reserved. -// --------------------------------------------------------------------------- -// Last modified: 18 April 2011 (DB) -// --------------------------------------------------------------------------- -// Provides methods for operating on a collection of SamReadGroup entries. -// *************************************************************************** - -#ifndef SAM_READGROUP_DICTIONARY_H -#define SAM_READGROUP_DICTIONARY_H - -#include <api/api_global.h> -#include <api/SamReadGroup.h> -#include <string> -#include <vector> - -namespace BamTools { - -typedef std::vector<SamReadGroup> SamReadGroupContainer; -typedef SamReadGroupContainer::iterator SamReadGroupIterator; -typedef SamReadGroupContainer::const_iterator SamReadGroupConstIterator; - -class API_EXPORT SamReadGroupDictionary { - - // ctor & dtor - public: - SamReadGroupDictionary(void); - SamReadGroupDictionary(const SamReadGroupDictionary& other); - ~SamReadGroupDictionary(void); - - // query/modify read group data - public: - // adds a read group - void Add(const SamReadGroup& readGroup); - void Add(const std::string& readGroupId); - - // adds multiple read groups - void Add(const std::vector<SamReadGroup>& readGroups); - void Add(const std::vector<std::string>& readGroupIds); - - // clears all read group entries - void Clear(void); - - // returns true if dictionary contains this read group - bool Contains(const SamReadGroup& readGroup) const; - bool Contains(const std::string& readGroupId) const; - - // returns true if dictionary is empty - bool IsEmpty(void) const; - - // removes read group, if found - void Remove(const SamReadGroup& readGroup); - void Remove(const std::string& readGroupId); - - // removes multiple read groups - void Remove(const std::vector<SamReadGroup>& readGroups); - void Remove(const std::vector<std::string>& readGroupIds); - - // returns number of read groups in dictionary - int Size(void) const; - - // retrieves a modifiable reference to the SamReadGroup object associated with this ID - SamReadGroup& operator[](const std::string& readGroupId); - - // retrieve STL-compatible iterators - public: - SamReadGroupIterator Begin(void); // returns iterator to begin() - SamReadGroupConstIterator Begin(void) const; // returns const_iterator to begin() - SamReadGroupConstIterator ConstBegin(void) const; // returns const_iterator to begin() - SamReadGroupIterator End(void); // returns iterator to end() - SamReadGroupConstIterator End(void) const; // returns const_iterator to end() - SamReadGroupConstIterator ConstEnd(void) const; // returns const_iterator to end() - - // internal methods - private: - int IndexOf(const std::string& readGroupId) const; - - // data members - private: - SamReadGroupContainer m_data; -}; - -} // namespace BamTools - -#endif // SAM_READGROUP_DICTIONARY_H diff --git a/src/utils/BamTools/include/api/SamSequence.h b/src/utils/BamTools/include/api/SamSequence.h deleted file mode 100644 index 054e58f9..00000000 --- a/src/utils/BamTools/include/api/SamSequence.h +++ /dev/null @@ -1,61 +0,0 @@ -// *************************************************************************** -// SamSequence.h (c) 2010 Derek Barnett -// Marth Lab, Department of Biology, Boston College -// All rights reserved. -// --------------------------------------------------------------------------- -// Last modified: 18 April 2011 (DB) -// --------------------------------------------------------------------------- -// Provides direct read/write access to the SAM sequence data fields. -// *************************************************************************** - -#ifndef SAM_SEQUENCE_H -#define SAM_SEQUENCE_H - -#include <api/api_global.h> -#include <string> - -namespace BamTools { - -struct API_EXPORT SamSequence { - - // ctor & dtor - SamSequence(void); - SamSequence(const std::string& name, const int& length); - SamSequence(const std::string& name, const std::string& length); - SamSequence(const SamSequence& other); - ~SamSequence(void); - - // query/modify entire sequence - void Clear(void); // clears all contents - - // convenience query methods - bool HasAssemblyID(void) const; // returns true if sequence has an assembly ID - bool HasChecksum(void) const; // returns true if sequence has an MD5 checksum - bool HasLength(void) const; // returns true if sequence has a length - bool HasName(void) const; // returns true if sequence has a name - bool HasSpecies(void) const; // returns true if sequence has a species ID - bool HasURI(void) const; // returns true if sequence has a URI - - // data members - std::string AssemblyID; // AS:<AssemblyID> - std::string Checksum; // M5:<Checksum> - std::string Length; // LN:<Length> *Required for valid SAM header* - std::string Name; // SN:<Name> *Required for valid SAM header* - std::string Species; // SP:<Species> - std::string URI; // UR:<URI> -}; - -/*! \fn bool operator==(const SamSequence& lhs, const SamSequence& rhs) - \brief tests equality by comparing sequence names, lengths, & checksums (if available) -*/ -API_EXPORT inline bool operator==(const SamSequence& lhs, const SamSequence& rhs) { - if ( lhs.Name != rhs.Name ) return false; - if ( lhs.Length != rhs.Length ) return false; - if ( lhs.HasChecksum() && rhs.HasChecksum() ) - return (lhs.Checksum == rhs.Checksum); - else return true; -} - -} // namespace BamTools - -#endif // SAM_SEQUENCE_H diff --git a/src/utils/BamTools/include/api/SamSequenceDictionary.h b/src/utils/BamTools/include/api/SamSequenceDictionary.h deleted file mode 100644 index 1ac73261..00000000 --- a/src/utils/BamTools/include/api/SamSequenceDictionary.h +++ /dev/null @@ -1,89 +0,0 @@ -// *************************************************************************** -// SamSequenceDictionary.h (c) 2010 Derek Barnett -// Marth Lab, Department of Biology, Boston College -// All rights reserved. -// --------------------------------------------------------------------------- -// Last modified: 18 April 2011 -// --------------------------------------------------------------------------- -// Provides methods for operating on a collection of SamSequence entries. -// *************************************************************************** - -#ifndef SAM_SEQUENCE_DICTIONARY_H -#define SAM_SEQUENCE_DICTIONARY_H - -#include <api/api_global.h> -#include <api/SamSequence.h> -#include <string> -#include <map> -#include <vector> - -namespace BamTools { - -typedef std::vector<SamSequence> SamSequenceContainer; -typedef SamSequenceContainer::iterator SamSequenceIterator; -typedef SamSequenceContainer::const_iterator SamSequenceConstIterator; - -class API_EXPORT SamSequenceDictionary { - - // ctor & dtor - public: - SamSequenceDictionary(void); - SamSequenceDictionary(const SamSequenceDictionary& other); - ~SamSequenceDictionary(void); - - // query/modify sequence data - public: - // adds a sequence - void Add(const SamSequence& sequence); - void Add(const std::string& name, const int& length); - - // adds multiple sequences - void Add(const std::vector<SamSequence>& sequences); - void Add(const std::map<std::string, int>& sequenceMap); - - // clears all sequence entries - void Clear(void); - - // returns true if dictionary contains this sequence - bool Contains(const SamSequence& sequence) const; - bool Contains(const std::string& sequenceName) const; - - // returns true if dictionary is empty - bool IsEmpty(void) const; - - // removes sequence, if found - void Remove(const SamSequence& sequence); - void Remove(const std::string& sequenceName); - - // removes multiple sequences - void Remove(const std::vector<SamSequence>& sequences); - void Remove(const std::vector<std::string>& sequenceNames); - - // returns number of sequences in dictionary - int Size(void) const; - - // retrieves a modifiable reference to the SamSequence object associated with this name - SamSequence& operator[](const std::string& sequenceName); - - // retrieve STL-compatible iterators - public: - SamSequenceIterator Begin(void); // returns iterator to begin() - SamSequenceConstIterator Begin(void) const; // returns const_iterator to begin() - SamSequenceConstIterator ConstBegin(void) const; // returns const_iterator to begin() - SamSequenceIterator End(void); // returns iterator to end() - SamSequenceConstIterator End(void) const; // returns const_iterator to end() - SamSequenceConstIterator ConstEnd(void) const; // returns const_iterator to end() - - // internal methods - private: - int IndexOf(const std::string& name) const; - - // data members - private: - SamSequenceContainer m_data; -}; - -} // namespace BamTools - -#endif // SAM_SEQUENCE_DICTIONARY_H - diff --git a/src/utils/BamTools/include/api/api_global.h b/src/utils/BamTools/include/api/api_global.h deleted file mode 100644 index 84fcad21..00000000 --- a/src/utils/BamTools/include/api/api_global.h +++ /dev/null @@ -1,22 +0,0 @@ -// *************************************************************************** -// api_global.h (c) 2010 Derek Barnett -// Marth Lab, Department of Biology, Boston College -// All rights reserved. -// --------------------------------------------------------------------------- -// Last modified: 19 November 2010 (DB) -// --------------------------------------------------------------------------- -// Provides macros for exporting & importing BamTools API library symbols -// *************************************************************************** - -#ifndef API_GLOBAL_H -#define API_GLOBAL_H - -#include "shared/bamtools_global.h" - -#ifdef BAMTOOLS_API_LIBRARY -# define API_EXPORT BAMTOOLS_LIBRARY_EXPORT -#else -# define API_EXPORT BAMTOOLS_LIBRARY_IMPORT -#endif - -#endif // API_GLOBAL_H diff --git a/src/utils/BamTools/include/shared/bamtools_global.h b/src/utils/BamTools/include/shared/bamtools_global.h deleted file mode 100644 index 6e3cb39e..00000000 --- a/src/utils/BamTools/include/shared/bamtools_global.h +++ /dev/null @@ -1,79 +0,0 @@ -// *************************************************************************** -// bamtools_global.h (c) 2010 Derek Barnett -// Marth Lab, Department of Biology, Boston College -// All rights reserved. -// --------------------------------------------------------------------------- -// Last modified: 3 March 2011 (DB) -// --------------------------------------------------------------------------- -// Provides the basic definitions for exporting & importing library symbols. -// Also provides some platform-specific rules for definitions. -// *************************************************************************** - -#ifndef BAMTOOLS_GLOBAL_H -#define BAMTOOLS_GLOBAL_H - -/*! \brief Library export macro - \internal -*/ -#ifndef BAMTOOLS_LIBRARY_EXPORT -# if defined(WIN32) -# define BAMTOOLS_LIBRARY_EXPORT __declspec(dllexport) -# else -# define BAMTOOLS_LIBRARY_EXPORT __attribute__((visibility("default"))) -# endif -#endif // BAMTOOLS_LIBRARY_EXPORT - -/*! \brief Library import macro - \internal -*/ -#ifndef BAMTOOLS_LIBRARY_IMPORT -# if defined(WIN32) -# define BAMTOOLS_LIBRARY_IMPORT __declspec(dllimport) -# else -# define BAMTOOLS_LIBRARY_IMPORT -# endif -#endif // BAMTOOLS_LIBRARY_IMPORT - -/*! \brief Platform-specific type definitions - \internal -*/ -#ifndef BAMTOOLS_LFS -#define BAMTOOLS_LFS - #ifdef WIN32 - #define ftell64(a) _ftelli64(a) - #define fseek64(a,b,c) _fseeki64(a,b,c) - #else - #define ftell64(a) ftello(a) - #define fseek64(a,b,c) fseeko(a,b,c) - #endif -#endif // BAMTOOLS_LFS - -/*! \def ftell64(a) - \brief Platform-independent tell() operation. - \internal -*/ -/*! \def fseek64(a,b,c) - \brief Platform-independent seek() operation. - \internal -*/ - -/*! \brief Platform-specific type definitions - \internal -*/ -#ifndef BAMTOOLS_TYPES -#define BAMTOOLS_TYPES - #ifdef _MSC_VER - typedef char int8_t; - typedef unsigned char uint8_t; - typedef short int16_t; - typedef unsigned short uint16_t; - typedef int int32_t; - typedef unsigned int uint32_t; - typedef long long int64_t; - typedef unsigned long long uint64_t; - #else - #include <stdint.h> - #endif -#endif // BAMTOOLS_TYPES - -#endif // BAMTOOLS_GLOBAL_H -- GitLab