]> git.donarmstrong.com Git - bamtools.git/blob - src/api/SamHeader.h
Added SAM header-handling classes for read/write/validate.
[bamtools.git] / src / api / SamHeader.h
1 // ***************************************************************************
2 // SamHeader.h (c) 2010 Derek Barnett
3 // Marth Lab, Department of Biology, Boston College
4 // All rights reserved.
5 // ---------------------------------------------------------------------------
6 // Last modified: 23 December 2010 (DB)
7 // ---------------------------------------------------------------------------
8 // Provides functionality for querying/manipulating SAM header data
9 // **************************************************************************
10
11 #ifndef SAM_HEADER_H
12 #define SAM_HEADER_H
13
14 #include <api/api_global.h>
15 #include <api/SamReadGroupDictionary.h>
16 #include <api/SamSequenceDictionary.h>
17 #include <string>
18 #include <vector>
19
20 namespace BamTools {
21
22 struct API_EXPORT SamHeader {
23
24     // ctor & dtor
25     public:
26         explicit SamHeader(const std::string& headerText = "");
27         ~SamHeader(void);
28
29     // query/modify entire SamHeader at once
30     public:
31
32         // clear all header contents
33         void Clear(void);
34
35         // checks if SAM header is well-formed
36         // @verbose - if true, validation errors & warnings will be printed to stderr
37         // otherwise, output is suppressed and only validation check occurs
38         bool IsValid(bool verbose = false) const;
39
40         // retrieves the printable, SAM-formatted header
41         // (with any local modifications since construction)
42         std::string ToString(void) const;
43
44     // query if header contains data elements
45     public:
46         bool HasVersion(void) const;
47         bool HasSortOrder(void) const;
48         bool HasGroupOrder(void) const;
49         bool HasSequences(void) const;
50         bool HasReadGroups(void) const;
51         bool HasProgramName(void) const;
52         bool HasProgramVersion(void) const;
53         bool HasProgramCommandLine(void) const;
54         bool HasComments(void) const;
55
56     // data members
57     public:
58
59         // header metadata (@HD line)
60         std::string Version;                // VN:<Version>
61         std::string SortOrder;              // SO:<SortOrder>
62         std::string GroupOrder;             // GO:<GroupOrder>
63
64         // header sequences (@SQ entries)
65         SamSequenceDictionary Sequences;
66
67         // header read groups (@RG entries)
68         SamReadGroupDictionary ReadGroups;
69
70         // header program data (@PG entries)
71         std::string ProgramName;            // ID:<ProgramName>
72         std::string ProgramVersion;         // VN:<ProgramVersion>
73         std::string ProgramCommandLine;     // CL:<ProgramCommandLine>
74
75         // header comments (@CO entries)
76         std::vector<std::string> Comments;
77 };
78
79 } // namespace BamTools
80
81 #endif // SAM_HEADER_H