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) {
if (sharedfile != "") { return true; }
if (taxonomyfile != "") { return true; }
if (treefile != "") { return true; }
+ if (flowfile != "") { return true; }
+ if (processors != "1") { return true; }
return hasCurrent;
sfffile = "";
oligosfile = "";
accnosfile = "";
- taxonomyfile = "";
+ taxonomyfile = "";
+ flowfile = "";
+ processors = "1";
}
catch(exception& e) {
errorOut(e, "MothurOut", "clearCurrentFiles");
}
}
/*********************************************************************************************/
+void MothurOut::mothurOut(string output, ofstream& outputFile) {
+ try {
+
+#ifdef USE_MPI
+ int pid;
+ MPI_Comm_rank(MPI_COMM_WORLD, &pid);
+
+ if (pid == 0) { //only one process should output to screen
+#endif
+
+ cout << output;
+ out << output;
+ outputFile << output;
+
+#ifdef USE_MPI
+ }
+#endif
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "MothurOut");
+ exit(1);
+ }
+}
+/*********************************************************************************************/
+void MothurOut::mothurOutEndLine(ofstream& outputFile) {
+ try {
+#ifdef USE_MPI
+ int pid;
+ MPI_Comm_rank(MPI_COMM_WORLD, &pid);
+
+ if (pid == 0) { //only one process should output to screen
+#endif
+
+ cout << endl;
+ out << endl;
+ outputFile << endl;
+
+#ifdef USE_MPI
+ }
+#endif
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "MothurOutEndLine");
+ exit(1);
+ }
+}
+/*********************************************************************************************/
void MothurOut::mothurOutJustToLog(string output) {
try {
#ifdef USE_MPI
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; }
}
exit(1);
}
}
-
+/**************************************************************************************************/
+int MothurOut::divideFile(string filename, int& proc, vector<string>& files) {
+ try{
+
+ vector<unsigned long int> 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){
exit(1);
}
}
+/**********************************************************************************************************************/
+int MothurOut::readNames(string namefile, map<string, string>& nameMap) {
+ try {
+
+ //open input file
+ ifstream in;
+ openInputFile(namefile, in);
+
+ while (!in.eof()) {
+ if (control_pressed) { break; }
+
+ string firstCol, secondCol;
+ in >> firstCol >> secondCol; gobble(in);
+
+ nameMap[firstCol] = secondCol;
+ }
+ in.close();
+
+ return 0;
+
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "readNames");
+ exit(1);
+ }
+}
+
/**********************************************************************************************************************/
map<string, int> MothurOut::readNames(string namefile) {
try {