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