using namespace std;
-#include <iostream>
-#include <iomanip>
-#include <fstream>
-#include <sstream>
-#include <cmath>
-#include <vector>
-#include <stdexcept>
-#include <set>
+#include "mothur.h"
+#include "treemap.h"
typedef unsigned long long ull;
if (!(i >> x) || (failIfLeftoverChars && i.get(c)))
throw BadConversion(s);
}
+//**********************************************************************************************************************
+
+template<typename T>
+inline bool convertTest(const string& s, T& x, bool failIfLeftoverChars = true){
+ istringstream i(s);
+ char c;
+ if (!(i >> x) || (failIfLeftoverChars && i.get(c)))
+ {
+ cout << "'" << s << "' is unable to be converted into an integer.\n";
+ return false;
+ }
+ return true;
+}
//**********************************************************************************************************************
//**********************************************************************************************************************
+template<typename T>
+string toHex(const T&x){
+ stringstream output;
+
+ output << hex << x;
+
+ return output.str();
+}
+
+//**********************************************************************************************************************
+
template<typename T>
string toString(const T&x, int i){
stringstream output;
}
/***********************************************************************/
+//This function parses the a string and puts peices in a vector
+inline void splitAtComma(string& estim, vector<string>& container) {
+ try {
+ string individual;
+
+ while (estim.find_first_of(',') != -1) {
+ individual = estim.substr(0,estim.find_first_of(','));
+ if ((estim.find_first_of(',')+1) <= estim.length()) { //checks to make sure you don't have comma at end of string
+ estim = estim.substr(estim.find_first_of(',')+1, estim.length());
+ container.push_back(individual);
+ }
+ }
+ //get last one
+ container.push_back(estim);
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the utilities class Function splitAtComma. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the utilities class function splitAtComma. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+/***********************************************************************/
//This function splits up the various option parameters
inline void splitAtComma(string& prefix, string& suffix){
try {
prefix = suffix.substr(0,suffix.find_first_of(','));
if ((suffix.find_first_of(',')+2) <= suffix.length()) { //checks to make sure you don't have comma at end of string
- suffix = suffix.substr(suffix.find_first_of(',')+2, suffix.length());
+ suffix = suffix.substr(suffix.find_first_of(',')+1, suffix.length());
+ string space = " ";
+ while(suffix.at(0) == ' ')
+ suffix = suffix.substr(1, suffix.length());
}
+
}
catch(exception& e) {
cout << "Standard Error: " << e.what() << " has occurred in the utilities class Function splitAtComma. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
}
}
-/*******************************************************/
-
+/**************************************************************************************************/
+inline bool inUsersGroups(string groupname, vector<string> Groups) {
+ try {
+ for (int i = 0; i < Groups.size(); i++) {
+ if (groupname == Groups[i]) { return true; }
+ }
+ return false;
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the utilities class Function inUsersGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the utilities class function inUsersGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
#endif