X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=mothur.h;h=23b9f189c992f97e2e9a47823cacce62db363696;hb=f5023c911c377e5320c5110c78af98dd8841ef58;hp=29124330420f1af5e8a7b5f54fb8f86689e20ee9;hpb=5ff964d3871ce86f59fec3052f9c25e872f22c42;p=mothur.git diff --git a/mothur.h b/mothur.h index 2912433..23b9f18 100644 --- a/mothur.h +++ b/mothur.h @@ -45,20 +45,21 @@ #include #include -using namespace std; -#ifdef _WIN32 - #define exp(x) (exp((double) x)) - #define sqrt(x) (sqrt((double) x)) - #define log10(x) (log10((double) x)) - #define log2(x) (log10(x)/log10(2)) - #define isnan(x) ((x) != (x)) - #define isinf(x) (fabs(x) == std::numeric_limits::infinity()) -#else +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) #include #include #endif +using namespace std; + +#define exp(x) (exp((double) x)) +#define sqrt(x) (sqrt((double) x)) +#define log10(x) (log10((double) x)) +#define log2(x) (log10(x)/log10(2)) +#define isnan(x) ((x) != (x)) +#define isinf(x) (fabs(x) == std::numeric_limits::infinity()) + typedef unsigned long ull; @@ -77,6 +78,14 @@ struct ThreadNode { IntNode* right; }; +/************************************************************/ +struct clusterNode { + int numSeq; + int parent; + int smallChild; //used to make linkTable work with list and rabund. represents bin number of this cluster node + clusterNode(int num, int par, int kid) : numSeq(num), parent(par), smallChild(kid) {}; +}; + /***********************************************************************/ // snagged from http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.2 @@ -96,6 +105,7 @@ inline void convert(const string& s, T& x, bool failIfLeftoverChars = true){ if (!(i >> x) || (failIfLeftoverChars && i.get(c))) throw BadConversion(s); } + //********************************************************************************************************************** template @@ -169,6 +179,16 @@ inline int openOutputFileAppend(string fileName, ofstream& fileHandle){ } /***********************************************************************/ +inline void gobble(istream& f){ + + char d; + while(isspace(d=f.get())) {;} + f.putback(d); + +} + +/***********************************************************************/ + inline string getline(ifstream& fileHandle) { try { @@ -179,7 +199,7 @@ inline string getline(ifstream& fileHandle) { char c = fileHandle.get(); //are you at the end of the line - if (c == 10 || c == 13){ break; } + if ((c == '\n') || (c == '\r') || (c == '\f')){ break; } else { line += c; } } @@ -255,7 +275,7 @@ inline void errorOut(exception& e, string object, string function) { mothurOut("Error: "); mothurOut(toString(e.what())); - mothurOut(" has occurred in the " + object + " class function " + function + ". Please contact Pat Schloss at pschloss@microbio.umass.edu, and be sure to include the mothur.logFile with your inquiry."); + mothurOut(" has occurred in the " + object + " class function " + function + ". Please contact Pat Schloss at mothur.bugs@gmail.com, and be sure to include the mothur.logFile with your inquiry."); mothurOutEndLine(); } @@ -263,15 +283,6 @@ inline void errorOut(exception& e, string object, string function) { -/***********************************************************************/ - -inline void gobble(istream& f){ - - char d; - while(isspace(d=f.get())) {;} - f.putback(d); - -} /***********************************************************************/ inline bool isTrue(string f){ @@ -422,6 +433,10 @@ inline int openInputFile(string fileName, ifstream& fileHandle){ return 1; } else { + //check for blank file + gobble(fileHandle); + if (fileHandle.eof()) { mothurOut(fileName + " is blank. Please correct."); mothurOutEndLine(); return 1; } + return 0; }