BamTools  2.5.2
SamHeader.h
Go to the documentation of this file.
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 // ***************************************************************************
9 
10 #ifndef SAM_HEADER_H
11 #define SAM_HEADER_H
12 
13 #include <string>
14 #include <vector>
15 #include "api/BamAux.h"
16 #include "api/SamProgramChain.h"
19 #include "api/api_global.h"
20 
21 namespace BamTools {
22 
23 struct API_EXPORT SamHeader
24 {
25 
26  // ctor & dtor
27  SamHeader(const std::string& headerText = std::string());
28 
29  // query/modify entire SamHeader
30  void Clear(); // clears all header contents
31  std::string GetErrorString() const;
32  bool HasError() const;
33  bool IsValid(bool verbose = false) const; // returns true if SAM header is well-formed
34  void SetHeaderText(
35  const std::string& headerText); // replaces data fields with contents of SAM-formatted text
36  std::string ToString() const; // returns the printable, SAM-formatted header text
37 
38  // convenience query methods
39  bool HasVersion() const; // returns true if header contains format version entry
40  bool HasSortOrder() const; // returns true if header contains sort order entry
41  bool HasGroupOrder() const; // returns true if header contains group order entry
42  bool HasSequences() const; // returns true if header contains any sequence entries
43  bool HasReadGroups() const; // returns true if header contains any read group entries
44  bool HasPrograms() const; // returns true if header contains any program record entries
45  bool HasComments() const; // returns true if header contains comments
46 
47  // --------------
48  // data members
49  // --------------
50 
51  // header metadata (@HD line)
52  std::string Version; // VN:<Version> *Required, if @HD record is present*
53  std::string SortOrder; // SO:<SortOrder>
54  std::string GroupOrder; // GO:<GroupOrder>
55  std::vector<CustomHeaderTag> CustomTags; // optional custom tags on @HD line
56 
57  // header sequences (@SQ entries)
59 
60  // header read groups (@RG entries)
62 
63  // header program data (@PG entries)
65 
66  // header comments (@CO entries)
67  std::vector<std::string> Comments;
68 
69  // internal data
70 private:
71  mutable std::string m_errorString;
72 };
73 
74 } // namespace BamTools
75 
76 #endif // SAM_HEADER_H
Sorted container "chain" of SamProgram records.
Definition: SamProgramChain.h:27
Container of SamReadGroup entries.
Definition: SamReadGroupDictionary.h:27
Container of SamSequence entries.
Definition: SamSequenceDictionary.h:27
Contains all BamTools classes & methods.
Definition: Sort.h:24
Represents the SAM-formatted text header that is part of the BAM file header.
Definition: SamHeader.h:24
SamReadGroupDictionary ReadGroups
corresponds to @RG entries
Definition: SamHeader.h:61
SamSequenceDictionary Sequences
corresponds to @SQ entries
Definition: SamHeader.h:58
std::string SortOrder
corresponds to @HD SO:<SortOrder>
Definition: SamHeader.h:53
std::vector< std::string > Comments
corresponds to @CO entries
Definition: SamHeader.h:67
std::string GroupOrder
corresponds to @HD GO:<GroupOrder>
Definition: SamHeader.h:54
std::vector< CustomHeaderTag > CustomTags
Definition: SamHeader.h:55
std::string Version
corresponds to @HD VN:<Version>
Definition: SamHeader.h:52
SamProgramChain Programs
corresponds to @PG entries
Definition: SamHeader.h:64