1 // ***************************************************************************
2 // SamHeaderValidator.h (c) 2010 Derek Barnett
3 // Marth Lab, Department of Biology, Boston College
4 // ---------------------------------------------------------------------------
5 // Last modified: 6 October 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.
35 class SamHeaderValidator {
39 SamHeaderValidator(const SamHeader& header);
40 ~SamHeaderValidator(void);
42 // SamHeaderValidator interface
45 // prints error & warning messages
46 void PrintMessages(std::ostream& stream);
48 // validates SamHeader data, returns true/false accordingly
54 // validate header metadata
55 bool ValidateMetadata(void);
56 bool ValidateVersion(void);
57 bool ContainsOnlyDigits(const std::string& s);
58 bool ValidateSortOrder(void);
59 bool ValidateGroupOrder(void);
61 // validate sequence dictionary
62 bool ValidateSequenceDictionary(void);
63 bool ContainsUniqueSequenceNames(void);
64 bool CheckNameFormat(const std::string& name);
65 bool ValidateSequence(const SamSequence& seq);
66 bool CheckLengthInRange(const std::string& length);
68 // validate read group dictionary
69 bool ValidateReadGroupDictionary(void);
70 bool ContainsUniqueIDsAndPlatformUnits(void);
71 bool ValidateReadGroup(const SamReadGroup& rg);
72 bool CheckReadGroupID(const std::string& id);
73 bool CheckSequencingTechnology(const std::string& technology);
75 // validate program data
76 bool ValidateProgramChain(void);
77 bool ContainsUniqueProgramIds(void);
78 bool ValidatePreviousProgramIds(void);
81 void AddError(const std::string& message);
82 void AddWarning(const std::string& message);
83 void PrintErrorMessages(std::ostream& stream);
84 void PrintWarningMessages(std::ostream& stream);
89 // SamHeader being validated
90 const SamHeader& m_header;
92 // error reporting helpers
93 static const std::string ERROR_PREFIX;
94 static const std::string WARN_PREFIX;
95 static const std::string NEWLINE;
97 // error reporting messages
98 std::vector<std::string> m_errorMessages;
99 std::vector<std::string> m_warningMessages;
102 } // namespace Internal
103 } // namespace BamTools
105 #endif // SAM_HEADER_VALIDATOR_P_H