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