// 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) {
return true;
}
-
-bool Utilities::FileExists(const std::string& filename) {
-
- struct stat fileInfo;
- return stat(filename.c_str(), &fileInfo) == 0;
-
-}
// 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;
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