]> git.donarmstrong.com Git - bamtools.git/blob - src/utils/bamtools_utilities.h
Major update to BamTools version 1.0
[bamtools.git] / src / utils / bamtools_utilities.h
1 // ***************************************************************************
2 // bamtools_utilities.h (c) 2010 Derek Barnett, Erik Garrison
3 // Marth Lab, Department of Biology, Boston College
4 // All rights reserved.
5 // ---------------------------------------------------------------------------
6 // Last modified: 26 January 2011
7 // ---------------------------------------------------------------------------
8 // Provides general utilities used by BamTools sub-tools.
9 // ***************************************************************************
10
11 #ifndef BAMTOOLS_UTILITIES_H
12 #define BAMTOOLS_UTILITIES_H
13
14 #include <api/BamAux.h>
15 #include <utils/utils_global.h>
16 #include <cassert>
17 #include <stdexcept>
18 #include <string>
19
20 #define BAMTOOLS_ASSERT_UNREACHABLE assert( false )
21 #define BAMTOOLS_ASSERT_MESSAGE( condition, message ) if (!( condition )) throw std::runtime_error( message );
22
23 namespace BamTools {
24
25 class BamReader;
26 class BamMultiReader;
27
28 class UTILS_EXPORT Utilities {
29   
30     public: 
31         // check if a file exists
32         static bool FileExists(const std::string& fname);
33         
34         // Parses a region string, uses reader to do validation (valid ID's, positions), stores in Region struct
35         // Returns success (true/false)
36         static bool ParseRegionString(const std::string& regionString,
37                                       const BamReader& reader,
38                                       BamRegion& region);
39         // Same as above, but accepts a BamMultiReader
40         static bool ParseRegionString(const std::string& regionString,
41                                       const BamMultiReader& reader,
42                                       BamRegion& region);
43
44         // sequence utilities
45         static void Reverse(std::string& sequence);
46         static void ReverseComplement(std::string& sequence);
47 };
48
49 } // namespace BamTools
50   
51 #endif // BAMTOOLS_UTILITIES_H