X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=mothurout.cpp;h=8a3b6313072a158f611e1a69a84d0a9713add18c;hp=3e4db45bcc43990a18f7d8e51493388d28a6d850;hb=df7e3ff9f68ef157b0328a2d353c3258c5d45d89;hpb=196c22d0f93ba48e8ec54ab76608b6e3ba5e68cc diff --git a/mothurout.cpp b/mothurout.cpp index 3e4db45..8a3b631 100644 --- a/mothurout.cpp +++ b/mothurout.cpp @@ -23,6 +23,7 @@ set MothurOut::getCurrentTypes() { set types; types.insert("fasta"); + types.insert("summary"); types.insert("accnos"); types.insert("column"); types.insert("design"); @@ -81,6 +82,7 @@ void MothurOut::printCurrentFiles() { if (biomfile != "") { mothurOut("biom=" + biomfile); mothurOutEndLine(); } if (counttablefile != "") { mothurOut("count=" + counttablefile); mothurOutEndLine(); } if (processors != "1") { mothurOut("processors=" + processors); mothurOutEndLine(); } + if (summaryfile != "") { mothurOut("summary=" + summaryfile); mothurOutEndLine(); } } catch(exception& e) { @@ -115,6 +117,7 @@ bool MothurOut::hasCurrentFiles() { if (flowfile != "") { return true; } if (biomfile != "") { return true; } if (counttablefile != "") { return true; } + if (summaryfile != "") { return true; } if (processors != "1") { return true; } return hasCurrent; @@ -151,6 +154,7 @@ void MothurOut::clearCurrentFiles() { flowfile = ""; biomfile = ""; counttablefile = ""; + summaryfile = ""; processors = "1"; } catch(exception& e) { @@ -344,6 +348,27 @@ void MothurOut::mothurOut(string output) { } } /*********************************************************************************************/ +void MothurOut::mothurOutJustToScreen(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 + logger() << output; + +#ifdef USE_MPI + } +#endif + } + catch(exception& e) { + errorOut(e, "MothurOut", "MothurOut"); + exit(1); + } +} +/*********************************************************************************************/ void MothurOut::mothurOutEndLine() { try { #ifdef USE_MPI @@ -1292,15 +1317,15 @@ vector MothurOut::setFilePosFasta(string filename, int& num) char c = inFASTA.get(); count++; if (c == '>') { positions.push_back(count-1); - //cout << count << endl; + if (debug) { mothurOut("[DEBUG]: numSeqs = " + toString(positions.size()) + " count = " + toString(count) + ".\n"); } } } inFASTA.close(); num = positions.size(); - - /*FILE * pFile; - long size; + if (debug) { mothurOut("[DEBUG]: num = " + toString(num) + ".\n"); } + FILE * pFile; + unsigned long long size; //get num bytes in file pFile = fopen (filename.c_str(),"rb"); @@ -1309,9 +1334,9 @@ vector MothurOut::setFilePosFasta(string filename, int& num) fseek (pFile, 0, SEEK_END); size=ftell (pFile); fclose (pFile); - }*/ + } - unsigned long long size = positions[(positions.size()-1)]; + /*unsigned long long size = positions[(positions.size()-1)]; ifstream in; openInputFile(filename, in); @@ -1321,8 +1346,10 @@ vector MothurOut::setFilePosFasta(string filename, int& num) if(in.eof()) { break; } else { size++; } } - in.close(); - + in.close();*/ + + if (debug) { mothurOut("[DEBUG]: size = " + toString(size) + ".\n"); } + positions.push_back(size); positions[0] = 0; @@ -2215,9 +2242,11 @@ map MothurOut::readNames(string namefile, unsigned long int& numSeq /************************************************************/ int MothurOut::checkName(string& name) { try { - for (int i = 0; i < name.length(); i++) { - if (name[i] == ':') { name[i] = '_'; changedSeqNames = true; } - } + if (modifyNames) { + for (int i = 0; i < name.length(); i++) { + if (name[i] == ':') { name[i] = '_'; changedSeqNames = true; } + } + } return 0; } catch(exception& e) { @@ -3243,6 +3272,26 @@ vector MothurOut::getAverages(vector< vector >& dists) { exit(1); } } +/**************************************************************************************************/ +double MothurOut::getAverage(vector dists) { + try{ + double average = 0; + + for (int i = 0; i < dists.size(); i++) { + average += dists[i]; + } + + //finds average. + average /= (double) dists.size(); + + return average; + } + catch(exception& e) { + errorOut(e, "MothurOut", "getAverage"); + exit(1); + } +} + /**************************************************************************************************/ vector MothurOut::getStandardDeviation(vector< vector >& dists) { try{