1 // ***************************************************************************
2 // SamHeaderValidator.h (c) 2010 Derek Barnett
3 // Marth Lab, Department of Biology, Boston College
4 // ---------------------------------------------------------------------------
5 // Last modified: 13 January 2011 (DB)
6 // ---------------------------------------------------------------------------
7 // Provides functionality for validating SamHeader data
8 // ***************************************************************************
10 #ifndef SAM_HEADER_VALIDATOR_P_H
11 #define SAM_HEADER_VALIDATOR_P_H
17 // This file is not part of the BamTools API. It exists purely as an
18 // implementation detail. This header file may change from version to version
19 // without notice, or even be removed.
34 class SamHeaderValidator {
38 SamHeaderValidator(const SamHeader& header);
39 ~SamHeaderValidator(void);
41 // SamHeaderValidator interface
43 // validates SamHeader data, returns true/false accordingly
44 // prints error & warning messages to stderr when @verbose is true
45 bool Validate(bool verbose = false);
50 // validate header metadata
51 bool ValidateMetadata(void);
52 bool ValidateVersion(void);
53 bool ContainsOnlyDigits(const std::string& s);
54 bool ValidateSortOrder(void);
55 bool ValidateGroupOrder(void);
57 // validate sequence dictionary
58 bool ValidateSequenceDictionary(void);
59 bool ContainsUniqueSequenceNames(void);
60 bool CheckNameFormat(const std::string& name);
61 bool ValidateSequence(const SamSequence& seq);
62 bool CheckLengthInRange(const std::string& length);
64 // validate read group dictionary
65 bool ValidateReadGroupDictionary(void);
66 bool ContainsUniqueIDsAndPlatformUnits(void);
67 bool ValidateReadGroup(const SamReadGroup& rg);
68 bool CheckReadGroupID(const std::string& id);
69 bool CheckSequencingTechnology(const std::string& technology);
71 // validate program data
72 bool ValidateProgramChain(void);
73 bool ContainsUniqueProgramIds(void);
74 bool ValidatePreviousProgramIds(void);
77 void AddError(const std::string& message);
78 void AddWarning(const std::string& message);
79 void PrintErrorMessages(void);
80 void PrintWarningMessages(void);
85 // SamHeader being validated
86 const SamHeader& m_header;
88 // error reporting helpers
89 static const std::string ERROR_PREFIX;
90 static const std::string WARN_PREFIX;
91 static const std::string NEWLINE;
93 // error reporting messages
94 std::vector<std::string> m_errorMessages;
95 std::vector<std::string> m_warningMessages;
98 } // namespace Internal
99 } // namespace BamTools
101 #endif // SAM_HEADER_VALIDATOR_P_H