]> git.donarmstrong.com Git - mothur.git/blobdiff - mothurout.cpp
some changes while testing 1.9
[mothur.git] / mothurout.cpp
index fe6fd26b09765e43b1032632564401ae86f36c6c..ca1a40b32ddbd86e185ddee6e59366e4b3aace94 100644 (file)
-/*
- *  m->mothurOut.cpp
- *  Mothur
- *
- *  Created by westcott on 2/25/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "mothurout.h"
-
-/******************************************************/
-MothurOut* MothurOut::getInstance() {
-       if( _uniqueInstance == 0) {
-               _uniqueInstance = new MothurOut();
-       }
-       return _uniqueInstance;
-}
-/*********************************************************************************************/
-void MothurOut::setFileName(string filename)  {
-       try {
-               logFileName = filename;
-               
-               #ifdef USE_MPI
-                       int pid;
-                       MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
-                                       
-                       if (pid == 0) { //only one process should output to screen
-               #endif
-               
-               openOutputFile(filename, out);
-               
-               #ifdef USE_MPI
-                       }
-               #endif
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "setFileName");
-               exit(1);
-       }
-}
-/*********************************************************************************************/
-MothurOut::~MothurOut() {
-       try {
-               _uniqueInstance = 0;
-               
-               #ifdef USE_MPI
-                       int pid;
-                       MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
-                                       
-                       if (pid == 0) { //only one process should output to screen
-               #endif
-               
-               out.close();
-               
-               #ifdef USE_MPI
-                       }
-               #endif
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "MothurOut");
-               exit(1);
-       }
-}
-
-/*********************************************************************************************/
-void MothurOut::mothurOut(string output) {
-       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;
-               
-               #ifdef USE_MPI
-                       }
-               #endif
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "MothurOut");
-               exit(1);
-       }
-}
-/*********************************************************************************************/
-void MothurOut::mothurOutEndLine() {
-       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;
-               
-               #ifdef USE_MPI
-                       }
-               #endif
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "MothurOutEndLine");
-               exit(1);
-       }
-}
-/*********************************************************************************************/
-void MothurOut::mothurOutJustToLog(string output) {
-       try {
-               #ifdef USE_MPI
-                       int pid;
-                       MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
-                                       
-                       if (pid == 0) { //only one process should output to screen
-               #endif
-               
-               out << output;
-               
-               #ifdef USE_MPI
-                       }
-               #endif
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "MothurOutJustToLog");
-               exit(1);
-       }
-}
-/*********************************************************************************************/
-void MothurOut::errorOut(exception& e, string object, string function) {
-       mothurOut("Error: ");
-       mothurOut(toString(e.what()));
-       mothurOut(" has occurred in the " + object + " class function " + function + ". Please contact Pat Schloss at mothur.bugs@gmail.com, and be sure to include the mothur.logFile with your inquiry.");
-       mothurOutEndLine();
-}
-/*********************************************************************************************/
-
-
-
-
-
+/*\r
+ *  m->mothurOut.cpp\r
+ *  Mothur\r
+ *\r
+ *  Created by westcott on 2/25/10.\r
+ *  Copyright 2010 Schloss Lab. All rights reserved.\r
+ *\r
+ */\r
+\r
+#include "mothurout.h"\r
+\r
+/******************************************************/\r
+MothurOut* MothurOut::getInstance() {\r
+       if( _uniqueInstance == 0) {\r
+               _uniqueInstance = new MothurOut();\r
+       }\r
+       return _uniqueInstance;\r
+}\r
+/*********************************************************************************************/\r
+void MothurOut::setFileName(string filename)  {\r
+       try {\r
+               logFileName = filename;\r
+               \r
+               #ifdef USE_MPI\r
+                       int pid;\r
+                       MPI_Comm_rank(MPI_COMM_WORLD, &pid); \r
+                                       \r
+                       if (pid == 0) { //only one process should output to screen\r
+               #endif\r
+               \r
+               openOutputFile(filename, out);\r
+               \r
+               #ifdef USE_MPI\r
+                       }\r
+               #endif\r
+       }\r
+       catch(exception& e) {\r
+               errorOut(e, "MothurOut", "setFileName");\r
+               exit(1);\r
+       }\r
+}\r
+/*********************************************************************************************/\r
+void MothurOut::closeLog()  {\r
+       try {\r
+               \r
+               #ifdef USE_MPI\r
+                       int pid;\r
+                       MPI_Comm_rank(MPI_COMM_WORLD, &pid); \r
+                                       \r
+                       if (pid == 0) { //only one process should output to screen\r
+               #endif\r
+               \r
+               out.close();\r
+               \r
+               #ifdef USE_MPI\r
+                       }\r
+               #endif\r
+       }\r
+       catch(exception& e) {\r
+               errorOut(e, "MothurOut", "closeLog");\r
+               exit(1);\r
+       }\r
+}\r
+\r
+/*********************************************************************************************/\r
+MothurOut::~MothurOut() {\r
+       try {\r
+               _uniqueInstance = 0;\r
+               \r
+       }\r
+       catch(exception& e) {\r
+               errorOut(e, "MothurOut", "MothurOut");\r
+               exit(1);\r
+       }\r
+}\r
+/*********************************************************************************************/\r
+void MothurOut::mothurOut(string output) {\r
+       try {\r
+               \r
+               #ifdef USE_MPI\r
+                       int pid;\r
+                       MPI_Comm_rank(MPI_COMM_WORLD, &pid); \r
+                                       \r
+                       if (pid == 0) { //only one process should output to screen\r
+               #endif\r
+               \r
+               cout << output;\r
+               out << output;\r
+               \r
+               #ifdef USE_MPI\r
+                       }\r
+               #endif\r
+       }\r
+       catch(exception& e) {\r
+               errorOut(e, "MothurOut", "MothurOut");\r
+               exit(1);\r
+       }\r
+}\r
+/*********************************************************************************************/\r
+void MothurOut::mothurOutEndLine() {\r
+       try {\r
+               #ifdef USE_MPI\r
+                       int pid;\r
+                       MPI_Comm_rank(MPI_COMM_WORLD, &pid); \r
+                                       \r
+                       if (pid == 0) { //only one process should output to screen\r
+               #endif\r
+               \r
+               cout << endl;\r
+               out << endl;\r
+               \r
+               #ifdef USE_MPI\r
+                       }\r
+               #endif\r
+       }\r
+       catch(exception& e) {\r
+               errorOut(e, "MothurOut", "MothurOutEndLine");\r
+               exit(1);\r
+       }\r
+}\r
+/*********************************************************************************************/\r
+void MothurOut::mothurOutJustToLog(string output) {\r
+       try {\r
+               #ifdef USE_MPI\r
+                       int pid;\r
+                       MPI_Comm_rank(MPI_COMM_WORLD, &pid); \r
+                                       \r
+                       if (pid == 0) { //only one process should output to screen\r
+               #endif\r
+               \r
+               out << output;\r
+               \r
+               #ifdef USE_MPI\r
+                       }\r
+               #endif\r
+       }\r
+       catch(exception& e) {\r
+               errorOut(e, "MothurOut", "MothurOutJustToLog");\r
+               exit(1);\r
+       }\r
+}\r
+/*********************************************************************************************/\r
+void MothurOut::errorOut(exception& e, string object, string function) {\r
+       mothurOut("Error: ");\r
+       mothurOut(toString(e.what()));\r
+       mothurOut(" has occurred in the " + object + " class function " + function + ". Please contact Pat Schloss at mothur.bugs@gmail.com, and be sure to include the mothur.logFile with your inquiry.");\r
+       mothurOutEndLine();\r
+}\r
+/*********************************************************************************************/\r
+\r
+\r
+\r
+\r
+\r