]> git.donarmstrong.com Git - bamtools.git/blobdiff - src/api/SamHeader.h
Cleaned up intra-API includes & moved version numbers to 2.0.0
[bamtools.git] / src / api / SamHeader.h
index b51f1750d1beb55c77aeed552a39a19407d607da..50049947e627a29f5b077cb719b0c1a7874bb75a 100644 (file)
@@ -1,19 +1,19 @@
 // ***************************************************************************
 // SamHeader.h (c) 2010 Derek Barnett
 // Marth Lab, Department of Biology, Boston College
-// All rights reserved.
 // ---------------------------------------------------------------------------
-// Last modified: 23 December 2010 (DB)
+// Last modified: 10 October 2011 (DB)
 // ---------------------------------------------------------------------------
-// Provides functionality for querying/manipulating SAM header data
-// **************************************************************************
+// Provides direct read/write access to the SAM header data fields.
+// ***************************************************************************
 
 #ifndef SAM_HEADER_H
 #define SAM_HEADER_H
 
-#include <api/api_global.h>
-#include <api/SamReadGroupDictionary.h>
-#include <api/SamSequenceDictionary.h>
+#include "api/api_global.h"
+#include "api/SamProgramChain.h"
+#include "api/SamReadGroupDictionary.h"
+#include "api/SamSequenceDictionary.h"
 #include <string>
 #include <vector>
 
@@ -22,58 +22,51 @@ namespace BamTools {
 struct API_EXPORT SamHeader {
 
     // ctor & dtor
-    public:
-        explicit SamHeader(const std::string& headerText = "");
-        ~SamHeader(void);
-
-    // query/modify entire SamHeader at once
-    public:
-
-        // clear all header contents
-        void Clear(void);
-
-        // checks if SAM header is well-formed
-        // @verbose - if true, validation errors & warnings will be printed to stderr
-        // otherwise, output is suppressed and only validation check occurs
-        bool IsValid(bool verbose = false) const;
-
-        // retrieves the printable, SAM-formatted header
-        // (with any local modifications since construction)
-        std::string ToString(void) const;
-
-    // query if header contains data elements
-    public:
-        bool HasVersion(void) const;
-        bool HasSortOrder(void) const;
-        bool HasGroupOrder(void) const;
-        bool HasSequences(void) const;
-        bool HasReadGroups(void) const;
-        bool HasProgramName(void) const;
-        bool HasProgramVersion(void) const;
-        bool HasProgramCommandLine(void) const;
-        bool HasComments(void) const;
-
+    SamHeader(const std::string& headerText = "");
+    SamHeader(const SamHeader& other);
+    ~SamHeader(void);
+
+    // query/modify entire SamHeader
+    void Clear(void);                                   // clears all header contents
+    std::string GetErrorString(void) const;
+    bool HasError(void) const;
+    bool IsValid(bool verbose = false) const;           // returns true if SAM header is well-formed
+    void SetHeaderText(const std::string& headerText);  // replaces data fields with contents of SAM-formatted text
+    std::string ToString(void) const;                   // returns the printable, SAM-formatted header text
+
+    // convenience query methods
+    bool HasVersion(void) const;     // returns true if header contains format version entry
+    bool HasSortOrder(void) const;   // returns true if header contains sort order entry
+    bool HasGroupOrder(void) const;  // returns true if header contains group order entry
+    bool HasSequences(void) const;   // returns true if header contains any sequence entries
+    bool HasReadGroups(void) const;  // returns true if header contains any read group entries
+    bool HasPrograms(void) const;    // returns true if header contains any program record entries
+    bool HasComments(void) const;    // returns true if header contains comments
+
+    // --------------
     // data members
-    public:
+    // --------------
+
+    // header metadata (@HD line)
+    std::string Version;             // VN:<Version>  *Required, if @HD record is present*
+    std::string SortOrder;           // SO:<SortOrder>
+    std::string GroupOrder;          // GO:<GroupOrder>
 
-        // header metadata (@HD line)
-        std::string Version;                // VN:<Version>
-        std::string SortOrder;              // SO:<SortOrder>
-        std::string GroupOrder;             // GO:<GroupOrder>
+    // header sequences (@SQ entries)
+    SamSequenceDictionary Sequences;
 
-        // header sequences (@SQ entries)
-        SamSequenceDictionary Sequences;
+    // header read groups (@RG entries)
+    SamReadGroupDictionary ReadGroups;
 
-        // header read groups (@RG entries)
-        SamReadGroupDictionary ReadGroups;
+    // header program data (@PG entries)
+    SamProgramChain Programs;
 
-        // header program data (@PG entries)
-        std::string ProgramName;            // ID:<ProgramName>
-        std::string ProgramVersion;         // VN:<ProgramVersion>
-        std::string ProgramCommandLine;     // CL:<ProgramCommandLine>
+    // header comments (@CO entries)
+    std::vector<std::string> Comments;
 
-        // header comments (@CO entries)
-        std::vector<std::string> Comments;
+    // internal data
+    private:
+        mutable std::string m_errorString;
 };
 
 } // namespace BamTools