X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=mothurout.cpp;h=3205ae794165a5b8c045c473403d8a66b1b54f90;hb=a150db3c2bfd7b76420048a1e94ebe397f2c6045;hp=65296221759fa879e591bb0967b0f20872106adc;hpb=64581f6d0e63e67d4e119601bea695ebb3f52a13;p=mothur.git diff --git a/mothurout.cpp b/mothurout.cpp index 6529622..3205ae7 100644 --- a/mothurout.cpp +++ b/mothurout.cpp @@ -39,6 +39,8 @@ void MothurOut::printCurrentFiles() { if (sharedfile != "") { mothurOut("shared=" + sharedfile); mothurOutEndLine(); } if (taxonomyfile != "") { mothurOut("taxonomy=" + taxonomyfile); mothurOutEndLine(); } if (treefile != "") { mothurOut("tree=" + treefile); mothurOutEndLine(); } + if (flowfile != "") { mothurOut("flow=" + flowfile); mothurOutEndLine(); } + if (processors != "1") { mothurOut("processors=" + processors); mothurOutEndLine(); } } catch(exception& e) { @@ -70,6 +72,8 @@ bool MothurOut::hasCurrentFiles() { if (sharedfile != "") { return true; } if (taxonomyfile != "") { return true; } if (treefile != "") { return true; } + if (flowfile != "") { return true; } + if (processors != "1") { return true; } return hasCurrent; @@ -101,7 +105,9 @@ void MothurOut::clearCurrentFiles() { sfffile = ""; oligosfile = ""; accnosfile = ""; - taxonomyfile = ""; + taxonomyfile = ""; + flowfile = ""; + processors = "1"; } catch(exception& e) { errorOut(e, "MothurOut", "clearCurrentFiles"); @@ -432,12 +438,12 @@ string MothurOut::getline(ifstream& fileHandle) { string line = ""; - while (!fileHandle.eof()) { + while (fileHandle) { //get next character char c = fileHandle.get(); //are you at the end of the line - if ((c == '\n') || (c == '\r') || (c == '\f')){ break; } + if ((c == '\n') || (c == '\r') || (c == '\f') || (c == EOF)){ break; } else { line += c; } } @@ -1148,7 +1154,43 @@ vector MothurOut::divideFile(string filename, int& proc) { exit(1); } } - +/**************************************************************************************************/ +int MothurOut::divideFile(string filename, int& proc, vector& files) { + try{ + + vector filePos = divideFile(filename, proc); + + for (int i = 0; i < (filePos.size()-1); i++) { + + //read file chunk + ifstream in; + openInputFile(filename, in); + in.seekg(filePos[i]); + unsigned long int size = filePos[(i+1)] - filePos[i]; + char* chunk = new char[size]; + in.read(chunk, size); + in.close(); + + //open new file + string fileChunkName = filename + "." + toString(i) + ".tmp"; + ofstream out; + openOutputFile(fileChunkName, out); + + out << chunk << endl; + out.close(); + delete[] chunk; + + //save name + files.push_back(fileChunkName); + } + + return 0; + } + catch(exception& e) { + errorOut(e, "MothurOut", "divideFile"); + exit(1); + } +} /***********************************************************************/ bool MothurOut::isTrue(string f){