X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=mothurout.cpp;h=c58e634500270cce359470ebc56f7244ef994c8c;hb=1b0bddfbf4ac5df7e2dad03c8a5350e71b052f78;hp=90d6f37434d7cb4df231817be6d1759df80b45bb;hpb=4c5e7a20a03ddc6feb49ff9d21fcb4c79bc5508d;p=mothur.git diff --git a/mothurout.cpp b/mothurout.cpp index 90d6f37..c58e634 100644 --- a/mothurout.cpp +++ b/mothurout.cpp @@ -1182,7 +1182,6 @@ vector MothurOut::setFilePosEachLine(string filename, int& n vector MothurOut::divideFile(string filename, int& proc) { try{ - vector filePos; filePos.push_back(0); @@ -1190,7 +1189,7 @@ vector MothurOut::divideFile(string filename, int& proc) { unsigned long long size; filename = getFullPathName(filename); - + //get num bytes in file pFile = fopen (filename.c_str(),"rb"); if (pFile==NULL) perror ("Error opening file"); @@ -1199,7 +1198,9 @@ vector MothurOut::divideFile(string filename, int& proc) { size=ftell (pFile); fclose (pFile); } - + + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + //estimate file breaks unsigned long long chunkSize = 0; chunkSize = size / proc; @@ -1219,7 +1220,10 @@ vector MothurOut::divideFile(string filename, int& proc) { unsigned long long newSpot = spot; while (!in.eof()) { char c = in.get(); + if (c == '>') { in.putback(c); newSpot = in.tellg(); break; } + else if (int(c) == -1) { break; } + } //there was not another sequence before the end of the file @@ -1233,14 +1237,18 @@ vector MothurOut::divideFile(string filename, int& proc) { //save end pos filePos.push_back(size); - + //sanity check filePos for (int i = 0; i < (filePos.size()-1); i++) { if (filePos[(i+1)] <= filePos[i]) { filePos.erase(filePos.begin()+(i+1)); i--; } } proc = (filePos.size() - 1); - +#else + mothurOut("[ERROR]: Windows version should not be calling the divideFile function."); mothurOutEndLine(); + proc=1; + filePos.push_back(size); +#endif return filePos; } catch(exception& e) { @@ -1469,10 +1477,37 @@ int MothurOut::getNumNames(string names){ } /***********************************************************************/ -void MothurOut::mothurRemove(string filename){ +int MothurOut::getNumChar(string line, char c){ + try { + int count = 0; + + if(line != ""){ + for(int i=0;i