]> git.donarmstrong.com Git - bamtools.git/commitdiff
Updated bamtools_utilities with #defines
authorDerek <derekwbarnett@gmail.com>
Mon, 30 Aug 2010 20:12:23 +0000 (16:12 -0400)
committerDerek <derekwbarnett@gmail.com>
Mon, 30 Aug 2010 20:12:23 +0000 (16:12 -0400)
src/utils/bamtools_utilities.cpp
src/utils/bamtools_utilities.h

index 7772587e84c10fe2289535244cd4c723f3986f54..8fd0b2f988f5cd3567cc5b6181f3acc5a6450b4c 100644 (file)
@@ -3,7 +3,7 @@
 // Marth Lab, Department of Biology, Boston College
 // All rights reserved.
 // ---------------------------------------------------------------------------
-// Last modified: 2 June 2010
+// Last modified: 30 August 2010
 // ---------------------------------------------------------------------------
 // Provides general utilities used by BamTools sub-tools.
 // ***************************************************************************
 #include "bamtools_utilities.h"
 #include "BamReader.h"
 #include "BamMultiReader.h"
-
 using namespace std;
 using namespace BamTools;
 
+// check if a file exists
+bool Utilities::FileExists(const std::string& filename) { 
+    struct stat fileInfo; 
+    return stat(filename.c_str(), &fileInfo) == 0;
+}
+
 // Parses a region string, does validation (valid ID's, positions), stores in Region struct
 // Returns success (true/false)
 bool Utilities::ParseRegionString(const std::string& regionString, const BamReader& reader, BamRegion& region) {
@@ -232,10 +237,3 @@ bool Utilities::ParseRegionString(const std::string& regionString, const BamMult
 
     return true;
 }
-
-bool Utilities::FileExists(const std::string& filename) { 
-
-    struct stat fileInfo; 
-    return stat(filename.c_str(), &fileInfo) == 0;
-
-}
index 4f6928b6832fb9a3b2299626fed22b40e5611b56..f72897a9112876121da2054e154e0720763ea3a2 100644 (file)
@@ -3,7 +3,7 @@
 // Marth Lab, Department of Biology, Boston College
 // All rights reserved.
 // ---------------------------------------------------------------------------
-// Last modified: 2 June 2010
+// Last modified: 30 August 2010
 // ---------------------------------------------------------------------------
 // Provides general utilities used by BamTools sub-tools.
 // ***************************************************************************
 #ifndef BAMTOOLS_UTILITIES_H
 #define BAMTOOLS_UTILITIES_H
 
+#include <cassert>
+#include <stdexcept>
 #include <string>
 #include "BamAux.h"
 
+#define BAMTOOLS_ASSERT_UNREACHABLE assert( false )
+#define BAMTOOLS_ASSERT_MESSAGE( condition, message ) if (!( condition )) throw std::runtime_error( message );
+
 namespace BamTools {
 
 class BamReader;
@@ -21,15 +26,17 @@ class BamMultiReader;
 
 class Utilities {
   
-    public:                          
+    public: 
+        // check if a file exists
+        static bool FileExists(const std::string& fname);
+        
         // Parses a region string, uses reader to do validation (valid ID's, positions), stores in Region struct
         // Returns success (true/false)
         static bool ParseRegionString(const std::string& regionString, const BamReader& reader, BamRegion& region);
         // Same as above, but accepts a BamMultiReader
         static bool ParseRegionString(const std::string& regionString, const BamMultiReader& reader, BamRegion& region);
 
-        // check if a file exists
-        static bool FileExists(const std::string& fname); 
+         
 };
 
 } // namespace BamTools