]> git.donarmstrong.com Git - bamtools.git/blob - src/api/SamHeader.h
Cleaned up intra-API includes & moved version numbers to 2.0.0
[bamtools.git] / src / api / SamHeader.h
1 // ***************************************************************************
2 // SamHeader.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 header data fields.
8 // ***************************************************************************
9
10 #ifndef SAM_HEADER_H
11 #define SAM_HEADER_H
12
13 #include "api/api_global.h"
14 #include "api/SamProgramChain.h"
15 #include "api/SamReadGroupDictionary.h"
16 #include "api/SamSequenceDictionary.h"
17 #include <string>
18 #include <vector>
19
20 namespace BamTools {
21
22 struct API_EXPORT SamHeader {
23
24     // ctor & dtor
25     SamHeader(const std::string& headerText = "");
26     SamHeader(const SamHeader& other);
27     ~SamHeader(void);
28
29     // query/modify entire SamHeader
30     void Clear(void);                                   // clears all header contents
31     std::string GetErrorString(void) const;
32     bool HasError(void) const;
33     bool IsValid(bool verbose = false) const;           // returns true if SAM header is well-formed
34     void SetHeaderText(const std::string& headerText);  // replaces data fields with contents of SAM-formatted text
35     std::string ToString(void) const;                   // returns the printable, SAM-formatted header text
36
37     // convenience query methods
38     bool HasVersion(void) const;     // returns true if header contains format version entry
39     bool HasSortOrder(void) const;   // returns true if header contains sort order entry
40     bool HasGroupOrder(void) const;  // returns true if header contains group order entry
41     bool HasSequences(void) const;   // returns true if header contains any sequence entries
42     bool HasReadGroups(void) const;  // returns true if header contains any read group entries
43     bool HasPrograms(void) const;    // returns true if header contains any program record entries
44     bool HasComments(void) const;    // returns true if header contains comments
45
46     // --------------
47     // data members
48     // --------------
49
50     // header metadata (@HD line)
51     std::string Version;             // VN:<Version>  *Required, if @HD record is present*
52     std::string SortOrder;           // SO:<SortOrder>
53     std::string GroupOrder;          // GO:<GroupOrder>
54
55     // header sequences (@SQ entries)
56     SamSequenceDictionary Sequences;
57
58     // header read groups (@RG entries)
59     SamReadGroupDictionary ReadGroups;
60
61     // header program data (@PG entries)
62     SamProgramChain Programs;
63
64     // header comments (@CO entries)
65     std::vector<std::string> Comments;
66
67     // internal data
68     private:
69         mutable std::string m_errorString;
70 };
71
72 } // namespace BamTools
73
74 #endif // SAM_HEADER_H