]> git.donarmstrong.com Git - mothur.git/blobdiff - mothur.h
mothur v.1.4.1
[mothur.git] / mothur.h
index 670a32c8326a76da2cf894cac0d7ad10a9a10825..e5d1113790decbacf45913e7d6ce11d2826de598 100644 (file)
--- a/mothur.h
+++ b/mothur.h
@@ -1,7 +1,6 @@
 #ifndef MOTHUR_H
 #define MOTHUR_H
 
-using namespace std;
 
 
 /*
@@ -41,6 +40,26 @@ using namespace std;
 #include <math.h>
 #include <algorithm>
 
+//misc
+#include <cerrno>
+#include <ctime>
+#include <limits>
+
+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<double>::infinity())
+#else
+       #include <sys/wait.h>
+       #include <unistd.h>
+#endif
+
+
 typedef unsigned long long ull;
 
 struct IntNode {
@@ -51,7 +70,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 +164,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 +256,7 @@ inline string getSimpleName(string longName){
 
        return simpleName;
 }
+
 /***********************************************************************/
 
 inline int factorial(int num){
@@ -316,6 +349,16 @@ inline int openOutputFileAppend(string fileName, ofstream& fileHandle){
 }
 
 
+/***********************************************************************/
+
+inline int getNumSeqs(ifstream& file){
+       
+       int numSeqs = count(istreambuf_iterator<char>(file),istreambuf_iterator<char>(), '>');
+       file.seekg(0);
+       return numSeqs;
+
+}
+
 /***********************************************************************/
 
 //This function parses the estimator options and puts them in a vector