]> git.donarmstrong.com Git - bamtools.git/blobdiff - src/api/internal/SamHeaderValidator_p.h
Brought API up to compliance with recent SAM Format Spec (v1.4-r962)
[bamtools.git] / src / api / internal / SamHeaderValidator_p.h
index 41c04ee8cf674609045070e6cc79df964925465a..06a82abeaa04d9ee1043ba89f47c41703ed12160 100644 (file)
@@ -3,7 +3,7 @@
 // Marth Lab, Department of Biology, Boston College
 // All rights reserved.
 // ---------------------------------------------------------------------------
-// Last modified: 23 December 2010 (DB)
+// Last modified: 13 January 2011 (DB)
 // ---------------------------------------------------------------------------
 // Provides functionality for validating SamHeader data
 // ***************************************************************************
 namespace BamTools {
 
 class SamHeader;
+class SamReadGroup;
+class SamSequence;
 
 namespace Internal {
 
 class SamHeaderValidator {
 
+    // ctor & dtor
     public:
-        SamHeaderValidator(const BamTools::SamHeader& header);
+        SamHeaderValidator(const SamHeader& header);
         ~SamHeaderValidator(void);
 
+    // SamHeaderValidator interface
     public:
-        // validates SamHeader data
-        // prints error & warning messages to stderr when (verbose == true)
+        // validates SamHeader data, returns true/false accordingly
+        // prints error & warning messages to stderr when @verbose is true
         bool Validate(bool verbose = false);
 
+    // internal methods
     private:
-        struct SamHeaderValidatorPrivate;
-        SamHeaderValidatorPrivate* d;
+
+        // validate header metadata
+        bool ValidateMetadata(void);
+        bool ValidateVersion(void);
+        bool ContainsOnlyDigits(const std::string& s);
+        bool ValidateSortOrder(void);
+        bool ValidateGroupOrder(void);
+
+        // validate sequence dictionary
+        bool ValidateSequenceDictionary(void);
+        bool ContainsUniqueSequenceNames(void);
+        bool CheckNameFormat(const std::string& name);
+        bool ValidateSequence(const SamSequence& seq);
+        bool CheckLengthInRange(const std::string& length);
+
+        // validate read group dictionary
+        bool ValidateReadGroupDictionary(void);
+        bool ContainsUniqueIDsAndPlatformUnits(void);
+        bool ValidateReadGroup(const SamReadGroup& rg);
+        bool CheckReadGroupID(const std::string& id);
+        bool CheckSequencingTechnology(const std::string& technology);
+
+        // validate program data
+        bool ValidateProgramChain(void);
+        bool ContainsUniqueProgramIds(void);
+        bool ValidatePreviousProgramIds(void);
+
+        // error reporting
+        void AddError(const std::string& message);
+        void AddWarning(const std::string& message);
+        void PrintErrorMessages(void);
+        void PrintWarningMessages(void);
+
+    // data members
+    private:
+
+        // SamHeader being validated
+        const SamHeader& m_header;
+
+        // error reporting helpers
+        static const std::string ERROR_PREFIX;
+        static const std::string WARN_PREFIX;
+        static const std::string NEWLINE;
+
+        // error reporting messages
+        std::vector<std::string> m_errorMessages;
+        std::vector<std::string> m_warningMessages;
 };
 
 } // namespace Internal