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 // ***************************************************************************
13 #include <api/api_global.h>
14 #include <api/SamProgramChain.h>
15 #include <api/SamReadGroupDictionary.h>
16 #include <api/SamSequenceDictionary.h>
22 struct API_EXPORT SamHeader {
25 SamHeader(const std::string& headerText = "");
26 SamHeader(const SamHeader& other);
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
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
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>
53 // header sequences (@SQ entries)
54 SamSequenceDictionary Sequences;
56 // header read groups (@RG entries)
57 SamReadGroupDictionary ReadGroups;
59 // header program data (@PG entries)
60 SamProgramChain Programs;
62 // header comments (@CO entries)
63 std::vector<std::string> Comments;
66 } // namespace BamTools
68 #endif // SAM_HEADER_H