X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=mothur.h;h=ec56c506c8c0c7654c4e436afa16222f14b1224f;hb=e7fe6dd9db877b98c362f9524c3130bbbd037200;hp=07bb971347d974066ab5449614172c5e68d4c2a6;hpb=a8f5a612bba54ceb74e17efc027d3a7f5aa93c9a;p=mothur.git diff --git a/mothur.h b/mothur.h index 07bb971..ec56c50 100644 --- a/mothur.h +++ b/mothur.h @@ -40,6 +40,15 @@ using namespace std; #include #include #include +#include + +#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)) +#endif + typedef unsigned long long ull; @@ -51,7 +60,13 @@ struct IntNode { IntNode* left; IntNode* right; }; - + +struct ThreadNode { + int* pid; + IntNode* left; + IntNode* right; +}; + /***********************************************************************/ // snagged from http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.2 @@ -139,6 +154,13 @@ inline void gobble(istream& f){ f.putback(d); } +/***********************************************************************/ + +inline bool isTrue(string f){ + + if ((f == "TRUE") || (f == "T") || (f == "true") || (f == "t")) { return true; } + else { return false; } +} /***********************************************************************/ @@ -224,6 +246,7 @@ inline string getSimpleName(string longName){ return simpleName; } + /***********************************************************************/ inline int factorial(int num){ @@ -249,7 +272,7 @@ inline string getPathName(string longName){ string rootPathName = longName; - if(longName.find_last_of("/") != longName.npos){ + if(longName.find_last_of('/') != longName.npos){ int pos = longName.find_last_of('/')+1; rootPathName = longName.substr(0, pos); } @@ -259,6 +282,20 @@ inline string getPathName(string longName){ /***********************************************************************/ +inline string getExtension(string longName){ + + string extension = longName; + + if(longName.find_last_of('.') != longName.npos){ + int pos = longName.find_last_of('.'); + extension = longName.substr(pos, longName.length()); + } + + return extension; +} + +/***********************************************************************/ + inline int openInputFile(string fileName, ifstream& fileHandle){ fileHandle.open(fileName.c_str()); @@ -302,6 +339,16 @@ inline int openOutputFileAppend(string fileName, ofstream& fileHandle){ } +/***********************************************************************/ + +inline int getNumSeqs(ifstream& file){ + + int numSeqs = count(istreambuf_iterator(file),istreambuf_iterator(), '>'); + file.seekg(0); + return numSeqs; + +} + /***********************************************************************/ //This function parses the estimator options and puts them in a vector