]> git.donarmstrong.com Git - mothur.git/blobdiff - mothur.h
modified the engine to extract the path of mothur executable if argv does not contain...
[mothur.git] / mothur.h
index 93f96df30c73fa91b7119b07eadb27a89dc5109d..f1b13920d0a4c8941214dbf3e42c96ed4ce39486 100644 (file)
--- a/mothur.h
+++ b/mothur.h
@@ -54,6 +54,8 @@
 
 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
        #include <sys/wait.h>
+       #include <sys/time.h>
+       #include <sys/resource.h>
        #include <unistd.h>
        
        #ifdef USE_READLINE
@@ -660,6 +662,29 @@ inline bool inVector(string member, vector<string> group){
 }
 /***********************************************************************/
 
+//This function parses the estimator options and puts them in a vector
+inline void splitAtChar(string& estim, vector<string>& container, char symbol) {
+       try {
+               string individual;
+               
+               while (estim.find_first_of(symbol) != -1) {
+                       individual = estim.substr(0,estim.find_first_of(symbol));
+                       if ((estim.find_first_of(symbol)+1) <= estim.length()) { //checks to make sure you don't have dash at end of string
+                               estim = estim.substr(estim.find_first_of(symbol)+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 mothur.h function splitAtDash. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
+               exit(1);
+       }       
+}
+
+/***********************************************************************/
+
 //This function parses the estimator options and puts them in a vector
 inline void splitAtDash(string& estim, vector<string>& container) {
        try {
@@ -786,6 +811,7 @@ inline void splitAtEquals(string& key, string& value){
                exit(1);
        }       
 }
+
 /**************************************************************************************************/
 
 inline bool inUsersGroups(string groupname, vector<string> Groups) {
@@ -990,9 +1016,9 @@ inline string sortFile(string distFile, string outputDir){
        }       
 }
 /**************************************************************************************************/
-inline vector<long> setFilePosFasta(string filename, int& num) {
+inline vector<unsigned long int> setFilePosFasta(string filename, int& num) {
 
-                       vector<long> positions;
+                       vector<unsigned long int> positions;
                        ifstream inFASTA;
                        openInputFile(filename, inFASTA);
                                
@@ -1000,7 +1026,7 @@ inline vector<long> setFilePosFasta(string filename, int& num) {
                        while(!inFASTA.eof()){
                                input = getline(inFASTA); gobble(inFASTA);
                                if (input.length() != 0) {
-                                       if(input[0] == '>'){    long pos = inFASTA.tellg(); positions.push_back(pos - input.length() - 1);      }
+                                       if(input[0] == '>'){    unsigned long int pos = inFASTA.tellg(); positions.push_back(pos - input.length() - 1); }
                                }
                        }
                        inFASTA.close();
@@ -1019,7 +1045,7 @@ inline vector<long> setFilePosFasta(string filename, int& num) {
                                fclose (pFile);
                        }*/
                        
-                       long size = positions[(positions.size()-1)];
+                       unsigned long int size = positions[(positions.size()-1)];
                        ifstream in;
                        openInputFile(filename, in);
                        
@@ -1036,18 +1062,18 @@ inline vector<long> setFilePosFasta(string filename, int& num) {
                        return positions;
 }
 /**************************************************************************************************/
-inline vector<long> setFilePosEachLine(string filename, int& num) {
+inline vector<unsigned long int> setFilePosEachLine(string filename, int& num) {
 
-                       vector<long> positions;
+                       vector<unsigned long int> positions;
                        ifstream in;
                        openInputFile(filename, in);
                                
                        string input;
                        while(!in.eof()){
-                               long lastpos = in.tellg();
+                               unsigned long int lastpos = in.tellg();
                                input = getline(in); gobble(in);
                                if (input.length() != 0) {
-                                       long pos = in.tellg(); 
+                                       unsigned long int pos = in.tellg(); 
                                        if (pos != -1) { positions.push_back(pos - input.length() - 1); }
                                        else {  positions.push_back(lastpos);  }
                                }
@@ -1057,7 +1083,7 @@ inline vector<long> setFilePosEachLine(string filename, int& num) {
                        num = positions.size();
                
                        FILE * pFile;
-                       long size;
+                       unsigned long int size;
                
                        //get num bytes in file
                        pFile = fopen (filename.c_str(),"rb");