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 // ***************************************************************************
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 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
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
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>
55 // header sequences (@SQ entries)
56 SamSequenceDictionary Sequences;
58 // header read groups (@RG entries)
59 SamReadGroupDictionary ReadGroups;
61 // header program data (@PG entries)
62 SamProgramChain Programs;
64 // header comments (@CO entries)
65 std::vector<std::string> Comments;
69 mutable std::string m_errorString;
72 } // namespace BamTools
74 #endif // SAM_HEADER_H