]> git.donarmstrong.com Git - bamtools.git/blob - src/api/SamHeader.h
3b67621ac4dca6bd94aba4293b7d944bf7eba5e8
[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: 18 April 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     bool IsValid(bool verbose = false) const;           // returns true if SAM header is well-formed
32     void SetHeaderText(const std::string& headerText);  // replaces data fields with contents of SAM-formatted text
33     std::string ToString(void) const;                   // returns the printable, SAM-formatted header text
34
35     // convenience query methods
36     bool HasVersion(void) const;            // returns true if header contains format version entry
37     bool HasSortOrder(void) const;          // returns true if header contains sort order entry
38     bool HasGroupOrder(void) const;         // returns true if header contains group order entry
39     bool HasSequences(void) const;          // returns true if header contains any sequence entries
40     bool HasReadGroups(void) const;         // returns true if header contains any read group entries
41     bool HasPrograms(void) const;           // returns true if header contains any program record entries
42     bool HasComments(void) const;           // returns true if header contains comments
43
44     // --------------
45     // data members
46     // --------------
47
48     // header metadata (@HD line)
49     std::string Version;                    // VN:<Version>  *Required for valid SAM header, if @HD record is present*
50     std::string SortOrder;                  // SO:<SortOrder>
51     std::string GroupOrder;                 // GO:<GroupOrder>
52
53     // header sequences (@SQ entries)
54     SamSequenceDictionary Sequences;
55
56     // header read groups (@RG entries)
57     SamReadGroupDictionary ReadGroups;
58
59     // header program data (@PG entries)
60     SamProgramChain Programs;
61
62     // header comments (@CO entries)
63     std::vector<std::string> Comments;
64 };
65
66 } // namespace BamTools
67
68 #endif // SAM_HEADER_H