]> git.donarmstrong.com Git - bamtools.git/blob - src/api/SamSequence.h
Added SAM header-handling classes for read/write/validate.
[bamtools.git] / src / api / SamSequence.h
1 // ***************************************************************************
2 // SamSequence.h (c) 2010 Derek Barnett
3 // Marth Lab, Department of Biology, Boston College
4 // All rights reserved.
5 // ---------------------------------------------------------------------------
6 // Last modified: 23 December 2010 (DB)
7 // ---------------------------------------------------------------------------
8 // Provides functionality for querying/manipulating sequence data
9 // **************************************************************************
10
11 #ifndef SAM_SEQUENCE_H
12 #define SAM_SEQUENCE_H
13
14 #include <api/api_global.h>
15 #include <string>
16
17 namespace BamTools {
18
19 class API_EXPORT SamSequence {
20
21     // ctor & dtor
22     public:
23         SamSequence(const std::string& name = "");
24         ~SamSequence(void);
25
26     // public methods
27     public:
28
29         // clear all contents
30         void Clear(void);
31
32         // convenience methods to check if SamSequence contains these values:
33         bool HasName(void) const;
34         bool HasLength(void) const;
35         bool HasAssemblyID(void) const;
36         bool HasChecksum(void) const;
37         bool HasURI(void) const;
38         bool HasSpecies(void) const;
39
40     // data members
41     public:
42         std::string Name;       // SN:<Name>
43         std::string Length;     // LN:<Length>
44         std::string AssemblyID; // AS:<AssemblyID>
45         std::string Checksum;   // M5:<Checksum>
46         std::string URI;        // UR:<URI>
47         std::string Species;    // SP:<Species>
48 };
49
50 // ---------------------------------------------------
51 // comparison operators
52
53 // for equality: compare Name, Length, & Checksum (if it exists for both)
54 inline bool operator==(const SamSequence& lhs, const SamSequence& rhs) {
55     if ( lhs.Name   != rhs.Name   ) return false;
56     if ( lhs.Length != rhs.Length ) return false;
57     if ( lhs.HasChecksum() && rhs.HasChecksum() )
58         return (lhs.Checksum == rhs.Checksum);
59     else return true;
60 }
61
62 } // namespace BamTools
63
64 #endif // SAM_SEQUENCE_H