]> git.donarmstrong.com Git - bamtools.git/blob - src/utils/bamtools_utilities.h
Merge branch 'master' of git://github.com/pezmaster31/bamtools
[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: 30 August 2010
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 <cassert>
15 #include <stdexcept>
16 #include <string>
17 #include "BamAux.h"
18
19 #define BAMTOOLS_ASSERT_UNREACHABLE assert( false )
20 #define BAMTOOLS_ASSERT_MESSAGE( condition, message ) if (!( condition )) throw std::runtime_error( message );
21
22 namespace BamTools {
23
24 class BamReader;
25 class BamMultiReader;
26
27 class Utilities {
28   
29     public: 
30         // check if a file exists
31         static bool FileExists(const std::string& fname);
32         
33         // Parses a region string, uses reader to do validation (valid ID's, positions), stores in Region struct
34         // Returns success (true/false)
35         static bool ParseRegionString(const std::string& regionString, const BamReader& reader, BamRegion& region);
36         // Same as above, but accepts a BamMultiReader
37         static bool ParseRegionString(const std::string& regionString, const BamMultiReader& reader, BamRegion& region);
38
39          
40 };
41
42 } // namespace BamTools
43   
44 #endif // BAMTOOLS_UTILITIES_H