}
}
/*********************************************************************************************/
+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
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 {