#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
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
#include <sys/wait.h>
#include <unistd.h>
#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<double>::infinity())
-typedef unsigned long long ull;
+
+typedef unsigned long ull;
struct IntNode {
int lvalue;
int rcoef;
IntNode* left;
IntNode* right;
+
+ IntNode(int lv, int rv, IntNode* l, IntNode* r) : lvalue(lv), rvalue(rv), left(l), right(r) {};
+ IntNode() {};
};
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
if (!(i >> x) || (failIfLeftoverChars && i.get(c)))
throw BadConversion(s);
}
+
//**********************************************************************************************************************
template<typename T>
return output.str();
}
-
/***********************************************************************/
inline int openOutputFileAppend(string fileName, ofstream& fileHandle){
fileHandle.open(fileName.c_str(), ios::app);
if(!fileHandle) {
- cerr << "Error: Could not open " << fileName << endl;
+ cout << "Error: Could not open " << fileName << endl;
return 1;
}
else {
}
}
+/***********************************************************************/
+inline void gobble(istream& f){
+
+ char d;
+ while(isspace(d=f.get())) {;}
+ f.putback(d);
+
+}
+
+/***********************************************************************/
+
+inline string getline(ifstream& fileHandle) {
+ try {
+
+ string line = "";
+
+ while (!fileHandle.eof()) {
+ //get next character
+ char c = fileHandle.get();
+
+ //are you at the end of the line
+ if ((c == '\n') || (c == '\r') || (c == '\f')){ break; }
+ else { line += c; }
+ }
+
+ return line;
+
+ }
+ catch(exception& e) {
+ cout << "Error in mothur function getline" << endl;
+ exit(1);
+ }
+}
/**************************************************************************************************/
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();
}
-/***********************************************************************/
-inline void gobble(istream& f){
-
- char d;
- while(isspace(d=f.get())) {;}
- f.putback(d);
-
-}
+
/***********************************************************************/
inline bool isTrue(string f){
fileHandle.open(fileName.c_str());
if(!fileHandle) {
- cerr << "Error: Could not open " << fileName << endl;
+ mothurOut("Error: Could not open " + fileName); mothurOutEndLine();
return 1;
}
else {
+ //check for blank file
+ gobble(fileHandle);
+ if (fileHandle.eof()) { mothurOut(fileName + " is blank. Please correct."); mothurOutEndLine(); return 1; }
+
return 0;
}
fileHandle.open(fileName.c_str(), ios::trunc);
if(!fileHandle) {
- cerr << "Error: Could not open " << fileName << endl;
+ mothurOut("Error: Could not open " + fileName); mothurOutEndLine();
return 1;
}
else {