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