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