1 // ***************************************************************************
2 // SamSequence.h (c) 2010 Derek Barnett
3 // Marth Lab, Department of Biology, Boston College
4 // ---------------------------------------------------------------------------
5 // Last modified: 10 October 2011 (DB)
6 // ---------------------------------------------------------------------------
7 // Provides direct read/write access to the SAM sequence data fields.
8 // ***************************************************************************
10 #ifndef SAM_SEQUENCE_H
11 #define SAM_SEQUENCE_H
13 #include "api/api_global.h"
18 struct API_EXPORT SamSequence {
22 SamSequence(const std::string& name, const int& length);
23 SamSequence(const std::string& name, const std::string& length);
24 SamSequence(const SamSequence& other);
27 // query/modify entire sequence
28 void Clear(void); // clears all contents
30 // convenience query methods
31 bool HasAssemblyID(void) const; // returns true if sequence has an assembly ID
32 bool HasChecksum(void) const; // returns true if sequence has an MD5 checksum
33 bool HasLength(void) const; // returns true if sequence has a length
34 bool HasName(void) const; // returns true if sequence has a name
35 bool HasSpecies(void) const; // returns true if sequence has a species ID
36 bool HasURI(void) const; // returns true if sequence has a URI
39 std::string AssemblyID; // AS:<AssemblyID>
40 std::string Checksum; // M5:<Checksum>
41 std::string Length; // LN:<Length> *Required for valid SAM header*
42 std::string Name; // SN:<Name> *Required for valid SAM header*
43 std::string Species; // SP:<Species>
44 std::string URI; // UR:<URI>
47 /*! \fn bool operator==(const SamSequence& lhs, const SamSequence& rhs)
48 \brief tests equality by comparing sequence names, lengths, & checksums (if available)
50 API_EXPORT inline bool operator==(const SamSequence& lhs, const SamSequence& rhs) {
51 if ( lhs.Name != rhs.Name ) return false;
52 if ( lhs.Length != rhs.Length ) return false;
53 if ( lhs.HasChecksum() && rhs.HasChecksum() )
54 return (lhs.Checksum == rhs.Checksum);
58 } // namespace BamTools
60 #endif // SAM_SEQUENCE_H