X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=pintail.cpp;h=b9f2434d19d4cc842bfac1dce4f6de5a0d1b742d;hp=5bfdc44128dd300cc22a33e8fa696d032dcab774;hb=a8e2df1b96a57f5f29576b08361b86a96a8eff4f;hpb=2f17ce987b15dca9a309116d9df5131a1d3a35ee diff --git a/pintail.cpp b/pintail.cpp index 5bfdc44..b9f2434 100644 --- a/pintail.cpp +++ b/pintail.cpp @@ -74,7 +74,7 @@ int Pintail::doPrep() { #ifdef USE_MPI //do nothing #else - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) //find breakup of templatefile for quantiles if (processors == 1) { templateLines.push_back(new linePair(0, templateSeqs.size())); } else { @@ -92,7 +92,7 @@ int Pintail::doPrep() { m->mothurOut("Getting conservation... "); cout.flush(); if (consfile == "") { m->mothurOut("Calculating probability of conservation for your template sequences. This can take a while... I will output the frequency of the highest base in each position to a .freq file so that you can input them using the conservation parameter next time you run this command. Providing the .freq file will improve speed. "); cout.flush(); - probabilityProfile = decalc->calcFreq(templateSeqs, outputDir + getSimpleName(templateFileName)); + probabilityProfile = decalc->calcFreq(templateSeqs, templateFileName); if (m->control_pressed) { return 0; } m->mothurOut("Done."); m->mothurOutEndLine(); }else { probabilityProfile = readFreq(); m->mothurOut("Done."); } @@ -170,20 +170,20 @@ int Pintail::doPrep() { string noOutliers, outliers; if ((!filter) && (seqMask == "")) { - noOutliers = outputDir + getRootName(getSimpleName(templateFileName)) + "pintail.quan"; + noOutliers = m->getRootName(m->getSimpleName(templateFileName)) + "pintail.quan"; }else if ((!filter) && (seqMask != "")) { - noOutliers = outputDir + getRootName(getSimpleName(templateFileName)) + "pintail.masked.quan"; + noOutliers =m->getRootName(m->getSimpleName(templateFileName)) + "pintail.masked.quan"; }else if ((filter) && (seqMask != "")) { - noOutliers = outputDir + getRootName(getSimpleName(templateFileName)) + "pintail.filtered." + getSimpleName(getRootName(fastafile)) + "masked.quan"; + noOutliers = m->getRootName(m->getSimpleName(templateFileName)) + "pintail.filtered." + m->getSimpleName(m->getRootName(fastafile)) + "masked.quan"; }else if ((filter) && (seqMask == "")) { - noOutliers = outputDir + getRootName(getSimpleName(templateFileName)) + "pintail.filtered." + getSimpleName(getRootName(fastafile)) + "quan"; + noOutliers = m->getRootName(m->getSimpleName(templateFileName)) + "pintail.filtered." + m->getSimpleName(m->getRootName(fastafile)) + "quan"; } decalc->removeObviousOutliers(quantilesMembers, templateSeqs.size()); if (m->control_pressed) { return 0; } - string outputString = ""; + string outputString = "#" + m->getVersion() + "\n"; //adjust quantiles for (int i = 0; i < quantilesMembers.size(); i++) { @@ -249,8 +249,9 @@ int Pintail::doPrep() { } } //*************************************************************************************************************** -int Pintail::print(ostream& out, ostream& outAcc) { +Sequence Pintail::print(ostream& out, ostream& outAcc) { try { + int index = ceil(deviation); //is your DE value higher than the 95% @@ -279,7 +280,7 @@ int Pintail::print(ostream& out, ostream& outAcc) { for (int m = 0; m < expectedDistance.size(); m++) { out << expectedDistance[m] << '\t'; } out << endl; - return 0; + return *querySeq; } catch(exception& e) { @@ -289,9 +290,9 @@ int Pintail::print(ostream& out, ostream& outAcc) { } #ifdef USE_MPI //*************************************************************************************************************** -int Pintail::print(MPI_File& out, MPI_File& outAcc) { +Sequence Pintail::print(MPI_File& out, MPI_File& outAcc) { try { - bool results = false; + string outputString = ""; int index = ceil(deviation); @@ -319,7 +320,7 @@ int Pintail::print(MPI_File& out, MPI_File& outAcc) { MPI_File_write_shared(outAcc, buf, length, MPI_CHAR, &statusAcc); delete buf; - results = true; + return *querySeq; } outputString += "Observed\t"; @@ -339,7 +340,7 @@ int Pintail::print(MPI_File& out, MPI_File& outAcc) { MPI_File_write_shared(out, buf2, length, MPI_CHAR, &status); delete buf2; - return results; + return *querySeq; } catch(exception& e) { m->errorOut(e, "Pintail", "print"); @@ -449,6 +450,9 @@ vector Pintail::readFreq() { if (tempBuf.length() > size) { tempBuf = tempBuf.substr(0, size); } istringstream iss (tempBuf,istringstream::in); + //read version + string line = m->getline(iss); m->gobble(iss); + while(!iss.eof()) { iss >> pos >> num; @@ -463,7 +467,7 @@ vector Pintail::readFreq() { prob.push_back(Pi); } - gobble(iss); + m->gobble(iss); } MPI_File_close(&inMPI); @@ -471,7 +475,10 @@ vector Pintail::readFreq() { #else ifstream in; - openInputFile(consfile, in); + m->openInputFile(consfile, in); + + //read version + string line = m->getline(in); m->gobble(in); while(!in.eof()){ @@ -488,7 +495,7 @@ vector Pintail::readFreq() { prob.push_back(Pi); } - gobble(in); + m->gobble(in); } in.close(); @@ -522,8 +529,8 @@ Sequence* Pintail::findPairs(Sequence* q) { //************************************************************************************************** void Pintail::createProcessesQuan() { try { -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) - int process = 0; +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) + int process = 1; vector processIDS; //loop through and create all the processes you want @@ -540,8 +547,7 @@ void Pintail::createProcessesQuan() { //write out data to file so parent can read it ofstream out; string s = toString(getpid()) + ".temp"; - openOutputFile(s, out); - + m->openOutputFile(s, out); //output observed distances for (int i = 0; i < quantilesMembers.size(); i++) { @@ -555,20 +561,27 @@ void Pintail::createProcessesQuan() { out.close(); exit(0); - }else { m->mothurOut("unable to spawn the necessary processes."); m->mothurOutEndLine(); exit(0); } + }else { + m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); + for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); } + exit(0); + } } + //parent does its part + quantilesMembers = decalc->getQuantiles(templateSeqs, windowSizesTemplate, window, probabilityProfile, increment, templateLines[0]->start, templateLines[0]->end); + //force parent to wait until all the processes are done - for (int i=0;iopenInputFile(s, in); vector< vector > quan; quan.resize(100); @@ -578,7 +591,7 @@ void Pintail::createProcessesQuan() { int num; in >> num; - gobble(in); + m->gobble(in); vector q; float w; for (int j = 0; j < num; j++) { @@ -587,7 +600,7 @@ void Pintail::createProcessesQuan() { } quan[h] = q; - gobble(in); + m->gobble(in); } @@ -599,9 +612,9 @@ void Pintail::createProcessesQuan() { } in.close(); - remove(s.c_str()); + m->mothurRemove(s); } - + #else quantilesMembers = decalc->getQuantiles(templateSeqs, windowSizesTemplate, window, probabilityProfile, increment, 0, templateSeqs.size()); #endif @@ -648,6 +661,9 @@ vector< vector > Pintail::readQuantiles() { istringstream iss (tempBuf,istringstream::in); delete buffer; + //read version + string line = m->getline(iss); m->gobble(iss); + while(!iss.eof()) { iss >> num >> ten >> twentyfive >> fifty >> seventyfive >> ninetyfive >> ninetynine; @@ -662,7 +678,7 @@ vector< vector > Pintail::readQuantiles() { quan.push_back(temp); - gobble(iss); + m->gobble(iss); } MPI_File_close(&inMPI); @@ -670,7 +686,10 @@ vector< vector > Pintail::readQuantiles() { #else ifstream in; - openInputFile(quanfile, in); + m->openInputFile(quanfile, in); + + //read version + string line = m->getline(in); m->gobble(in); while(!in.eof()){ @@ -687,7 +706,7 @@ vector< vector > Pintail::readQuantiles() { quan.push_back(temp); - gobble(in); + m->gobble(in); } in.close(); #endif @@ -737,7 +756,7 @@ void Pintail::printQuanFile(string file, string outputString) { //delete FileName; #else ofstream outQuan; - openOutputFile(file, outQuan); + m->openOutputFile(file, outQuan); outQuan << outputString;