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 // ***************************************************************************
14 #include <api/api_global.h>
15 #include <api/SamProgramChain.h>
16 #include <api/SamReadGroupDictionary.h>
17 #include <api/SamSequenceDictionary.h>
23 struct API_EXPORT SamHeader {
26 SamHeader(const std::string& headerText = "");
27 SamHeader(const SamHeader& other);
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
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
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>
54 // header sequences (@SQ entries)
55 SamSequenceDictionary Sequences;
57 // header read groups (@RG entries)
58 SamReadGroupDictionary ReadGroups;
60 // header program data (@PG entries)
61 SamProgramChain Programs;
63 // header comments (@CO entries)
64 std::vector<std::string> Comments;
67 } // namespace BamTools
69 #endif // SAM_HEADER_H