X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=mothurout.cpp;h=c89d580d64f6c69a6afedada448143ae114453a3;hb=43ed0accfbc2852849e104ff7eccdd2c42acd4ec;hp=001e8c48a8932374d7266b4e6097036c5b2ed9ac;hpb=7f0cae4f4853cc3f12bc751ee06ea31c7c97496e;p=mothur.git diff --git a/mothurout.cpp b/mothurout.cpp index 001e8c4..c89d580 100644 --- a/mothurout.cpp +++ b/mothurout.cpp @@ -143,7 +143,7 @@ void MothurOut::setDefaultPath(string pathname) { //add / to name if needed string lastChar = pathname.substr(pathname.length()-1); - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) if (lastChar != "/") { pathname += "/"; } #else if (lastChar != "\\") { pathname += "\\"; } @@ -212,8 +212,8 @@ void MothurOut::mothurOut(string output) { if (pid == 0) { //only one process should output to screen #endif - cout << output; out << output; + logger() << output; #ifdef USE_MPI } @@ -234,8 +234,8 @@ void MothurOut::mothurOutEndLine() { if (pid == 0) { //only one process should output to screen #endif - cout << endl; out << endl; + logger() << endl; #ifdef USE_MPI } @@ -257,13 +257,15 @@ void MothurOut::mothurOut(string output, ofstream& outputFile) { if (pid == 0) { //only one process should output to screen #endif - cout << output; + out << output; outputFile << output; + logger() << output; #ifdef USE_MPI } #endif + } catch(exception& e) { errorOut(e, "MothurOut", "MothurOut"); @@ -280,9 +282,9 @@ void MothurOut::mothurOutEndLine(ofstream& outputFile) { if (pid == 0) { //only one process should output to screen #endif - cout << endl; out << endl; outputFile << endl; + logger() << endl; #ifdef USE_MPI } @@ -332,7 +334,7 @@ void MothurOut::errorOut(exception& e, string object, string function) { // // On failure, returns 0.0, 0.0 int MothurOut::mem_usage(double& vm_usage, double& resident_set) { - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) vm_usage = 0.0; resident_set = 0.0; @@ -504,7 +506,7 @@ string MothurOut::getline(ifstream& fileHandle) { } /***********************************************************************/ -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #ifdef USE_COMPRESSION inline bool endsWith(string s, const char * suffix){ size_t suffixLength = strlen(suffix); @@ -518,7 +520,7 @@ string MothurOut::getRootName(string longName){ string rootName = longName; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #ifdef USE_COMPRESSION if (endsWith(rootName, ".gz") || endsWith(rootName, ".bz2")) { int pos = rootName.find_last_of('.'); @@ -673,7 +675,7 @@ string MothurOut::getFullPathName(string fileName){ string cwd; //get current working directory - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) if (path.find("~") != -1) { //go to home directory string homeDir; @@ -726,7 +728,7 @@ string MothurOut::getFullPathName(string fileName){ }else if (path[(pos-1)] == '/') { //you want the current working dir ./ path = path.substr(0, pos); }else if (pos == 1) { break; //you are at the end - }else { cout << "cannot resolve path for " << fileName << endl; return fileName; } + }else { mothurOut("cannot resolve path for " + fileName + "\n"); return fileName; } } for (int i = index; i >= 0; i--) { @@ -772,7 +774,7 @@ string MothurOut::getFullPathName(string fileName){ }else if (path[(pos-1)] == '\\') { //you want the current working dir ./ path = path.substr(0, pos); }else if (pos == 1) { break; //you are at the end - }else { cout << "cannot resolve path for " << fileName << endl; return fileName; } + }else { mothurOut("cannot resolve path for " + fileName + "\n"); return fileName; } } for (int i = index; i >= 0; i--) { @@ -796,7 +798,7 @@ int MothurOut::openInputFile(string fileName, ifstream& fileHandle, string m){ try { //get full path name string completeFileName = getFullPathName(fileName); -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #ifdef USE_COMPRESSION // check for gzipped or bzipped file if (endsWith(completeFileName, ".gz") || endsWith(completeFileName, ".bz2")) { @@ -842,7 +844,7 @@ int MothurOut::openInputFile(string fileName, ifstream& fileHandle){ //get full path name string completeFileName = getFullPathName(fileName); -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #ifdef USE_COMPRESSION // check for gzipped or bzipped file if (endsWith(completeFileName, ".gz") || endsWith(completeFileName, ".bz2")) { @@ -893,7 +895,7 @@ int MothurOut::renameFile(string oldName, string newName){ int exist = openInputFile(newName, inTest, ""); inTest.close(); - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) if (exist == 0) { //you could open it so you want to delete it string command = "rm " + newName; system(command.c_str()); @@ -920,7 +922,7 @@ int MothurOut::openOutputFile(string fileName, ofstream& fileHandle){ try { string completeFileName = getFullPathName(fileName); -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #ifdef USE_COMPRESSION // check for gzipped file if (endsWith(completeFileName, ".gz") || endsWith(completeFileName, ".bz2")) { @@ -996,7 +998,7 @@ string MothurOut::sortFile(string distFile, string outputDir){ //if you can, use the unix sort since its been optimized for years - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) string command = "sort -n -k +3 " + distFile + " -o " + outfile; system(command.c_str()); #else //you are stuck with my best attempt... @@ -1151,7 +1153,7 @@ vector MothurOut::setFilePosEachLine(string filename, int& n while(isspace(d) && (d != in.eof())) { d=in.get(); count++;} } positions.push_back(count-1); - cout << count-1 << endl; + //cout << count-1 << endl; } in.close(); @@ -1199,7 +1201,7 @@ vector MothurOut::divideFile(string filename, int& proc) { fclose (pFile); } - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) //estimate file breaks unsigned long long chunkSize = 0; @@ -1477,6 +1479,26 @@ int MothurOut::getNumNames(string names){ } /***********************************************************************/ +int MothurOut::getNumChar(string line, char c){ + try { + int count = 0; + + if(line != ""){ + for(int i=0;i > MothurOut::binomial(int maxOrder){ @@ -2054,7 +2154,7 @@ int MothurOut::removeConfidences(string& tax) { int pos2 = taxon.find_last_of(')'); if (pos2 != -1) { string confidenceScore = taxon.substr(pos+1, (pos2-(pos+1))); - if (isContainingOnlyDigits(confidenceScore)) { + if (isNumeric1(confidenceScore)) { taxon = taxon.substr(0, pos); //rip off confidence } }