10 * Created by Sarah Westcott on 2/19/09.
11 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
15 /* This file contains all the standard incudes we use in the project as well as some common utilities. */
53 /***********************************************************************/
55 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
58 #include <sys/resource.h>
62 #include <readline/readline.h>
63 #include <readline/history.h>
67 #include <conio.h> //allows unbuffered screen capture from stdin
68 #include <direct.h> //get cwd
76 #define exp(x) (exp((double) x))
77 #define sqrt(x) (sqrt((double) x))
78 #define log10(x) (log10((double) x))
79 #define log2(x) (log10(x)/log10(2))
80 #define isnan(x) ((x) != (x))
81 #define isinf(x) (fabs(x) == std::numeric_limits<double>::infinity())
83 typedef unsigned long ull;
93 IntNode(int lv, int rv, IntNode* l, IntNode* r) : lvalue(lv), rvalue(rv), left(l), right(r) {};
103 /************************************************************/
107 int smallChild; //used to make linkTable work with list and rabund. represents bin number of this cluster node
108 clusterNode(int num, int par, int kid) : numSeq(num), parent(par), smallChild(kid) {};
110 /************************************************************/
116 seqDist(int s1, int s2, float d) : seq1(s1), seq2(s2), dist(d) {}
119 //********************************************************************************************************************
120 //sorts lowest to highest
121 inline bool compareSequenceDistance(seqDist left, seqDist right){
122 return (left.dist < right.dist);
124 /***********************************************************************/
126 // snagged from http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.2
127 // works for now, but there should be a way to do it without killing the whole program
129 class BadConversion : public runtime_error {
131 BadConversion(const string& s) : runtime_error(s){ }
134 //**********************************************************************************************************************
137 inline void convert(const string& s, T& x, bool failIfLeftoverChars = true){
140 if (!(i >> x) || (failIfLeftoverChars && i.get(c)))
141 throw BadConversion(s);
144 //**********************************************************************************************************************
147 inline bool convertTestFloat(const string& s, T& x, bool failIfLeftoverChars = true){
150 if (!(i >> x) || (failIfLeftoverChars && i.get(c)))
157 //**********************************************************************************************************************
160 inline bool convertTest(const string& s, T& x, bool failIfLeftoverChars = true){
163 if (!(i >> x) || (failIfLeftoverChars && i.get(c)))
165 cout << "unable to be converted into an integer.\n" << endl;
171 //**********************************************************************************************************************
174 string toString(const T&x){
180 //**********************************************************************************************************************
183 string toHex(const T&x){
190 //**********************************************************************************************************************
193 string toString(const T&x, int i){
197 output << fixed << x;
201 /***********************************************************************/
202 inline int openOutputFileAppend(string fileName, ofstream& fileHandle){
204 fileHandle.open(fileName.c_str(), ios::app);
206 cout << "Error: Could not open " << fileName << endl;
214 /***********************************************************************/
216 inline void gobble(istream& f){
219 while(isspace(d=f.get())) {;}
223 /***********************************************************************/
225 inline string getline(istringstream& fileHandle) {
230 while (!fileHandle.eof()) {
232 char c = fileHandle.get();
234 //are you at the end of the line
235 if ((c == '\n') || (c == '\r') || (c == '\f')){ break; }
242 catch(exception& e) {
243 cout << "Error in mothur function getline" << endl;
247 /***********************************************************************/
249 inline string getline(ifstream& fileHandle) {
254 while (!fileHandle.eof()) {
256 char c = fileHandle.get();
258 //are you at the end of the line
259 if ((c == '\n') || (c == '\r') || (c == '\f')){ break; }
266 catch(exception& e) {
267 cout << "Error in mothur function getline" << endl;
271 /***********************************************************************/
273 inline bool isTrue(string f){
275 if ((f == "TRUE") || (f == "T") || (f == "true") || (f == "t")) { return true; }
276 else { return false; }
279 /***********************************************************************/
281 inline float roundDist(float dist, int precision){
283 return int(dist * precision + 0.5)/float(precision);
286 /***********************************************************************/
288 inline float ceilDist(float dist, int precision){
290 return int(ceil(dist * precision))/float(precision);
294 /***********************************************************************/
296 inline int getNumNames(string names){
302 for(int i=0;i<names.size();i++){
313 /**************************************************************************************************/
315 inline vector<vector<double> > binomial(int maxOrder){
317 vector<vector<double> > binomial(maxOrder+1);
319 for(int i=0;i<=maxOrder;i++){
320 binomial[i].resize(maxOrder+1);
329 for(int i=2;i<=maxOrder;i++){
333 for(int i=2;i<=maxOrder;i++){
334 for(int j=1;j<=maxOrder;j++){
335 if(i==j){ binomial[i][j]=1; }
336 if(j>i) { binomial[i][j]=0; }
337 else { binomial[i][j]=binomial[i-1][j-1]+binomial[i-1][j]; }
344 /***********************************************************************/
346 inline string getRootName(string longName){
348 string rootName = longName;
350 if(longName.find_last_of(".") != longName.npos){
351 int pos = longName.find_last_of('.')+1;
352 rootName = longName.substr(0, pos);
357 /***********************************************************************/
359 inline string getSimpleName(string longName){
361 string simpleName = longName;
364 found=longName.find_last_of("/\\");
366 if(found != longName.npos){
367 simpleName = longName.substr(found+1);
370 //if(longName.find_last_of("/") != longName.npos){
371 // int pos = longName.find_last_of('/')+1;
372 // simpleName = longName.substr(pos, longName.length());
378 /***********************************************************************/
380 inline int factorial(int num){
383 for (int i = 1; i <= num; i++) {
389 /**************************************************************************************************
391 double min(double x, double y)
397 /***********************************************************************/
399 inline string getPathName(string longName){
401 string rootPathName = longName;
403 if(longName.find_last_of("/\\") != longName.npos){
404 int pos = longName.find_last_of("/\\")+1;
405 rootPathName = longName.substr(0, pos);
410 /***********************************************************************/
412 inline string hasPath(string longName){
417 found=longName.find_last_of("~/\\");
419 if(found != longName.npos){
420 path = longName.substr(0, found+1);
426 /***********************************************************************/
428 inline string getExtension(string longName){
430 string extension = longName;
432 if(longName.find_last_of('.') != longName.npos){
433 int pos = longName.find_last_of('.');
434 extension = longName.substr(pos, longName.length());
439 /***********************************************************************/
440 inline bool isBlank(string fileName){
443 fileHandle.open(fileName.c_str());
445 cout << "Error: Could not open " << fileName << endl;
448 //check for blank file
450 if (fileHandle.eof()) { fileHandle.close(); return true; }
454 /***********************************************************************/
456 inline string getFullPathName(string fileName){
459 string path = hasPath(fileName);
463 if (path == "") { return fileName; } //its a simple name
464 else { //we need to complete the pathname
465 // ex. ../../../filename
466 // cwd = /user/work/desktop
469 //get current working directory
470 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
472 if (path.find("~") != -1) { //go to home directory
473 string homeDir = getenv ("HOME");
474 newFileName = homeDir + fileName.substr(fileName.find("~")+1);
477 if (path.rfind("./") == -1) { return fileName; } //already complete name
478 else { newFileName = fileName.substr(fileName.rfind("./")+2); } //save the complete part of the name
480 char* cwdpath = new char[1024];
483 cwdpath=getcwd(cwdpath,size);
489 if (cwd.length() > 0) { simpleCWD = cwd.substr(1); }
491 //break apart the current working directory
493 while (simpleCWD.find_first_of('/') != -1) {
494 string dir = simpleCWD.substr(0,simpleCWD.find_first_of('/'));
495 simpleCWD = simpleCWD.substr(simpleCWD.find_first_of('/')+1, simpleCWD.length());
498 //get last one // ex. ../../../filename = /user/work/desktop/filename
499 dirs.push_back(simpleCWD); //ex. dirs[0] = user, dirs[1] = work, dirs[2] = desktop
502 int index = dirs.size()-1;
504 while((pos = path.rfind("./")) != -1) { //while you don't have a complete path
505 if (pos == 0) { break; //you are at the end
506 }else if (path[(pos-1)] == '.') { //you want your parent directory ../
507 path = path.substr(0, pos-1);
509 if (index == 0) { break; }
510 }else if (path[(pos-1)] == '/') { //you want the current working dir ./
511 path = path.substr(0, pos);
512 }else if (pos == 1) { break; //you are at the end
513 }else { cout << "cannot resolve path for " << fileName << endl; return fileName; }
516 for (int i = index; i >= 0; i--) {
517 newFileName = dirs[i] + "/" + newFileName;
520 newFileName = "/" + newFileName;
524 if (path.find("~") != -1) { //go to home directory
525 string homeDir = getenv ("HOMEPATH");
526 newFileName = homeDir + fileName.substr(fileName.find("~")+1);
529 if (path.rfind(".\\") == -1) { return fileName; } //already complete name
530 else { newFileName = fileName.substr(fileName.rfind(".\\")+2); } //save the complete part of the name
532 char *cwdpath = NULL;
533 cwdpath = getcwd(NULL, 0); // or _getcwd
534 if ( cwdpath != NULL) { cwd = cwdpath; }
537 //break apart the current working directory
539 while (cwd.find_first_of('\\') != -1) {
540 string dir = cwd.substr(0,cwd.find_first_of('\\'));
541 cwd = cwd.substr(cwd.find_first_of('\\')+1, cwd.length());
546 dirs.push_back(cwd); //ex. dirs[0] = user, dirs[1] = work, dirs[2] = desktop
548 int index = dirs.size()-1;
550 while((pos = path.rfind(".\\")) != -1) { //while you don't have a complete path
551 if (pos == 0) { break; //you are at the end
552 }else if (path[(pos-1)] == '.') { //you want your parent directory ../
553 path = path.substr(0, pos-1);
555 if (index == 0) { break; }
556 }else if (path[(pos-1)] == '\\') { //you want the current working dir ./
557 path = path.substr(0, pos);
558 }else if (pos == 1) { break; //you are at the end
559 }else { cout << "cannot resolve path for " << fileName << endl; return fileName; }
562 for (int i = index; i >= 0; i--) {
563 newFileName = dirs[i] + "\\" + newFileName;
572 catch(exception& e) {
573 cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function getFullPathName. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
577 /***********************************************************************/
579 inline int openInputFile(string fileName, ifstream& fileHandle, string m){
582 string completeFileName = getFullPathName(fileName);
584 fileHandle.open(completeFileName.c_str());
588 //check for blank file
593 /***********************************************************************/
595 inline int openInputFile(string fileName, ifstream& fileHandle){
598 string completeFileName = getFullPathName(fileName);
600 fileHandle.open(completeFileName.c_str());
602 cout << "Error: Could not open " << completeFileName << endl;
606 //check for blank file
608 if (fileHandle.eof()) { cout << completeFileName << " is blank. Please correct." << endl; }
614 /***********************************************************************/
616 inline int renameFile(string oldName, string newName){
619 int exist = openInputFile(newName, inTest, "");
621 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
622 if (exist == 0) { //you could open it so you want to delete it
624 string command = "rm " + newName;
625 system(command.c_str());
628 string command = "mv " + oldName + " " + newName;
629 system(command.c_str());
631 remove(newName.c_str());
632 int renameOk = rename(oldName.c_str(), newName.c_str());
637 /***********************************************************************/
639 inline int openOutputFile(string fileName, ofstream& fileHandle){
641 string completeFileName = getFullPathName(fileName);
643 fileHandle.open(completeFileName.c_str(), ios::trunc);
645 cout << "Error: Could not open " << completeFileName << endl;
654 /***********************************************************************/
656 inline int getNumSeqs(ifstream& file){
658 int numSeqs = count(istreambuf_iterator<char>(file),istreambuf_iterator<char>(), '>');
663 /***********************************************************************/
664 inline void getNumSeqs(ifstream& file, int& numSeqs){
669 input = getline(file);
670 if (input.length() != 0) {
671 if(input[0] == '>'){ numSeqs++; }
676 /***********************************************************************/
678 inline bool inVector(string member, vector<string> group){
680 for (int i = 0; i < group.size(); i++) {
681 if (group[i] == member) { return true; }
686 /***********************************************************************/
688 //This function parses the estimator options and puts them in a vector
689 inline void splitAtChar(string& estim, vector<string>& container, char symbol) {
693 while (estim.find_first_of(symbol) != -1) {
694 individual = estim.substr(0,estim.find_first_of(symbol));
695 if ((estim.find_first_of(symbol)+1) <= estim.length()) { //checks to make sure you don't have dash at end of string
696 estim = estim.substr(estim.find_first_of(symbol)+1, estim.length());
697 container.push_back(individual);
701 container.push_back(estim);
703 catch(exception& e) {
704 cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function splitAtDash. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
709 /***********************************************************************/
711 //This function parses the estimator options and puts them in a vector
712 inline void splitAtDash(string& estim, vector<string>& container) {
716 while (estim.find_first_of('-') != -1) {
717 individual = estim.substr(0,estim.find_first_of('-'));
718 if ((estim.find_first_of('-')+1) <= estim.length()) { //checks to make sure you don't have dash at end of string
719 estim = estim.substr(estim.find_first_of('-')+1, estim.length());
720 container.push_back(individual);
724 container.push_back(estim);
726 catch(exception& e) {
727 cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function splitAtDash. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
732 /***********************************************************************/
733 //This function parses the label options and puts them in a set
734 inline void splitAtDash(string& estim, set<string>& container) {
738 while (estim.find_first_of('-') != -1) {
739 individual = estim.substr(0,estim.find_first_of('-'));
740 if ((estim.find_first_of('-')+1) <= estim.length()) { //checks to make sure you don't have dash at end of string
741 estim = estim.substr(estim.find_first_of('-')+1, estim.length());
742 container.insert(individual);
746 container.insert(estim);
748 catch(exception& e) {
749 cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function splitAtDash. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
753 /***********************************************************************/
754 //This function parses the line options and puts them in a set
755 inline void splitAtDash(string& estim, set<int>& container) {
760 while (estim.find_first_of('-') != -1) {
761 individual = estim.substr(0,estim.find_first_of('-'));
762 if ((estim.find_first_of('-')+1) <= estim.length()) { //checks to make sure you don't have dash at end of string
763 estim = estim.substr(estim.find_first_of('-')+1, estim.length());
764 convert(individual, lineNum); //convert the string to int
765 container.insert(lineNum);
769 convert(estim, lineNum); //convert the string to int
770 container.insert(lineNum);
772 catch(exception& e) {
773 cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function splitAtDash. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
777 /***********************************************************************/
778 //This function parses the a string and puts peices in a vector
779 inline void splitAtComma(string& estim, vector<string>& container) {
783 while (estim.find_first_of(',') != -1) {
784 individual = estim.substr(0,estim.find_first_of(','));
785 if ((estim.find_first_of(',')+1) <= estim.length()) { //checks to make sure you don't have comma at end of string
786 estim = estim.substr(estim.find_first_of(',')+1, estim.length());
787 container.push_back(individual);
791 container.push_back(estim);
793 catch(exception& e) {
794 cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function splitAtComma. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
798 /***********************************************************************/
800 //This function splits up the various option parameters
801 inline void splitAtComma(string& prefix, string& suffix){
803 prefix = suffix.substr(0,suffix.find_first_of(','));
804 if ((suffix.find_first_of(',')+2) <= suffix.length()) { //checks to make sure you don't have comma at end of string
805 suffix = suffix.substr(suffix.find_first_of(',')+1, suffix.length());
807 while(suffix.at(0) == ' ')
808 suffix = suffix.substr(1, suffix.length());
812 catch(exception& e) {
813 cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function splitAtComma. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
817 /***********************************************************************/
819 //This function separates the key value from the option value i.e. dist=96_...
820 inline void splitAtEquals(string& key, string& value){
822 if(value.find_first_of('=') != -1){
823 key = value.substr(0,value.find_first_of('='));
824 if ((value.find_first_of('=')+1) <= value.length()) {
825 value = value.substr(value.find_first_of('=')+1, value.length());
832 catch(exception& e) {
833 cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function splitAtEquals. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
838 /**************************************************************************************************/
840 inline bool inUsersGroups(string groupname, vector<string> Groups) {
842 for (int i = 0; i < Groups.size(); i++) {
843 if (groupname == Groups[i]) { return true; }
847 catch(exception& e) {
848 cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function inUsersGroups. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
852 /**************************************************************************************************/
853 //returns true if any of the strings in first vector are in second vector
854 inline bool inUsersGroups(vector<string> groupnames, vector<string> Groups) {
857 for (int i = 0; i < groupnames.size(); i++) {
858 if (inUsersGroups(groupnames[i], Groups)) { return true; }
862 catch(exception& e) {
863 cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function inUsersGroups. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
867 /***********************************************************************/
868 //this function determines if the user has given us labels that are smaller than the given label.
869 //if so then it returns true so that the calling function can run the previous valid distance.
870 //it's a "smart" distance function. It also checks for invalid labels.
871 inline bool anyLabelsToProcess(string label, set<string>& userLabels, string errorOff) {
874 set<string>::iterator it;
875 vector<float> orderFloat;
876 map<string, float> userMap; //the conversion process removes trailing 0's which we need to put back
877 map<string, float>::iterator it2;
879 bool smaller = false;
881 //unique is the smallest line
882 if (label == "unique") { return false; }
884 if (convertTestFloat(label, labelFloat)) {
885 convert(label, labelFloat);
886 }else { //cant convert
891 //go through users set and make them floats
892 for(it = userLabels.begin(); it != userLabels.end(); ++it) {
895 if ((*it != "unique") && (convertTestFloat(*it, temp) == true)){
897 orderFloat.push_back(temp);
899 }else if (*it == "unique") {
900 orderFloat.push_back(-1.0);
901 userMap["unique"] = -1.0;
903 if (errorOff == "") { cout << *it << " is not a valid label." << endl; }
904 userLabels.erase(*it);
910 sort(orderFloat.begin(), orderFloat.end());
912 /*************************************************/
913 //is this label bigger than any of the users labels
914 /*************************************************/
916 //loop through order until you find a label greater than label
917 for (int i = 0; i < orderFloat.size(); i++) {
918 if (orderFloat[i] < labelFloat) {
920 if (orderFloat[i] == -1) {
921 if (errorOff == "") { cout << "Your file does not include the label unique." << endl; }
922 userLabels.erase("unique");
925 if (errorOff == "") { cout << "Your file does not include the label " << endl; }
927 for (it2 = userMap.begin(); it2!= userMap.end(); it2++) {
928 if (it2->second == orderFloat[i]) {
930 //remove small labels
935 if (errorOff == "") {cout << s << ". I will use the next smallest distance. " << endl; }
937 //since they are sorted once you find a bigger one stop looking
944 catch(exception& e) {
945 cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function anyLabelsToProcess. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
950 /**************************************************************************************************/
951 inline void appendFiles(string temp, string filename) {
956 //open output file in append mode
957 openOutputFileAppend(filename, output);
958 int ableToOpen = openInputFile(temp, input, "no error");
960 if (ableToOpen == 0) { //you opened it
961 while(char c = input.get()){
962 if(input.eof()) { break; }
963 else { output << c; }
970 catch(exception& e) {
971 cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function appendFiles. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
976 /**************************************************************************************************/
977 inline string sortFile(string distFile, string outputDir){
980 //if (outputDir == "") { outputDir += hasPath(distFile); }
981 string outfile = getRootName(distFile) + "sorted.dist";
984 //if you can, use the unix sort since its been optimized for years
985 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
986 string command = "sort -n -k +3 " + distFile + " -o " + outfile;
987 system(command.c_str());
988 #else //you are stuck with my best attempt...
989 //windows sort does not have a way to specify a column, only a character in the line
990 //since we cannot assume that the distance will always be at the the same character location on each line
991 //due to variable sequence name lengths, I chose to force the distance into first position, then sort and then put it back.
993 //read in file line by file and put distance first
994 string tempDistFile = distFile + ".temp";
997 openInputFile(distFile, input);
998 openOutputFile(tempDistFile, output);
1000 string firstName, secondName;
1003 input >> firstName >> secondName >> dist;
1004 output << dist << '\t' << firstName << '\t' << secondName << endl;
1011 //sort using windows sort
1012 string tempOutfile = outfile + ".temp";
1013 string command = "sort " + tempDistFile + " /O " + tempOutfile;
1014 system(command.c_str());
1016 //read in sorted file and put distance at end again
1018 openInputFile(tempOutfile, input2);
1019 openOutputFile(outfile, output);
1022 input2 >> dist >> firstName >> secondName;
1023 output << firstName << '\t' << secondName << '\t' << dist << endl;
1030 remove(tempDistFile.c_str());
1031 remove(tempOutfile.c_str());
1036 catch(exception& e) {
1037 cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function sortfile. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
1041 /**************************************************************************************************/
1042 inline vector<unsigned long int> setFilePosFasta(string filename, int& num) {
1044 vector<unsigned long int> positions;
1046 openInputFile(filename, inFASTA);
1049 while(!inFASTA.eof()){
1050 input = getline(inFASTA); gobble(inFASTA);
1051 if (input.length() != 0) {
1052 if(input[0] == '>'){ unsigned long int pos = inFASTA.tellg(); positions.push_back(pos - input.length() - 1); }
1057 num = positions.size();
1062 //get num bytes in file
1063 pFile = fopen (filename.c_str(),"rb");
1064 if (pFile==NULL) perror ("Error opening file");
1066 fseek (pFile, 0, SEEK_END);
1071 unsigned long int size = positions[(positions.size()-1)];
1073 openInputFile(filename, in);
1077 while(char c = in.get()){
1078 if(in.eof()) { break; }
1083 positions.push_back(size);
1087 /**************************************************************************************************/
1088 inline vector<unsigned long int> setFilePosEachLine(string filename, int& num) {
1090 vector<unsigned long int> positions;
1092 openInputFile(filename, in);
1096 unsigned long int lastpos = in.tellg();
1097 input = getline(in); gobble(in);
1098 if (input.length() != 0) {
1099 unsigned long int pos = in.tellg();
1100 if (pos != -1) { positions.push_back(pos - input.length() - 1); }
1101 else { positions.push_back(lastpos); }
1106 num = positions.size();
1109 unsigned long int size;
1111 //get num bytes in file
1112 pFile = fopen (filename.c_str(),"rb");
1113 if (pFile==NULL) perror ("Error opening file");
1115 fseek (pFile, 0, SEEK_END);
1120 positions.push_back(size);
1124 /**************************************************************************************************/
1125 inline bool checkReleaseVersion(ifstream& file, string version) {
1130 string line = getline(file);
1132 //before we added this check
1133 if (line[0] != '#') { good = false; }
1136 line = line.substr(1);
1138 vector<string> versionVector;
1139 splitAtChar(version, versionVector, '.');
1141 //check file version
1142 vector<string> linesVector;
1143 splitAtChar(line, linesVector, '.');
1145 if (versionVector.size() != linesVector.size()) { good = false; }
1147 for (int j = 0; j < versionVector.size(); j++) {
1149 convert(versionVector[j], num1);
1150 convert(linesVector[j], num2);
1152 //if mothurs version is newer than this files version, then we want to remake it
1153 if (num1 > num2) { good = false; break; }
1159 if (!good) { file.close(); }
1160 else { file.seekg(0); }
1164 catch(exception& e) {
1165 cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function checkReleaseVersion. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
1169 /**************************************************************************************************/