From: westcott Date: Fri, 15 Jul 2011 19:50:30 +0000 (+0000) Subject: rewrote metastats command in c++, added mothurRemove function to handle ~ error.... X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=commitdiff_plain;h=19fcbbdba99658f5eca244803280f9ee7f9f6607 rewrote metastats command in c++, added mothurRemove function to handle ~ error. fixed bug with classify.otu summary file. added check for isnum in quality scores read. --- diff --git a/Mothur.xcodeproj/project.pbxproj b/Mothur.xcodeproj/project.pbxproj index c693c07..00bcf9a 100644 --- a/Mothur.xcodeproj/project.pbxproj +++ b/Mothur.xcodeproj/project.pbxproj @@ -17,6 +17,7 @@ A721765713BB9F7D0014DAAE /* referencedb.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A721765613BB9F7D0014DAAE /* referencedb.cpp */; }; A727864412E9E28C00F86ABA /* removerarecommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A727864312E9E28C00F86ABA /* removerarecommand.cpp */; }; A73DDBBA13C4A0D1006AAE38 /* clearmemorycommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A73DDBB913C4A0D1006AAE38 /* clearmemorycommand.cpp */; }; + A73DDC3813C4BF64006AAE38 /* mothurmetastats.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A73DDC3713C4BF64006AAE38 /* mothurmetastats.cpp */; }; A74D3687137DAB8300332B0C /* addtargets2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A74D3655137DAB8300332B0C /* addtargets2.cpp */; }; A74D3688137DAB8400332B0C /* alignchime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A74D3656137DAB8300332B0C /* alignchime.cpp */; }; A74D3689137DAB8400332B0C /* alignchimel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A74D3657137DAB8300332B0C /* alignchimel.cpp */; }; @@ -44,6 +45,7 @@ A7730EFF13967241007433A3 /* countseqscommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7730EFE13967241007433A3 /* countseqscommand.cpp */; }; A778FE6B134CA6CA00C0BA33 /* getcommandinfocommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A778FE6A134CA6CA00C0BA33 /* getcommandinfocommand.cpp */; }; A77A221F139001B600B0BE70 /* deuniquetreecommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A77A221E139001B600B0BE70 /* deuniquetreecommand.cpp */; }; + A79234D713C74BF6002B08E2 /* mothurfisher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A79234D613C74BF6002B08E2 /* mothurfisher.cpp */; }; A799F5B91309A3E000AEEFA0 /* makefastqcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A799F5B81309A3E000AEEFA0 /* makefastqcommand.cpp */; }; A7A61F2D130062E000E05B6B /* amovacommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7A61F2C130062E000E05B6B /* amovacommand.cpp */; }; A7E9B88112D37EC400DA6239 /* ace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7E9B64F12D37EC300DA6239 /* ace.cpp */; }; @@ -354,6 +356,8 @@ A727864312E9E28C00F86ABA /* removerarecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = removerarecommand.cpp; sourceTree = ""; }; A73DDBB813C4A0D1006AAE38 /* clearmemorycommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = clearmemorycommand.h; sourceTree = ""; }; A73DDBB913C4A0D1006AAE38 /* clearmemorycommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = clearmemorycommand.cpp; sourceTree = ""; }; + A73DDC3613C4BF64006AAE38 /* mothurmetastats.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mothurmetastats.h; sourceTree = ""; }; + A73DDC3713C4BF64006AAE38 /* mothurmetastats.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mothurmetastats.cpp; sourceTree = ""; }; A74D3655137DAB8300332B0C /* addtargets2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = addtargets2.cpp; sourceTree = ""; }; A74D3656137DAB8300332B0C /* alignchime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = alignchime.cpp; sourceTree = ""; }; A74D3657137DAB8300332B0C /* alignchimel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = alignchimel.cpp; sourceTree = ""; }; @@ -414,6 +418,8 @@ A778FE6A134CA6CA00C0BA33 /* getcommandinfocommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = getcommandinfocommand.cpp; sourceTree = ""; }; A77A221D139001B600B0BE70 /* deuniquetreecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = deuniquetreecommand.h; sourceTree = ""; }; A77A221E139001B600B0BE70 /* deuniquetreecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = deuniquetreecommand.cpp; sourceTree = ""; }; + A79234D513C74BF6002B08E2 /* mothurfisher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mothurfisher.h; sourceTree = ""; }; + A79234D613C74BF6002B08E2 /* mothurfisher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mothurfisher.cpp; sourceTree = ""; }; A799F5B71309A3E000AEEFA0 /* makefastqcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = makefastqcommand.h; sourceTree = ""; }; A799F5B81309A3E000AEEFA0 /* makefastqcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = makefastqcommand.cpp; sourceTree = ""; }; A7A61F1A130035C800E05B6B /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = ""; }; @@ -1743,6 +1749,10 @@ A7E9B6E612D37EC400DA6239 /* fisher2.h */, A7E9B75512D37EC400DA6239 /* metastats.h */, A7E9B75612D37EC400DA6239 /* metastats2.c */, + A79234D513C74BF6002B08E2 /* mothurfisher.h */, + A79234D613C74BF6002B08E2 /* mothurfisher.cpp */, + A73DDC3613C4BF64006AAE38 /* mothurmetastats.h */, + A73DDC3713C4BF64006AAE38 /* mothurmetastats.cpp */, ); name = metastats; sourceTree = ""; @@ -2119,6 +2129,8 @@ A7730EFF13967241007433A3 /* countseqscommand.cpp in Sources */, A721765713BB9F7D0014DAAE /* referencedb.cpp in Sources */, A73DDBBA13C4A0D1006AAE38 /* clearmemorycommand.cpp in Sources */, + A73DDC3813C4BF64006AAE38 /* mothurmetastats.cpp in Sources */, + A79234D713C74BF6002B08E2 /* mothurfisher.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/aligncommand.cpp b/aligncommand.cpp index e3db3dd..a32ec4d 100644 --- a/aligncommand.cpp +++ b/aligncommand.cpp @@ -436,7 +436,7 @@ int AlignCommand::execute(){ //MPI_Info info; //MPI_File_delete(outAccnosFilename, info); hasAccnos = false; - remove(accnosFileName.c_str()); + m->mothurRemove(accnosFileName); } } @@ -456,10 +456,10 @@ int AlignCommand::execute(){ numFastaSeqs = driver(lines[0], alignFileName, reportFileName, accnosFileName, candidateFileNames[s]); #endif - if (m->control_pressed) { remove(accnosFileName.c_str()); remove(alignFileName.c_str()); remove(reportFileName.c_str()); outputTypes.clear(); return 0; } + if (m->control_pressed) { m->mothurRemove(accnosFileName); m->mothurRemove(alignFileName); m->mothurRemove(reportFileName); outputTypes.clear(); return 0; } //delete accnos file if its blank else report to user - if (m->isBlank(accnosFileName)) { remove(accnosFileName.c_str()); hasAccnos = false; } + if (m->isBlank(accnosFileName)) { m->mothurRemove(accnosFileName); hasAccnos = false; } else { m->mothurOut("Some of you sequences generated alignments that eliminated too many bases, a list is provided in " + accnosFileName + "."); if (!flip) { @@ -849,24 +849,24 @@ int AlignCommand::createProcesses(string alignFileName, string reportFileName, s vector nonBlankAccnosFiles; if (!(m->isBlank(accnosFName))) { nonBlankAccnosFiles.push_back(accnosFName); } - else { remove(accnosFName.c_str()); } //remove so other files can be renamed to it + else { m->mothurRemove(accnosFName); } //remove so other files can be renamed to it for (int i = 0; i < processIDS.size(); i++) { ifstream in; string tempFile = alignFileName + toString(processIDS[i]) + ".num.temp"; m->openInputFile(tempFile, in); if (!in.eof()) { int tempNum = 0; in >> tempNum; num += tempNum; } - in.close(); remove(tempFile.c_str()); + in.close(); m->mothurRemove(tempFile); appendAlignFiles((alignFileName + toString(processIDS[i]) + ".temp"), alignFileName); - remove((alignFileName + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((alignFileName + toString(processIDS[i]) + ".temp")); appendReportFiles((reportFileName + toString(processIDS[i]) + ".temp"), reportFileName); - remove((reportFileName + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((reportFileName + toString(processIDS[i]) + ".temp")); if (!(m->isBlank(accnosFName + toString(processIDS[i]) + ".temp"))) { nonBlankAccnosFiles.push_back(accnosFName + toString(processIDS[i]) + ".temp"); - }else { remove((accnosFName + toString(processIDS[i]) + ".temp").c_str()); } + }else { m->mothurRemove((accnosFName + toString(processIDS[i]) + ".temp")); } } @@ -876,7 +876,7 @@ int AlignCommand::createProcesses(string alignFileName, string reportFileName, s for (int h=1; h < nonBlankAccnosFiles.size(); h++) { appendAlignFiles(nonBlankAccnosFiles[h], accnosFName); - remove(nonBlankAccnosFiles[h].c_str()); + m->mothurRemove(nonBlankAccnosFiles[h]); } }else { //recreate the accnosfile if needed ofstream out; diff --git a/bayesian.cpp b/bayesian.cpp index 0b55efd..1d5c46b 100644 --- a/bayesian.cpp +++ b/bayesian.cpp @@ -89,7 +89,7 @@ Classify(), kmerSize(ksize), confidenceThreshold(cutoff), iters(i) { generateDatabaseAndNames(tfile, tempFile, method, ksize, 0.0, 0.0, 0.0, 0.0); //prevents errors caused by creating shortcut files if you had an error in the sanity check. - if (m->control_pressed) { remove(phyloTreeName.c_str()); remove(probFileName.c_str()); remove(probFileName2.c_str()); } + if (m->control_pressed) { m->mothurRemove(phyloTreeName); m->mothurRemove(probFileName); m->mothurRemove(probFileName2); } else{ genusNodes = phyloTree->getGenusNodes(); genusTotals = phyloTree->getGenusTotals(); diff --git a/bellerophon.cpp b/bellerophon.cpp index f4d04ea..207fa51 100644 --- a/bellerophon.cpp +++ b/bellerophon.cpp @@ -677,7 +677,7 @@ int Bellerophon::writePrefs(string file, linePair tempLine) { for (int j = 0; j < numSeqs; j++) { - if (m->control_pressed) { outTemp.close(); remove(file.c_str()); return 0; } + if (m->control_pressed) { outTemp.close(); m->mothurRemove(file); return 0; } outTemp << pref[i][j].name << '\t' << pref[i][j].leftParent << '\t' << pref[i][j].rightParent << '\t'; outTemp << pref[i][j].score << '\t' << pref[i][j].closestLeft << '\t' << pref[i][j].closestRight << '\t' << pref[i][j].midpoint << endl; @@ -709,7 +709,7 @@ int Bellerophon::readPrefs(string file) { for (int j = 0; j < numSeqs; j++) { - if (m->control_pressed) { inTemp.close(); remove(file.c_str()); return 0; } + if (m->control_pressed) { inTemp.close(); m->mothurRemove(file); return 0; } inTemp >> pref[i][j].name >> pref[i][j].leftParent >> pref[i][j].rightParent; inTemp >> pref[i][j].score >> pref[i][j].closestLeft >> pref[i][j].closestRight >> pref[i][j].midpoint; @@ -719,7 +719,7 @@ int Bellerophon::readPrefs(string file) { inTemp.close(); - remove(file.c_str()); + m->mothurRemove(file); return 0; } diff --git a/binsequencecommand.cpp b/binsequencecommand.cpp index 8e8ec2b..4977cad 100644 --- a/binsequencecommand.cpp +++ b/binsequencecommand.cpp @@ -221,12 +221,12 @@ int BinSeqCommand::execute(){ while((list != NULL) && ((allLines == 1) || (userLabels.size() != 0))) { - if(m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } delete input; delete fasta; if (groupfile != "") { delete groupMap; } return 0; } + if(m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } delete input; delete fasta; if (groupfile != "") { delete groupMap; } return 0; } if(allLines == 1 || labels.count(list->getLabel()) == 1){ error = process(list); - if (error == 1) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } delete input; delete fasta; if (groupfile != "") { delete groupMap; } return 0; } + if (error == 1) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } delete input; delete fasta; if (groupfile != "") { delete groupMap; } return 0; } processedLabels.insert(list->getLabel()); userLabels.erase(list->getLabel()); @@ -239,7 +239,7 @@ int BinSeqCommand::execute(){ list = input->getListVector(lastLabel); error = process(list); - if (error == 1) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } delete input; delete fasta; if (groupfile != "") { delete groupMap; } return 0; } + if (error == 1) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } delete input; delete fasta; if (groupfile != "") { delete groupMap; } return 0; } processedLabels.insert(list->getLabel()); userLabels.erase(list->getLabel()); @@ -254,7 +254,7 @@ int BinSeqCommand::execute(){ list = input->getListVector(); } - if(m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } delete input; delete fasta; if (groupfile != "") { delete groupMap; } return 0; } + if(m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } delete input; delete fasta; if (groupfile != "") { delete groupMap; } return 0; } //output error messages about any remaining user labels set::iterator it; @@ -275,7 +275,7 @@ int BinSeqCommand::execute(){ list = input->getListVector(lastLabel); error = process(list); - if (error == 1) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } delete input; delete fasta; if (groupfile != "") { delete groupMap; } return 0; } + if (error == 1) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } delete input; delete fasta; if (groupfile != "") { delete groupMap; } return 0; } delete list; } @@ -284,7 +284,7 @@ int BinSeqCommand::execute(){ delete fasta; if (groupfile != "") { delete groupMap; } - if(m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if(m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); diff --git a/blastalign.cpp b/blastalign.cpp index 9af31df..bb7192a 100644 --- a/blastalign.cpp +++ b/blastalign.cpp @@ -37,9 +37,9 @@ BlastAlignment::BlastAlignment(float go, float ge, float ma, float mm) : //**************************************************************************************************/ BlastAlignment::~BlastAlignment(){ // The desctructor should clean up by removing the temporary - remove(candidateFileName.c_str()); // files used to run bl2seq - remove(templateFileName.c_str()); - remove(blastFileName.c_str()); + m->mothurRemove(candidateFileName); // files used to run bl2seq + m->mothurRemove(templateFileName); + m->mothurRemove(blastFileName); } //**************************************************************************************************/ diff --git a/blastdb.cpp b/blastdb.cpp index d64f374..96770dc 100644 --- a/blastdb.cpp +++ b/blastdb.cpp @@ -168,14 +168,14 @@ BlastDB::BlastDB() : Database() { BlastDB::~BlastDB(){ try{ - remove(queryFileName.c_str()); // let's clean stuff up and remove the temp files - remove(dbFileName.c_str()); // let's clean stuff up and remove the temp files - remove((dbFileName+".nsq").c_str()); // let's clean stuff up and remove the temp files - remove((dbFileName+".nsi").c_str()); // let's clean stuff up and remove the temp files - remove((dbFileName+".nsd").c_str()); // let's clean stuff up and remove the temp files - remove((dbFileName+".nin").c_str()); // let's clean stuff up and remove the temp files - remove((dbFileName+".nhr").c_str()); // let's clean stuff up and remove the temp files - remove(blastFileName.c_str()); // let's clean stuff up and remove the temp files + m->mothurRemove(queryFileName); // let's clean stuff up and remove the temp files + m->mothurRemove(dbFileName); // let's clean stuff up and remove the temp files + m->mothurRemove((dbFileName+".nsq")); // let's clean stuff up and remove the temp files + m->mothurRemove((dbFileName+".nsi")); // let's clean stuff up and remove the temp files + m->mothurRemove((dbFileName+".nsd")); // let's clean stuff up and remove the temp files + m->mothurRemove((dbFileName+".nin")); // let's clean stuff up and remove the temp files + m->mothurRemove((dbFileName+".nhr")); // let's clean stuff up and remove the temp files + m->mothurRemove(blastFileName.c_str()); // let's clean stuff up and remove the temp files } catch(exception& e) { m->errorOut(e, "BlastDB", "~BlastDB"); @@ -236,8 +236,8 @@ vector BlastDB::findClosestSequences(Sequence* seq, int n) { topMatches.push_back(templateAccession); } m8FileHandle.close(); - remove((queryFileName+pid+toString(randNumber)).c_str()); - remove((blastFileName+pid+toString(randNumber)).c_str()); + m->mothurRemove((queryFileName+pid+toString(randNumber))); + m->mothurRemove((blastFileName+pid+toString(randNumber))); return topMatches; } @@ -309,8 +309,8 @@ vector BlastDB::findClosestMegaBlast(Sequence* seq, int n, int minPerID) { //cout << templateAccession << endl; } m8FileHandle.close(); - remove((queryFileName+pid+toString(randNumber)).c_str()); - remove((blastFileName+pid+toString(randNumber)).c_str()); + m->mothurRemove((queryFileName+pid+toString(randNumber))); + m->mothurRemove((blastFileName+pid+toString(randNumber))); //cout << "\n" ; return topMatches; } diff --git a/bootstrapsharedcommand.cpp b/bootstrapsharedcommand.cpp index 478821e..783016a 100644 --- a/bootstrapsharedcommand.cpp +++ b/bootstrapsharedcommand.cpp @@ -256,13 +256,13 @@ int BootSharedCommand::execute(){ globaldata->gTreemap = tmap; while((order != NULL) && ((allLines == 1) || (userLabels.size() != 0))) { - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } globaldata->Groups.clear(); delete input;delete util; return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } globaldata->Groups.clear(); delete input;delete util; return 0; } if(allLines == 1 || labels.count(order->getLabel()) == 1){ m->mothurOut(order->getLabel()); m->mothurOutEndLine(); int error = process(order); - if (error == 1) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } globaldata->Groups.clear(); delete input;delete util; return 0; } + if (error == 1) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } globaldata->Groups.clear(); delete input;delete util; return 0; } processedLabels.insert(order->getLabel()); userLabels.erase(order->getLabel()); @@ -276,7 +276,7 @@ int BootSharedCommand::execute(){ order = input->getSharedOrderVector(lastLabel); m->mothurOut(order->getLabel()); m->mothurOutEndLine(); int error = process(order); - if (error == 1) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } globaldata->Groups.clear(); delete input;delete util; return 0; } + if (error == 1) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } globaldata->Groups.clear(); delete input;delete util; return 0; } processedLabels.insert(order->getLabel()); userLabels.erase(order->getLabel()); @@ -294,7 +294,7 @@ int BootSharedCommand::execute(){ } - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } globaldata->Groups.clear(); delete input; delete util; return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } globaldata->Groups.clear(); delete input; delete util; return 0; } //output error messages about any remaining user labels set::iterator it; @@ -309,7 +309,7 @@ int BootSharedCommand::execute(){ } } - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } globaldata->Groups.clear(); delete input; delete util; return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } globaldata->Groups.clear(); delete input; delete util; return 0; } //run last line if you need to if (needToRun == true) { @@ -317,13 +317,13 @@ int BootSharedCommand::execute(){ order = input->getSharedOrderVector(lastLabel); m->mothurOut(order->getLabel()); m->mothurOutEndLine(); int error = process(order); - if (error == 1) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } globaldata->Groups.clear(); delete input; delete util; return 0; } + if (error == 1) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } globaldata->Groups.clear(); delete input; delete util; return 0; } delete order; } - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } globaldata->Groups.clear();delete input; delete util; return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } globaldata->Groups.clear();delete input; delete util; return 0; } //reset groups parameter globaldata->Groups.clear(); diff --git a/catchallcommand.cpp b/catchallcommand.cpp index fd51664..39cc44f 100644 --- a/catchallcommand.cpp +++ b/catchallcommand.cpp @@ -236,7 +236,7 @@ int CatchAllCommand::execute() { //run catchall system(catchAllCommand.c_str()); - remove(filename.c_str()); + m->mothurRemove(filename); filename = m->getRootName(filename); filename = filename.substr(0, filename.length()-1); //rip off extra . if (savedOutputDir == "") { filename = m->getSimpleName(filename); } @@ -248,7 +248,7 @@ int CatchAllCommand::execute() { createSummaryFile(filename + "_BestModelsAnalysis.csv", sabund->getLabel(), out); - if (m->control_pressed) { out.close(); for (int i = 0; i < outputNames.size(); i++) {remove(outputNames[i].c_str()); } delete input; delete sabund; return 0; } + if (m->control_pressed) { out.close(); for (int i = 0; i < outputNames.size(); i++) {m->mothurRemove(outputNames[i]); } delete input; delete sabund; return 0; } processedLabels.insert(sabund->getLabel()); userLabels.erase(sabund->getLabel()); @@ -280,7 +280,7 @@ int CatchAllCommand::execute() { //run catchall system(catchAllCommand.c_str()); - remove(filename.c_str()); + m->mothurRemove(filename); filename = m->getRootName(filename); filename = filename.substr(0, filename.length()-1); //rip off extra . if (savedOutputDir == "") { filename = m->getSimpleName(filename); } @@ -292,7 +292,7 @@ int CatchAllCommand::execute() { createSummaryFile(filename + "_BestModelsAnalysis.csv", sabund->getLabel(), out); - if (m->control_pressed) { out.close(); for (int i = 0; i < outputNames.size(); i++) {remove(outputNames[i].c_str()); } delete input; delete sabund; return 0; } + if (m->control_pressed) { out.close(); for (int i = 0; i < outputNames.size(); i++) {m->mothurRemove(outputNames[i]); } delete input; delete sabund; return 0; } processedLabels.insert(sabund->getLabel()); userLabels.erase(sabund->getLabel()); @@ -345,7 +345,7 @@ int CatchAllCommand::execute() { //run catchall system(catchAllCommand.c_str()); - remove(filename.c_str()); + m->mothurRemove(filename); filename = m->getRootName(filename); filename = filename.substr(0, filename.length()-1); //rip off extra . if (savedOutputDir == "") { filename = m->getSimpleName(filename); } @@ -363,7 +363,7 @@ int CatchAllCommand::execute() { out.close(); delete input; - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {m->mothurRemove(outputNames[i]); } return 0; } } @@ -471,7 +471,7 @@ string CatchAllCommand::combineSummmary(vector& outputNames) { numLines = thisFilesLines.size(); temp.close(); - remove(outputNames[i].c_str()); + m->mothurRemove(outputNames[i]); } //for each label @@ -579,7 +579,7 @@ vector CatchAllCommand::parseSharedFile(string filename) { //clears file before we start to write to it below for (int i=0; igetGroup() + ".sabund").c_str()); + m->mothurRemove((sharedFileRoot + lookup[i]->getGroup() + ".sabund")); filenames.push_back((sharedFileRoot + lookup[i]->getGroup() + ".sabund")); groups.push_back(lookup[i]->getGroup()); } diff --git a/chimerabellerophoncommand.cpp b/chimerabellerophoncommand.cpp index 0031acb..ac1645d 100644 --- a/chimerabellerophoncommand.cpp +++ b/chimerabellerophoncommand.cpp @@ -227,7 +227,7 @@ int ChimeraBellerophonCommand::execute(){ chimera->getChimeras(); - if (m->control_pressed) { delete chimera; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); return 0; } + if (m->control_pressed) { delete chimera; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); return 0; } #ifdef USE_MPI MPI_File outMPI; @@ -263,7 +263,7 @@ int ChimeraBellerophonCommand::execute(){ #endif - if (m->control_pressed) { remove(accnosFileName.c_str()); remove(outputFileName.c_str()); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); delete chimera; return 0; } + if (m->control_pressed) { m->mothurRemove(accnosFileName); m->mothurRemove(outputFileName); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); delete chimera; return 0; } m->mothurOutEndLine(); m->mothurOut("It took " + toString(time(NULL) - start) + " secs to check " + toString(numSeqs) + " sequences."); m->mothurOutEndLine(); m->mothurOutEndLine(); diff --git a/chimeraccodecommand.cpp b/chimeraccodecommand.cpp index fd80ec9..7c8485a 100644 --- a/chimeraccodecommand.cpp +++ b/chimeraccodecommand.cpp @@ -293,7 +293,7 @@ int ChimeraCcodeCommand::execute(){ string mapInfo = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "mapinfo"; - if (m->control_pressed) { delete chimera; for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } outputTypes.clear(); return 0; } + if (m->control_pressed) { delete chimera; for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } outputTypes.clear(); return 0; } #ifdef USE_MPI @@ -325,7 +325,7 @@ int ChimeraCcodeCommand::execute(){ MPI_File_open(MPI_COMM_WORLD, outFilename, outMode, MPI_INFO_NULL, &outMPI); MPI_File_open(MPI_COMM_WORLD, outAccnosFilename, outMode, MPI_INFO_NULL, &outMPIAccnos); - if (m->control_pressed) { MPI_File_close(&inMPI); MPI_File_close(&outMPI); MPI_File_close(&outMPIAccnos); for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } outputTypes.clear(); delete chimera; return 0; } + if (m->control_pressed) { MPI_File_close(&inMPI); MPI_File_close(&outMPI); MPI_File_close(&outMPIAccnos); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } outputTypes.clear(); delete chimera; return 0; } if (pid == 0) { //you are the root process string outTemp = "For full window mapping info refer to " + mapInfo + "\n"; @@ -355,7 +355,7 @@ int ChimeraCcodeCommand::execute(){ //align your part driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPI, outMPIAccnos, MPIPos); - if (m->control_pressed) { MPI_File_close(&inMPI); MPI_File_close(&outMPI); MPI_File_close(&outMPIAccnos); remove(outputFileName.c_str()); remove(accnosFileName.c_str()); for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } outputTypes.clear(); delete chimera; return 0; } + if (m->control_pressed) { MPI_File_close(&inMPI); MPI_File_close(&outMPI); MPI_File_close(&outMPIAccnos); m->mothurRemove(outputFileName); m->mothurRemove(accnosFileName); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } outputTypes.clear(); delete chimera; return 0; } }else{ //you are a child process MPI_Recv(&numSeqs, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status); @@ -371,7 +371,7 @@ int ChimeraCcodeCommand::execute(){ //align your part driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPI, outMPIAccnos, MPIPos); - if (m->control_pressed) { MPI_File_close(&inMPI); MPI_File_close(&outMPI); MPI_File_close(&outMPIAccnos); for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } outputTypes.clear(); delete chimera; return 0; } + if (m->control_pressed) { MPI_File_close(&inMPI); MPI_File_close(&outMPI); MPI_File_close(&outMPIAccnos); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } outputTypes.clear(); delete chimera; return 0; } } //close files @@ -402,7 +402,7 @@ int ChimeraCcodeCommand::execute(){ numSeqs = driver(lines[0], outputFileName, fastaFileNames[s], accnosFileName); - if (m->control_pressed) { remove(outputFileName.c_str()); remove(tempHeader.c_str()); remove(accnosFileName.c_str()); for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } for (int i = 0; i < lines.size(); i++) { delete lines[i]; } outputTypes.clear(); lines.clear(); delete chimera; return 0; } + if (m->control_pressed) { m->mothurRemove(outputFileName); m->mothurRemove(tempHeader); m->mothurRemove(accnosFileName); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } for (int i = 0; i < lines.size(); i++) { delete lines[i]; } outputTypes.clear(); lines.clear(); delete chimera; return 0; } }else{ processIDS.resize(0); @@ -415,19 +415,19 @@ int ChimeraCcodeCommand::execute(){ //append output files for(int i=1;iappendFiles((outputFileName + toString(processIDS[i]) + ".temp"), outputFileName); - remove((outputFileName + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((outputFileName + toString(processIDS[i]) + ".temp")); } //append output files for(int i=1;iappendFiles((accnosFileName + toString(processIDS[i]) + ".temp"), accnosFileName); - remove((accnosFileName + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((accnosFileName + toString(processIDS[i]) + ".temp")); } if (m->control_pressed) { - remove(outputFileName.c_str()); - remove(accnosFileName.c_str()); - for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } outputTypes.clear(); + m->mothurRemove(outputFileName); + m->mothurRemove(accnosFileName); + for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } outputTypes.clear(); for (int i = 0; i < lines.size(); i++) { delete lines[i]; } lines.clear(); delete chimera; return 0; @@ -438,13 +438,13 @@ int ChimeraCcodeCommand::execute(){ #else numSeqs = driver(lines[0], outputFileName, fastaFileNames[s], accnosFileName); - if (m->control_pressed) { remove(outputFileName.c_str()); remove(tempHeader.c_str()); remove(accnosFileName.c_str()); for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } for (int i = 0; i < lines.size(); i++) { delete lines[i]; } outputTypes.clear(); lines.clear(); delete chimera; return 0; } + if (m->control_pressed) { m->mothurRemove(outputFileName); m->mothurRemove(tempHeader); m->mothurRemove(accnosFileName); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } for (int i = 0; i < lines.size(); i++) { delete lines[i]; } outputTypes.clear(); lines.clear(); delete chimera; return 0; } #endif m->appendFiles(outputFileName, tempHeader); - remove(outputFileName.c_str()); + m->mothurRemove(outputFileName); rename(tempHeader.c_str(), outputFileName.c_str()); #endif @@ -648,7 +648,7 @@ int ChimeraCcodeCommand::createProcesses(string outputFileName, string filename, string tempFile = outputFileName + toString(processIDS[i]) + ".num.temp"; m->openInputFile(tempFile, in); if (!in.eof()) { int tempNum = 0; in >> tempNum; num += tempNum; } - in.close(); remove(tempFile.c_str()); + in.close(); m->mothurRemove(tempFile); } return num; diff --git a/chimeracheckcommand.cpp b/chimeracheckcommand.cpp index 584e987..2b88eb5 100644 --- a/chimeracheckcommand.cpp +++ b/chimeracheckcommand.cpp @@ -370,7 +370,7 @@ int ChimeraCheckCommand::execute(){ MPI_File_open(MPI_COMM_WORLD, inFileName, inMode, MPI_INFO_NULL, &inMPI); //comm, filename, mode, info, filepointer MPI_File_open(MPI_COMM_WORLD, outFilename, outMode, MPI_INFO_NULL, &outMPI); - if (m->control_pressed) { MPI_File_close(&inMPI); MPI_File_close(&outMPI); for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } outputTypes.clear(); delete chimera; return 0; } + if (m->control_pressed) { MPI_File_close(&inMPI); MPI_File_close(&outMPI); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } outputTypes.clear(); delete chimera; return 0; } if (pid == 0) { //you are the root process MPIPos = m->setFilePosFasta(fastaFileNames[i], numSeqs); //fills MPIPos, returns numSeqs @@ -390,7 +390,7 @@ int ChimeraCheckCommand::execute(){ //align your part driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPI, MPIPos); - if (m->control_pressed) { MPI_File_close(&inMPI); MPI_File_close(&outMPI); for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } outputTypes.clear(); delete chimera; return 0; } + if (m->control_pressed) { MPI_File_close(&inMPI); MPI_File_close(&outMPI); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } outputTypes.clear(); delete chimera; return 0; } //wait on chidren for(int j = 1; j < processors; j++) { @@ -410,7 +410,7 @@ int ChimeraCheckCommand::execute(){ //align your part driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPI, MPIPos); - if (m->control_pressed) { MPI_File_close(&inMPI); MPI_File_close(&outMPI); for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } outputTypes.clear(); delete chimera; return 0; } + if (m->control_pressed) { MPI_File_close(&inMPI); MPI_File_close(&outMPI); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } outputTypes.clear(); delete chimera; return 0; } //tell parent you are done. char buf[5]; @@ -435,7 +435,7 @@ int ChimeraCheckCommand::execute(){ if(processors == 1){ numSeqs = driver(lines[0], outputFileName, fastaFileNames[i]); - if (m->control_pressed) { for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } for (int j = 0; j < lines.size(); j++) { delete lines[j]; } outputTypes.clear(); lines.clear(); delete chimera; return 0; } + if (m->control_pressed) { for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } for (int j = 0; j < lines.size(); j++) { delete lines[j]; } outputTypes.clear(); lines.clear(); delete chimera; return 0; } }else{ processIDS.resize(0); @@ -447,11 +447,11 @@ int ChimeraCheckCommand::execute(){ //append output files for(int j=1;jappendFiles((outputFileName + toString(processIDS[j]) + ".temp"), outputFileName); - remove((outputFileName + toString(processIDS[j]) + ".temp").c_str()); + m->mothurRemove((outputFileName + toString(processIDS[j]) + ".temp")); } if (m->control_pressed) { - for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } outputTypes.clear(); + for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } outputTypes.clear(); for (int j = 0; j < lines.size(); j++) { delete lines[j]; } lines.clear(); delete chimera; return 0; @@ -461,7 +461,7 @@ int ChimeraCheckCommand::execute(){ #else numSeqs = driver(lines[0], outputFileName, fastaFileNames[i]); - if (m->control_pressed) { for (int j = 0; j < lines.size(); j++) { delete lines[j]; } lines.clear(); for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } outputTypes.clear(); delete chimera; return 0; } + if (m->control_pressed) { for (int j = 0; j < lines.size(); j++) { delete lines[j]; } lines.clear(); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } outputTypes.clear(); delete chimera; return 0; } #endif #endif delete chimera; @@ -636,7 +636,7 @@ int ChimeraCheckCommand::createProcesses(string outputFileName, string filename) string tempFile = outputFileName + toString(processIDS[i]) + ".num.temp"; m->openInputFile(tempFile, in); if (!in.eof()) { int tempNum = 0; in >> tempNum; num += tempNum; } - in.close(); remove(tempFile.c_str()); + in.close(); m->mothurRemove(tempFile); } return num; diff --git a/chimerapintailcommand.cpp b/chimerapintailcommand.cpp index 66fe65d..01a905f 100644 --- a/chimerapintailcommand.cpp +++ b/chimerapintailcommand.cpp @@ -405,7 +405,7 @@ int ChimeraPintailCommand::execute(){ accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "pintail.accnos"; } - if (m->control_pressed) { delete chimera; for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } return 0; } + if (m->control_pressed) { delete chimera; for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } return 0; } if (chimera->getUnaligned()) { m->mothurOut("Your template sequences are different lengths, please correct."); m->mothurOutEndLine(); @@ -443,7 +443,7 @@ int ChimeraPintailCommand::execute(){ MPI_File_open(MPI_COMM_WORLD, outFilename, outMode, MPI_INFO_NULL, &outMPI); MPI_File_open(MPI_COMM_WORLD, outAccnosFilename, outMode, MPI_INFO_NULL, &outMPIAccnos); - if (m->control_pressed) { outputTypes.clear(); MPI_File_close(&inMPI); MPI_File_close(&outMPI); MPI_File_close(&outMPIAccnos); for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } delete chimera; return 0; } + if (m->control_pressed) { outputTypes.clear(); MPI_File_close(&inMPI); MPI_File_close(&outMPI); MPI_File_close(&outMPIAccnos); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } delete chimera; return 0; } if (pid == 0) { //you are the root process @@ -463,7 +463,7 @@ int ChimeraPintailCommand::execute(){ //do your part driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPI, outMPIAccnos, MPIPos); - if (m->control_pressed) { outputTypes.clear(); MPI_File_close(&inMPI); MPI_File_close(&outMPI); MPI_File_close(&outMPIAccnos); remove(outputFileName.c_str()); remove(accnosFileName.c_str()); for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } delete chimera; return 0; } + if (m->control_pressed) { outputTypes.clear(); MPI_File_close(&inMPI); MPI_File_close(&outMPI); MPI_File_close(&outMPIAccnos); m->mothurRemove(outputFileName); m->mothurRemove(accnosFileName); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } delete chimera; return 0; } }else{ //you are a child process MPI_Recv(&numSeqs, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status); @@ -478,7 +478,7 @@ int ChimeraPintailCommand::execute(){ //do your part driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPI, outMPIAccnos, MPIPos); - if (m->control_pressed) { outputTypes.clear(); MPI_File_close(&inMPI); MPI_File_close(&outMPI); MPI_File_close(&outMPIAccnos); for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } delete chimera; return 0; } + if (m->control_pressed) { outputTypes.clear(); MPI_File_close(&inMPI); MPI_File_close(&outMPI); MPI_File_close(&outMPIAccnos); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } delete chimera; return 0; } } //close files @@ -499,7 +499,7 @@ int ChimeraPintailCommand::execute(){ numSeqs = driver(lines[0], outputFileName, fastaFileNames[s], accnosFileName); - if (m->control_pressed) { outputTypes.clear(); remove(outputFileName.c_str()); remove(accnosFileName.c_str()); for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } for (int i = 0; i < lines.size(); i++) { delete lines[i]; } lines.clear(); delete chimera; return 0; } + if (m->control_pressed) { outputTypes.clear(); m->mothurRemove(outputFileName); m->mothurRemove(accnosFileName); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } for (int i = 0; i < lines.size(); i++) { delete lines[i]; } lines.clear(); delete chimera; return 0; } }else{ processIDS.resize(0); @@ -512,19 +512,19 @@ int ChimeraPintailCommand::execute(){ //append output files for(int i=1;iappendFiles((outputFileName + toString(processIDS[i]) + ".temp"), outputFileName); - remove((outputFileName + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((outputFileName + toString(processIDS[i]) + ".temp")); } //append output files for(int i=1;iappendFiles((accnosFileName + toString(processIDS[i]) + ".temp"), accnosFileName); - remove((accnosFileName + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((accnosFileName + toString(processIDS[i]) + ".temp")); } if (m->control_pressed) { - remove(outputFileName.c_str()); - remove(accnosFileName.c_str()); - for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } outputTypes.clear(); + m->mothurRemove(outputFileName); + m->mothurRemove(accnosFileName); + for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } outputTypes.clear(); for (int i = 0; i < lines.size(); i++) { delete lines[i]; } lines.clear(); delete chimera; return 0; @@ -534,7 +534,7 @@ int ChimeraPintailCommand::execute(){ #else numSeqs = driver(lines[0], outputFileName, fastaFileNames[s], accnosFileName); - if (m->control_pressed) { outputTypes.clear(); remove(outputFileName.c_str()); remove(accnosFileName.c_str()); for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } for (int i = 0; i < lines.size(); i++) { delete lines[i]; } lines.clear(); delete chimera; return 0; } + if (m->control_pressed) { outputTypes.clear(); m->mothurRemove(outputFileName); m->mothurRemove(accnosFileName); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } for (int i = 0; i < lines.size(); i++) { delete lines[i]; } lines.clear(); delete chimera; return 0; } #endif #endif @@ -736,7 +736,7 @@ int ChimeraPintailCommand::createProcesses(string outputFileName, string filenam string tempFile = outputFileName + toString(processIDS[i]) + ".num.temp"; m->openInputFile(tempFile, in); if (!in.eof()) { int tempNum = 0; in >> tempNum; num += tempNum; } - in.close(); remove(tempFile.c_str()); + in.close(); m->mothurRemove(tempFile); } return num; diff --git a/chimeraslayercommand.cpp b/chimeraslayercommand.cpp index c846a83..4c37a85 100644 --- a/chimeraslayercommand.cpp +++ b/chimeraslayercommand.cpp @@ -464,7 +464,7 @@ int ChimeraSlayerCommand::execute(){ map priority = sortFastaFile(fastaFileNames[s], nameFile); m->mothurOut("Done."); m->mothurOutEndLine(); - if (m->control_pressed) { for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } return 0; } + if (m->control_pressed) { for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } return 0; } chimera = new ChimeraSlayer(fastaFileNames[s], templatefile, trim, priority, search, ksize, match, mismatch, window, divR, minSimilarity, minCoverage, minBS, minSNP, parents, iters, increment, numwanted, realign); } @@ -474,7 +474,7 @@ int ChimeraSlayerCommand::execute(){ string accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "slayer.accnos"; string trimFastaFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "slayer.fasta"; - if (m->control_pressed) { delete chimera; for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } return 0; } + if (m->control_pressed) { delete chimera; for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } return 0; } if (chimera->getUnaligned()) { m->mothurOut("Your template sequences are different lengths, please correct."); m->mothurOutEndLine(); @@ -517,7 +517,7 @@ int ChimeraSlayerCommand::execute(){ MPI_File_open(MPI_COMM_WORLD, outAccnosFilename, outMode, MPI_INFO_NULL, &outMPIAccnos); if (trim) { MPI_File_open(MPI_COMM_WORLD, outFastaFilename, outMode, MPI_INFO_NULL, &outMPIFasta); } - if (m->control_pressed) { outputTypes.clear(); MPI_File_close(&inMPI); MPI_File_close(&outMPI); if (trim) { MPI_File_close(&outMPIFasta); } MPI_File_close(&outMPIAccnos); for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } delete chimera; return 0; } + if (m->control_pressed) { outputTypes.clear(); MPI_File_close(&inMPI); MPI_File_close(&outMPI); if (trim) { MPI_File_close(&outMPIFasta); } MPI_File_close(&outMPIAccnos); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } delete chimera; return 0; } if (pid == 0) { //you are the root process m->mothurOutEndLine(); @@ -566,7 +566,7 @@ int ChimeraSlayerCommand::execute(){ if (numSeqs == numNoParents) { m->mothurOut("[WARNING]: megablast returned 0 potential parents for all your sequences. This could be due to formatdb.exe not being setup properly, please check formatdb.log for errors."); m->mothurOutEndLine(); } - if (m->control_pressed) { outputTypes.clear(); MPI_File_close(&inMPI); MPI_File_close(&outMPI); if (trim) { MPI_File_close(&outMPIFasta); } MPI_File_close(&outMPIAccnos); for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } remove(outputFileName.c_str()); remove(accnosFileName.c_str()); delete chimera; return 0; } + if (m->control_pressed) { outputTypes.clear(); MPI_File_close(&inMPI); MPI_File_close(&outMPI); if (trim) { MPI_File_close(&outMPIFasta); } MPI_File_close(&outMPIAccnos); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } m->mothurRemove(outputFileName); m->mothurRemove(accnosFileName); delete chimera; return 0; } }else{ //you are a child process if (templatefile != "self") { //if template=self we can only use 1 processor @@ -585,7 +585,7 @@ int ChimeraSlayerCommand::execute(){ int numNoParents = chimera->getNumNoParents(); MPI_Send(&numNoParents, 1, MPI_INT, 0, tag, MPI_COMM_WORLD); - if (m->control_pressed) { outputTypes.clear(); MPI_File_close(&inMPI); MPI_File_close(&outMPI); if (trim) { MPI_File_close(&outMPIFasta); } MPI_File_close(&outMPIAccnos); for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } delete chimera; return 0; } + if (m->control_pressed) { outputTypes.clear(); MPI_File_close(&inMPI); MPI_File_close(&outMPI); if (trim) { MPI_File_close(&outMPIFasta); } MPI_File_close(&outMPIAccnos); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } delete chimera; return 0; } } } @@ -619,7 +619,7 @@ int ChimeraSlayerCommand::execute(){ int numNoParents = chimera->getNumNoParents(); if (numNoParents == numSeqs) { m->mothurOut("[WARNING]: megablast returned 0 potential parents for all your sequences. This could be due to formatdb.exe not being setup properly, please check formatdb.log for errors."); m->mothurOutEndLine(); } - if (m->control_pressed) { outputTypes.clear(); if (trim) { remove(trimFastaFileName.c_str()); } remove(outputFileName.c_str()); remove(tempHeader.c_str()); remove(accnosFileName.c_str()); for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } for (int i = 0; i < lines.size(); i++) { delete lines[i]; } lines.clear(); delete chimera; return 0; } + if (m->control_pressed) { outputTypes.clear(); if (trim) { m->mothurRemove(trimFastaFileName); } m->mothurRemove(outputFileName); m->mothurRemove(tempHeader); m->mothurRemove(accnosFileName); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } for (int i = 0; i < lines.size(); i++) { delete lines[i]; } lines.clear(); delete chimera; return 0; } }else{ processIDS.resize(0); @@ -633,23 +633,23 @@ int ChimeraSlayerCommand::execute(){ //append output files for(int i=1;iappendFiles((outputFileName + toString(processIDS[i]) + ".temp"), outputFileName); - remove((outputFileName + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((outputFileName + toString(processIDS[i]) + ".temp")); } //append output files for(int i=1;iappendFiles((accnosFileName + toString(processIDS[i]) + ".temp"), accnosFileName); - remove((accnosFileName + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((accnosFileName + toString(processIDS[i]) + ".temp")); } if (trim) { for(int i=1;iappendFiles((trimFastaFileName + toString(processIDS[i]) + ".temp"), trimFastaFileName); - remove((trimFastaFileName + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((trimFastaFileName + toString(processIDS[i]) + ".temp")); } } - if (m->control_pressed) { outputTypes.clear(); if (trim) { remove(trimFastaFileName.c_str()); } remove(outputFileName.c_str()); remove(accnosFileName.c_str()); for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } for (int i = 0; i < lines.size(); i++) { delete lines[i]; } lines.clear(); delete chimera; return 0; } + if (m->control_pressed) { outputTypes.clear(); if (trim) { m->mothurRemove(trimFastaFileName); } m->mothurRemove(outputFileName); m->mothurRemove(accnosFileName); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } for (int i = 0; i < lines.size(); i++) { delete lines[i]; } lines.clear(); delete chimera; return 0; } } #else @@ -659,13 +659,13 @@ int ChimeraSlayerCommand::execute(){ if (numNoParents == numSeqs) { m->mothurOut("[WARNING]: megablast returned 0 potential parents for all your sequences. This could be due to formatdb.exe not being setup properly, please check formatdb.log for errors."); m->mothurOutEndLine(); } - if (m->control_pressed) { outputTypes.clear(); if (trim) { remove(trimFastaFileName.c_str()); } remove(outputFileName.c_str()); remove(tempHeader.c_str()); remove(accnosFileName.c_str()); for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } for (int i = 0; i < lines.size(); i++) { delete lines[i]; } lines.clear(); delete chimera; return 0; } + if (m->control_pressed) { outputTypes.clear(); if (trim) { m->mothurRemove(trimFastaFileName); } m->mothurRemove(outputFileName); m->mothurRemove(tempHeader); m->mothurRemove(accnosFileName); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } for (int i = 0; i < lines.size(); i++) { delete lines[i]; } lines.clear(); delete chimera; return 0; } #endif m->appendFiles(outputFileName, tempHeader); - remove(outputFileName.c_str()); + m->mothurRemove(outputFileName); rename(tempHeader.c_str(), outputFileName.c_str()); #endif @@ -994,7 +994,7 @@ int ChimeraSlayerCommand::createProcesses(string outputFileName, string filename string tempFile = outputFileName + toString(processIDS[i]) + ".num.temp"; m->openInputFile(tempFile, in); if (!in.eof()) { int tempNum = 0; int tempNumParents = 0; in >> tempNum >> tempNumParents; num += tempNum; numNoParents += tempNumParents; } - in.close(); remove(tempFile.c_str()); + in.close(); m->mothurRemove(tempFile); } if (num == numNoParents) { m->mothurOut("[WARNING]: megablast returned 0 potential parents for all your sequences. This could be due to formatdb.exe not being setup properly, please check formatdb.log for errors."); m->mothurOutEndLine(); } diff --git a/chimerauchimecommand.cpp b/chimerauchimecommand.cpp index b42a491..4c1db20 100644 --- a/chimerauchimecommand.cpp +++ b/chimerauchimecommand.cpp @@ -435,7 +435,7 @@ int ChimeraUchimeCommand::execute(){ while (!in.eof()) { - if (m->control_pressed) { in.close(); for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } return 0; } + if (m->control_pressed) { in.close(); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } return 0; } Sequence seq(in); m->gobble(in); seqs[seq.getName()] = seq.getAligned(); @@ -446,10 +446,10 @@ int ChimeraUchimeCommand::execute(){ vector nameMapCount; int error = m->readNames(nameFile, nameMapCount, seqs); - if (m->control_pressed) { for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } return 0; } + if (m->control_pressed) { for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } return 0; } - if (error == 1) { for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } return 0; } - if (seqs.size() != nameMapCount.size()) { m->mothurOut( "The number of sequences in your fastafile does not match the number of sequences in your namefile, aborting."); m->mothurOutEndLine(); for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } return 0; } + if (error == 1) { for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } return 0; } + if (seqs.size() != nameMapCount.size()) { m->mothurOut( "The number of sequences in your fastafile does not match the number of sequences in your namefile, aborting."); m->mothurOutEndLine(); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } return 0; } sort(nameMapCount.begin(), nameMapCount.end(), compareSeqPriorityNodes); @@ -468,7 +468,7 @@ int ChimeraUchimeCommand::execute(){ #ifdef USE_MPI } #endif - if (m->control_pressed) { for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } return 0; } + if (m->control_pressed) { for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } return 0; } } if (outputDir == "") { outputDir = m->hasPath(fastaFileNames[s]); }//if user entered a file with a path then preserve it @@ -476,7 +476,7 @@ int ChimeraUchimeCommand::execute(){ string accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "uchime.accnos"; string alnsFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "uchime.alns"; - if (m->control_pressed) { for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } return 0; } + if (m->control_pressed) { for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } return 0; } int numSeqs = 0; #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) @@ -485,10 +485,10 @@ int ChimeraUchimeCommand::execute(){ #else numSeqs = driver(outputFileName, fastaFileNames[s], accnosFileName, alnsFileName); #endif - if (m->control_pressed) { for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } return 0; } + if (m->control_pressed) { for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } return 0; } //remove file made for uchime - if (templatefile == "self") { remove(fastaFileNames[s].c_str()); } + if (templatefile == "self") { m->mothurRemove(fastaFileNames[s]); } outputNames.push_back(outputFileName); outputTypes["chimera"].push_back(outputFileName); outputNames.push_back(accnosFileName); outputTypes["accnos"].push_back(accnosFileName); @@ -830,14 +830,14 @@ int ChimeraUchimeCommand::createProcesses(string outputFileName, string filename num += temp; m->appendFiles((outputFileName + toString(j) + ".temp"), outputFileName); - remove((outputFileName + toString(j) + ".temp").c_str()); + m->mothurRemove((outputFileName + toString(j) + ".temp")); m->appendFiles((accnos + toString(j) + ".temp"), accnos); - remove((accnos + toString(j) + ".temp").c_str()); + m->mothurRemove((accnos + toString(j) + ".temp")); if (chimealns) { m->appendFiles((alns + toString(j) + ".temp"), alns); - remove((alns + toString(j) + ".temp").c_str()); + m->mothurRemove((alns + toString(j) + ".temp")); } } } @@ -892,26 +892,26 @@ int ChimeraUchimeCommand::createProcesses(string outputFileName, string filename string tempFile = outputFileName + toString(processIDS[i]) + ".num.temp"; m->openInputFile(tempFile, in); if (!in.eof()) { int tempNum = 0; in >> tempNum; num += tempNum; } - in.close(); remove(tempFile.c_str()); + in.close(); m->mothurRemove(tempFile); } //append output files for(int i=0;iappendFiles((outputFileName + toString(processIDS[i]) + ".temp"), outputFileName); - remove((outputFileName + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((outputFileName + toString(processIDS[i]) + ".temp")); m->appendFiles((accnos + toString(processIDS[i]) + ".temp"), accnos); - remove((accnos + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((accnos + toString(processIDS[i]) + ".temp")); if (chimealns) { m->appendFiles((alns + toString(processIDS[i]) + ".temp"), alns); - remove((alns + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((alns + toString(processIDS[i]) + ".temp")); } } #endif //get rid of the file pieces. - for (int i = 0; i < files.size(); i++) { remove(files[i].c_str()); } + for (int i = 0; i < files.size(); i++) { m->mothurRemove(files[i]); } #endif return num; } diff --git a/chopseqscommand.cpp b/chopseqscommand.cpp index fc4327f..e2b0fa4 100644 --- a/chopseqscommand.cpp +++ b/chopseqscommand.cpp @@ -165,7 +165,7 @@ int ChopSeqsCommand::execute(){ Sequence seq(in); - if (m->control_pressed) { outputTypes.clear(); in.close(); out.close(); outAcc.close(); remove(outputFileName.c_str()); remove(outputFileNameAccnos.c_str()); return 0; } + if (m->control_pressed) { outputTypes.clear(); in.close(); out.close(); outAcc.close(); m->mothurRemove(outputFileName); m->mothurRemove(outputFileNameAccnos); return 0; } if (seq.getName() != "") { string newSeqString = getChopped(seq); @@ -188,7 +188,7 @@ int ChopSeqsCommand::execute(){ m->mothurOut(outputFileName); m->mothurOutEndLine(); outputNames.push_back(outputFileName); outputTypes["fasta"].push_back(outputFileName); if (wroteAccnos) { m->mothurOut(outputFileNameAccnos); m->mothurOutEndLine(); outputNames.push_back(outputFileNameAccnos); outputTypes["accnos"].push_back(outputFileNameAccnos); } - else { remove(outputFileNameAccnos.c_str()); } + else { m->mothurRemove(outputFileNameAccnos); } m->mothurOutEndLine(); diff --git a/classifyotucommand.cpp b/classifyotucommand.cpp index d065b3a..7b1a04f 100644 --- a/classifyotucommand.cpp +++ b/classifyotucommand.cpp @@ -244,7 +244,7 @@ int ClassifyOtuCommand::execute(){ set processedLabels; set userLabels = labels; - if (m->control_pressed) { outputTypes.clear(); delete input; delete list; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { outputTypes.clear(); delete input; delete list; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } while((list != NULL) && ((allLines == 1) || (userLabels.size() != 0))) { @@ -252,7 +252,7 @@ int ClassifyOtuCommand::execute(){ m->mothurOut(list->getLabel() + "\t" + toString(list->size())); m->mothurOutEndLine(); process(list); - if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } delete input; delete list; return 0; } + if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } delete input; delete list; return 0; } processedLabels.insert(list->getLabel()); userLabels.erase(list->getLabel()); @@ -267,7 +267,7 @@ int ClassifyOtuCommand::execute(){ process(list); - if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } delete input; delete list; return 0; } + if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } delete input; delete list; return 0; } processedLabels.insert(list->getLabel()); userLabels.erase(list->getLabel()); @@ -303,12 +303,12 @@ int ClassifyOtuCommand::execute(){ process(list); delete list; - if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } delete input; delete list; return 0; } + if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } delete input; delete list; return 0; } } delete input; - if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); @@ -451,7 +451,7 @@ vector ClassifyOtuCommand::findConsensusTaxonomy(int bin, ListVector* th phylo->assignHeirarchyIDs(0); TaxNode currentNode = phylo->get(0); - + int myLevel = 0; //at each level while (currentNode.children.size() != 0) { //you still have more to explore @@ -480,6 +480,7 @@ vector ClassifyOtuCommand::findConsensusTaxonomy(int bin, ListVector* th }else{ conTax += bestChild.name + ";"; } + myLevel++; }else{ //if no, quit break; } @@ -488,7 +489,12 @@ vector ClassifyOtuCommand::findConsensusTaxonomy(int bin, ListVector* th currentNode = bestChild; } - + if (myLevel != phylo->getMaxLevel()) { + while (myLevel != phylo->getMaxLevel()) { + conTax += "unclassified;"; + myLevel++; + } + } if (conTax == "") { conTax = "no_consensus;"; } delete phylo; @@ -570,6 +576,35 @@ int ClassifyOtuCommand::process(ListVector* processList) { exit(1); } } +/**************************************************************************************************/ +string ClassifyOtuCommand::addUnclassifieds(string tax, int maxlevel) { + try{ + string newTax, taxon; + int level = 0; + + //keep what you have counting the levels + while (tax.find_first_of(';') != -1) { + //get taxon + taxon = tax.substr(0,tax.find_first_of(';'))+';'; + tax = tax.substr(tax.find_first_of(';')+1, tax.length()); + newTax += taxon; + level++; + } + + //add "unclassified" until you reach maxLevel + while (level < maxlevel) { + newTax += "unclassified;"; + level++; + } + + return newTax; + } + catch(exception& e) { + m->errorOut(e, "ClassifyOtuCommand", "addUnclassifieds"); + exit(1); + } +} + /**************************************************************************************************/ void ClassifyOtuCommand::removeConfidences(string& tax) { try { diff --git a/classifyotucommand.h b/classifyotucommand.h index b3ca653..d1c1734 100644 --- a/classifyotucommand.h +++ b/classifyotucommand.h @@ -48,6 +48,7 @@ private: int readTaxonomyFile(); void removeConfidences(string&); int process(ListVector*); + string addUnclassifieds(string, int); vector findConsensusTaxonomy(int, ListVector*, int&, string&); // returns the name of the "representative" taxonomy of given bin diff --git a/classifyseqscommand.cpp b/classifyseqscommand.cpp index f1b3a0e..d9bd698 100644 --- a/classifyseqscommand.cpp +++ b/classifyseqscommand.cpp @@ -565,7 +565,7 @@ int ClassifySeqsCommand::execute(){ //align your part driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPINewTax, outMPITempTax, MPIPos); - if (m->control_pressed) { outputTypes.clear(); MPI_File_close(&inMPI); MPI_File_close(&outMPINewTax); MPI_File_close(&outMPITempTax); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } delete classify; return 0; } + if (m->control_pressed) { outputTypes.clear(); MPI_File_close(&inMPI); MPI_File_close(&outMPINewTax); MPI_File_close(&outMPITempTax); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } delete classify; return 0; } for (int i = 1; i < processors; i++) { int done; @@ -660,7 +660,7 @@ int ClassifySeqsCommand::execute(){ PhyloSummary taxaSum(baseTName, group); - if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } delete classify; return 0; } + if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } delete classify; return 0; } if (namefile == "") { taxaSum.summarize(tempTaxonomyFile); } else { @@ -687,9 +687,9 @@ int ClassifySeqsCommand::execute(){ } in.close(); } - remove(tempTaxonomyFile.c_str()); + m->mothurRemove(tempTaxonomyFile); - if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } delete classify; return 0; } + if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } delete classify; return 0; } //print summary file ofstream outTaxTree; @@ -711,7 +711,7 @@ int ClassifySeqsCommand::execute(){ //read taxfile - this reading and rewriting is done to preserve the confidence scores. string name, taxon; while (!inTax.eof()) { - if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } remove(unclass.c_str()); delete classify; return 0; } + if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } m->mothurRemove(unclass); delete classify; return 0; } inTax >> name >> taxon; m->gobble(inTax); @@ -722,7 +722,7 @@ int ClassifySeqsCommand::execute(){ inTax.close(); outTax.close(); - remove(newTaxonomyFile.c_str()); + m->mothurRemove(newTaxonomyFile); rename(unclass.c_str(), newTaxonomyFile.c_str()); m->mothurOutEndLine(); @@ -800,7 +800,7 @@ int ClassifySeqsCommand::createProcesses(string taxFileName, string tempTaxFile, process++; }else if (pid == 0){ num = driver(lines[process], taxFileName + toString(getpid()) + ".temp", tempTaxFile + toString(getpid()) + ".temp", filename); - + //pass numSeqs to parent ofstream out; string tempFile = filename + toString(getpid()) + ".num.temp"; @@ -830,14 +830,14 @@ int ClassifySeqsCommand::createProcesses(string taxFileName, string tempTaxFile, string tempFile = filename + toString(processIDS[i]) + ".num.temp"; m->openInputFile(tempFile, in); if (!in.eof()) { int tempNum = 0; in >> tempNum; num += tempNum; } - in.close(); remove(tempFile.c_str()); + in.close(); m->mothurRemove(m->getFullPathName(tempFile)); } for(int i=0;imothurRemove((m->getFullPathName(taxFileName) + toString(processIDS[i]) + ".temp")); + m->mothurRemove((m->getFullPathName(tempTaxFile) + toString(processIDS[i]) + ".temp")); } return num; diff --git a/clustercommand.cpp b/clustercommand.cpp index fd1f841..059f277 100644 --- a/clustercommand.cpp +++ b/clustercommand.cpp @@ -244,7 +244,7 @@ int ClusterCommand::execute(){ if (m->control_pressed) { //clean up delete list; delete matrix; delete rabund; sabundFile.close();rabundFile.close();listFile.close(); - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); return 0; } @@ -283,7 +283,7 @@ int ClusterCommand::execute(){ if (m->control_pressed) { //clean up delete list; delete matrix; delete rabund; delete cluster; sabundFile.close();rabundFile.close();listFile.close(); - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); return 0; } diff --git a/clusterdoturcommand.cpp b/clusterdoturcommand.cpp index 3f629dc..0d57e68 100644 --- a/clusterdoturcommand.cpp +++ b/clusterdoturcommand.cpp @@ -219,7 +219,7 @@ int ClusterDoturCommand::execute(){ int estart = time(NULL); while ((cluster->getSmallDist() < cutoff) && (cluster->getNSeqs() > 1)){ - if (m->control_pressed) { delete cluster; delete list; delete rabund; sabundFile.close();rabundFile.close();listFile.close(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); return 0; } + if (m->control_pressed) { delete cluster; delete list; delete rabund; sabundFile.close();rabundFile.close();listFile.close(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); return 0; } cluster->update(cutoff); diff --git a/clusterfragmentscommand.cpp b/clusterfragmentscommand.cpp index 71ce5ee..5c8d12b 100644 --- a/clusterfragmentscommand.cpp +++ b/clusterfragmentscommand.cpp @@ -238,7 +238,7 @@ int ClusterFragmentsCommand::execute(){ m->mothurOut("It took " + toString(time(NULL) - start) + " secs to cluster " + toString(numSeqs) + " sequences."); m->mothurOutEndLine(); - if (m->control_pressed) { remove(newFastaFile.c_str()); remove(newNamesFile.c_str()); return 0; } + if (m->control_pressed) { m->mothurRemove(newFastaFile); m->mothurRemove(newNamesFile); return 0; } m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); diff --git a/clustersplitcommand.cpp b/clustersplitcommand.cpp index 9999eb0..1f99efc 100644 --- a/clustersplitcommand.cpp +++ b/clustersplitcommand.cpp @@ -596,7 +596,7 @@ int ClusterSplitCommand::execute(){ listFileNames.push_back(tempName); } in.close(); - remove((toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((toString(processIDS[i]) + ".temp")); //get labels filename = toString(processIDS[i]) + ".temp.labels"; @@ -613,14 +613,14 @@ int ClusterSplitCommand::execute(){ if (labels.count(tempName) == 0) { labels.insert(tempName); } } in2.close(); - remove((toString(processIDS[i]) + ".temp.labels").c_str()); + m->mothurRemove((toString(processIDS[i]) + ".temp.labels")); } } #else listFileNames = cluster(distName, labels); //clusters individual files and returns names of list files #endif #endif - if (m->control_pressed) { for (int i = 0; i < listFileNames.size(); i++) { remove(listFileNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < listFileNames.size(); i++) { m->mothurRemove(listFileNames[i]); } return 0; } if (saveCutoff != cutoff) { m->mothurOut("Cutoff was " + toString(saveCutoff) + " changed cutoff to " + toString(cutoff)); m->mothurOutEndLine(); } @@ -637,11 +637,11 @@ int ClusterSplitCommand::execute(){ ListVector* listSingle; map labelBins = completeListFile(listFileNames, singletonName, labels, listSingle); //returns map of label to numBins - if (m->control_pressed) { if (listSingle != NULL) { delete listSingle; } for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { if (listSingle != NULL) { delete listSingle; } for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } mergeLists(listFileNames, labelBins, listSingle); - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } m->mothurOut("It took " + toString(time(NULL) - estart) + " seconds to merge."); m->mothurOutEndLine(); @@ -703,7 +703,7 @@ map ClusterSplitCommand::completeListFile(vector listNames, listSingle->push_back(secondCol); } in.close(); - remove(singleton.c_str()); + m->mothurRemove(singleton); numSingleBins = listSingle->getNumBins(); }else{ listSingle = NULL; numSingleBins = 0; } @@ -729,8 +729,8 @@ map ClusterSplitCommand::completeListFile(vector listNames, for (int k = 0; k < listNames.size(); k++) { if (m->control_pressed) { - if (listSingle != NULL) { delete listSingle; listSingle = NULL; remove(singleton.c_str()); } - for (int i = 0; i < listNames.size(); i++) { remove(listNames[i].c_str()); } + if (listSingle != NULL) { delete listSingle; listSingle = NULL; m->mothurRemove(singleton); } + for (int i = 0; i < listNames.size(); i++) { m->mothurRemove(listNames[i]); } return labelBin; } @@ -783,7 +783,7 @@ map ClusterSplitCommand::completeListFile(vector listNames, delete input; outFilled.close(); - remove(listNames[k].c_str()); + m->mothurRemove(listNames[k]); rename(filledInList.c_str(), listNames[k].c_str()); } @@ -833,7 +833,7 @@ int ClusterSplitCommand::mergeLists(vector listNames, map us //get the list info from each file for (int k = 0; k < listNames.size(); k++) { - if (m->control_pressed) { if (listSingle != NULL) { delete listSingle; } for (int i = 0; i < listNames.size(); i++) { remove(listNames[i].c_str()); } delete rabund; return 0; } + if (m->control_pressed) { if (listSingle != NULL) { delete listSingle; } for (int i = 0; i < listNames.size(); i++) { m->mothurRemove(listNames[i]); } delete rabund; return 0; } InputData* input = new InputData(listNames[k], "list"); ListVector* list = input->getListVector(thisLabel); @@ -865,7 +865,7 @@ int ClusterSplitCommand::mergeLists(vector listNames, map us if (listSingle != NULL) { delete listSingle; } - for (int i = 0; i < listNames.size(); i++) { remove(listNames[i].c_str()); } + for (int i = 0; i < listNames.size(); i++) { m->mothurRemove(listNames[i]); } return 0; } @@ -1047,7 +1047,7 @@ vector ClusterSplitCommand::cluster(vector< map > distNa if (m->control_pressed) { //clean up delete matrix; delete list; delete cluster; delete rabund; listFile.close(); - for (int i = 0; i < listFileNames.size(); i++) { remove(listFileNames[i].c_str()); } + for (int i = 0; i < listFileNames.size(); i++) { m->mothurRemove(listFileNames[i]); } listFileNames.clear(); return listFileNames; } @@ -1093,12 +1093,12 @@ vector ClusterSplitCommand::cluster(vector< map > distNa listFile.close(); if (m->control_pressed) { //clean up - for (int i = 0; i < listFileNames.size(); i++) { remove(listFileNames[i].c_str()); } + for (int i = 0; i < listFileNames.size(); i++) { m->mothurRemove(listFileNames[i]); } listFileNames.clear(); return listFileNames; } - remove(thisDistFile.c_str()); - remove(thisNamefile.c_str()); + m->mothurRemove(thisDistFile); + m->mothurRemove(thisNamefile); if (saveCutoff != cutoff) { if (hard) { saveCutoff = m->ceilDist(saveCutoff, precision); } @@ -1137,7 +1137,7 @@ int ClusterSplitCommand::createMergedDistanceFile(vector< map > string thisOutputDir = outputDir; if (outputDir == "") { thisOutputDir = m->hasPath(fastafile); } string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "dist"; - remove(outputFileName.c_str()); + m->mothurRemove(outputFileName); for (int i = 0; i < distNames.size(); i++) { diff --git a/collectcommand.cpp b/collectcommand.cpp index 5bd9fd7..89ab0a4 100644 --- a/collectcommand.cpp +++ b/collectcommand.cpp @@ -307,7 +307,7 @@ int CollectCommand::execute(){ for (int p = 0; p < inputFileNames.size(); p++) { - if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } m->Groups.clear(); return 0; } + if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } m->Groups.clear(); return 0; } if (outputDir == "") { outputDir += m->hasPath(inputFileNames[p]); } string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(inputFileNames[p])); @@ -413,7 +413,7 @@ int CollectCommand::execute(){ if (m->control_pressed) { for(int i=0;imothurRemove(outputNames[i]); } outputTypes.clear(); delete input; delete order; m->Groups.clear(); @@ -425,7 +425,7 @@ int CollectCommand::execute(){ if (m->control_pressed) { for(int i=0;imothurRemove(outputNames[i]); } outputTypes.clear(); delete input; delete order; m->Groups.clear(); @@ -474,7 +474,7 @@ int CollectCommand::execute(){ if (m->control_pressed) { for(int i=0;imothurRemove(outputNames[i]); } outputTypes.clear(); delete input; m->Groups.clear(); return 0; @@ -506,7 +506,7 @@ int CollectCommand::execute(){ if (m->control_pressed) { for(int i=0;imothurRemove(outputNames[i]); } outputTypes.clear(); delete input; delete order; m->Groups.clear(); @@ -520,7 +520,7 @@ int CollectCommand::execute(){ delete input; } - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); @@ -551,7 +551,7 @@ vector CollectCommand::parseSharedFile(string filename) { //clears file before we start to write to it below for (int i=0; igetGroup() + ".rabund").c_str()); + m->mothurRemove((sharedFileRoot + lookup[i]->getGroup() + ".rabund")); filenames.push_back((sharedFileRoot + lookup[i]->getGroup() + ".rabund")); } diff --git a/collectsharedcommand.cpp b/collectsharedcommand.cpp index 202883e..3b43a40 100644 --- a/collectsharedcommand.cpp +++ b/collectsharedcommand.cpp @@ -445,7 +445,7 @@ int CollectSharedCommand::execute(){ while((order != NULL) && ((allLines == 1) || (userLabels.size() != 0))) { if (m->control_pressed) { - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); for(int i=0;iGroups.clear(); @@ -493,7 +493,7 @@ int CollectSharedCommand::execute(){ } if (m->control_pressed) { - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); for(int i=0;iGroups.clear(); delete input; @@ -524,7 +524,7 @@ int CollectSharedCommand::execute(){ delete cCurve; if (m->control_pressed) { - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); for(int i=0;i::iterator it = nameMap.begin(); it != nameMap.end(); it++) { - if (m->control_pressed) { outSummary.close(); outFasta.close(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { outSummary.close(); outFasta.close(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } string seq = fastaMap[it->second]; seqs.push_back(seq); @@ -223,7 +223,7 @@ int ConsensusSeqsCommand::execute(){ //get counts for (int j = 0; j < seqLength; j++) { - if (m->control_pressed) { outSummary.close(); outFasta.close(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { outSummary.close(); outFasta.close(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } vector counts; counts.resize(5, 0); //A,T,G,C,Gap int numDots = 0; @@ -276,7 +276,7 @@ int ConsensusSeqsCommand::execute(){ //as long as you are not at the end of the file or done wih the lines you want while((list != NULL) && ((allLines == 1) || (userLabels.size() != 0))) { - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } delete list; delete input; return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } delete list; delete input; return 0; } if(allLines == 1 || labels.count(list->getLabel()) == 1){ @@ -314,7 +314,7 @@ int ConsensusSeqsCommand::execute(){ } - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } if (list != NULL) { delete list; } delete input; return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } if (list != NULL) { delete list; } delete input; return 0; } //output error messages about any remaining user labels set::iterator it; diff --git a/countseqscommand.cpp b/countseqscommand.cpp index a7890b8..0d8ddf5 100644 --- a/countseqscommand.cpp +++ b/countseqscommand.cpp @@ -222,7 +222,7 @@ int CountSeqsCommand::execute(){ if (groupfile != "") { delete groupMap; } - if (m->control_pressed) { remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { m->mothurRemove(outputFileName); return 0; } m->mothurOutEndLine(); m->mothurOut("Output File Name: "); m->mothurOutEndLine(); diff --git a/deconvolutecommand.cpp b/deconvolutecommand.cpp index 5888fee..bc2dd48 100644 --- a/deconvolutecommand.cpp +++ b/deconvolutecommand.cpp @@ -165,7 +165,7 @@ int DeconvoluteCommand::execute() { int count = 0; while (!in.eof()) { - if (m->control_pressed) { in.close(); outFasta.close(); remove(outFastaFile.c_str()); return 0; } + if (m->control_pressed) { in.close(); outFasta.close(); m->mothurRemove(outFastaFile); return 0; } Sequence seq(in); @@ -216,14 +216,14 @@ int DeconvoluteCommand::execute() { in.close(); outFasta.close(); - if (m->control_pressed) { remove(outFastaFile.c_str()); return 0; } + if (m->control_pressed) { m->mothurRemove(outFastaFile); return 0; } //print new names file ofstream outNames; m->openOutputFile(outNameFile, outNames); for (itStrings = sequenceStrings.begin(); itStrings != sequenceStrings.end(); itStrings++) { - if (m->control_pressed) { outputTypes.clear(); remove(outFastaFile.c_str()); outNames.close(); remove(outNameFile.c_str()); return 0; } + if (m->control_pressed) { outputTypes.clear(); m->mothurRemove(outFastaFile); outNames.close(); m->mothurRemove(outNameFile); return 0; } //get rep name int pos = (itStrings->second).find_first_of(','); @@ -236,7 +236,7 @@ int DeconvoluteCommand::execute() { } outNames.close(); - if (m->control_pressed) { outputTypes.clear(); remove(outFastaFile.c_str()); remove(outNameFile.c_str()); return 0; } + if (m->control_pressed) { outputTypes.clear(); m->mothurRemove(outFastaFile); m->mothurRemove(outNameFile); return 0; } m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); diff --git a/degapseqscommand.cpp b/degapseqscommand.cpp index f590d8b..1d83f3b 100644 --- a/degapseqscommand.cpp +++ b/degapseqscommand.cpp @@ -197,7 +197,7 @@ int DegapSeqsCommand::execute(){ m->openOutputFile(degapFile, outFASTA); while(!inFASTA.eof()){ - if (m->control_pressed) { outputTypes.clear(); inFASTA.close(); outFASTA.close(); remove(degapFile.c_str()); for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } return 0; } + if (m->control_pressed) { outputTypes.clear(); inFASTA.close(); outFASTA.close(); m->mothurRemove(degapFile); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } return 0; } Sequence currSeq(inFASTA); m->gobble(inFASTA); if (currSeq.getName() != "") { @@ -210,7 +210,7 @@ int DegapSeqsCommand::execute(){ outputNames.push_back(degapFile); outputTypes["fasta"].push_back(degapFile); - if (m->control_pressed) { outputTypes.clear(); remove(degapFile.c_str()); for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } return 0; } + if (m->control_pressed) { outputTypes.clear(); m->mothurRemove(degapFile); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } return 0; } } //set fasta file as new current fastafile diff --git a/deuniqueseqscommand.cpp b/deuniqueseqscommand.cpp index 2ba6f3d..7481416 100644 --- a/deuniqueseqscommand.cpp +++ b/deuniqueseqscommand.cpp @@ -155,14 +155,14 @@ int DeUniqueSeqsCommand::execute() { m->openOutputFile(outFastaFile, out); readNamesFile(); - if (m->control_pressed) { out.close(); outputTypes.clear(); remove(outFastaFile.c_str()); return 0; } + if (m->control_pressed) { out.close(); outputTypes.clear(); m->mothurRemove(outFastaFile); return 0; } ifstream in; m->openInputFile(fastaFile, in); while (!in.eof()) { - if (m->control_pressed) { in.close(); out.close(); outputTypes.clear(); remove(outFastaFile.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); outputTypes.clear(); m->mothurRemove(outFastaFile); return 0; } Sequence seq(in); m->gobble(in); @@ -196,7 +196,7 @@ int DeUniqueSeqsCommand::execute() { } } - if (m->control_pressed) { outputTypes.clear(); remove(outFastaFile.c_str()); return 0; } + if (m->control_pressed) { outputTypes.clear(); m->mothurRemove(outFastaFile); return 0; } m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); diff --git a/deuniquetreecommand.cpp b/deuniquetreecommand.cpp index f39a182..dca81e5 100644 --- a/deuniquetreecommand.cpp +++ b/deuniquetreecommand.cpp @@ -181,7 +181,7 @@ int DeuniqueTreeCommand::execute() { if (m->control_pressed) { delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; } - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); m->Groups.clear(); return 0; } diff --git a/distancecommand.cpp b/distancecommand.cpp index 4bdeaae..b69b93d 100644 --- a/distancecommand.cpp +++ b/distancecommand.cpp @@ -255,7 +255,7 @@ int DistanceCommand::execute(){ if (output == "lt") { //does the user want lower triangle phylip formatted file outputFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "phylip.dist"; - remove(outputFile.c_str()); outputTypes["phylip"].push_back(outputFile); + m->mothurRemove(outputFile); outputTypes["phylip"].push_back(outputFile); //output numSeqs to phylip formatted dist file }else if (output == "column") { //user wants column format @@ -268,10 +268,10 @@ int DistanceCommand::execute(){ rename(column.c_str(), tempcolumn.c_str()); } - remove(outputFile.c_str()); + m->mothurRemove(outputFile); }else { //assume square outputFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "square.dist"; - remove(outputFile.c_str()); + m->mothurRemove(outputFile); outputTypes["phylip"].push_back(outputFile); } @@ -449,7 +449,7 @@ int DistanceCommand::execute(){ #endif #endif - if (m->control_pressed) { outputTypes.clear(); delete distCalculator; remove(outputFile.c_str()); return 0; } + if (m->control_pressed) { outputTypes.clear(); delete distCalculator; m->mothurRemove(outputFile); return 0; } #ifdef USE_MPI MPI_Comm_rank(MPI_COMM_WORLD, &pid); @@ -472,17 +472,17 @@ int DistanceCommand::execute(){ if (outputFile == column) { string tempcolumn = column + ".old"; m->appendFiles(tempcolumn, outputFile); - remove(tempcolumn.c_str()); + m->mothurRemove(tempcolumn); }else{ m->appendFiles(outputFile, column); - remove(outputFile.c_str()); + m->mothurRemove(outputFile); outputFile = column; } if (outputDir != "") { string newOutputName = outputDir + m->getSimpleName(outputFile); rename(outputFile.c_str(), newOutputName.c_str()); - remove(outputFile.c_str()); + m->mothurRemove(outputFile); outputFile = newOutputName; } } @@ -492,7 +492,7 @@ int DistanceCommand::execute(){ } #endif - if (m->control_pressed) { outputTypes.clear(); delete distCalculator; remove(outputFile.c_str()); return 0; } + if (m->control_pressed) { outputTypes.clear(); delete distCalculator; m->mothurRemove(outputFile); return 0; } delete distCalculator; @@ -571,7 +571,7 @@ void DistanceCommand::createProcesses(string filename) { //append and remove temp files for (int i=0;iappendFiles((filename + toString(processIDS[i]) + ".temp"), filename); - remove((filename + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((filename + toString(processIDS[i]) + ".temp")); } #endif } @@ -935,7 +935,7 @@ int DistanceCommand::convertMatrix(string outputFile) { //m->openInputFile(outfile, in); while(!in.eof()) { - if (m->control_pressed) { in.close(); remove(outfile.c_str()); out.close(); return 0; } + if (m->control_pressed) { in.close(); m->mothurRemove(outfile); out.close(); return 0; } in >> first >> second >> dist; m->gobble(in); @@ -970,7 +970,7 @@ int DistanceCommand::convertMatrix(string outputFile) { in.close(); out.close(); - remove(outfile.c_str()); + m->mothurRemove(outfile); return 1; @@ -1025,7 +1025,7 @@ int DistanceCommand::convertToLowerTriangle(string outputFile) { //m->openInputFile(outfile, in); while(!in.eof()) { - if (m->control_pressed) { in.close(); remove(outfile.c_str()); out.close(); return 0; } + if (m->control_pressed) { in.close(); m->mothurRemove(outfile); out.close(); return 0; } in >> first >> second >> dist; m->gobble(in); @@ -1064,7 +1064,7 @@ int DistanceCommand::convertToLowerTriangle(string outputFile) { in.close(); out.close(); - remove(outfile.c_str()); + m->mothurRemove(outfile); return 1; @@ -1135,7 +1135,7 @@ bool DistanceCommand::sanityCheck() { string name1, name2; float dist; while (!inDist.eof()) { - if (m->control_pressed) { inDist.close(); outDist.close(); remove(outputFile.c_str()); return good; } + if (m->control_pressed) { inDist.close(); outDist.close(); m->mothurRemove(outputFile); return good; } inDist >> name1 >> name2 >> dist; m->gobble(inDist); @@ -1152,10 +1152,10 @@ bool DistanceCommand::sanityCheck() { outDist.close(); if (good) { - remove(column.c_str()); + m->mothurRemove(column); rename(outputFile.c_str(), column.c_str()); }else{ - remove(outputFile.c_str()); //temp file is bad because file mismatch above + m->mothurRemove(outputFile); //temp file is bad because file mismatch above } return good; diff --git a/fileoutput.cpp b/fileoutput.cpp index c2432ac..a4a68a8 100644 --- a/fileoutput.cpp +++ b/fileoutput.cpp @@ -15,7 +15,7 @@ ThreeColumnFile::~ThreeColumnFile(){ inFile.close(); outFile.close(); - remove(outName.c_str()); + m->mothurRemove(outName); } /***********************************************************************/ @@ -78,7 +78,7 @@ void ThreeColumnFile::resetFile(){ } counter = 1; - remove(inName.c_str()); + m->mothurRemove(inName); renameOk = rename(outName.c_str(), inName.c_str()); //renameFile(outName, inName); @@ -102,7 +102,7 @@ ColumnFile::~ColumnFile(){ inFile.close(); outFile.close(); - remove(outName.c_str()); + m->mothurRemove(outName); } /***********************************************************************/ @@ -182,7 +182,7 @@ void ColumnFile::resetFile(){ } counter = 1; - remove(inName.c_str()); + m->mothurRemove(inName); renameOk = rename(outName.c_str(), inName.c_str()); //renameFile(outName, inName); @@ -206,7 +206,7 @@ SharedThreeColumnFile::~SharedThreeColumnFile(){ inFile.close(); outFile.close(); - remove(outName.c_str()); + m->mothurRemove(outName); } /***********************************************************************/ @@ -270,7 +270,7 @@ void SharedThreeColumnFile::resetFile(){ } counter = 1; - remove(inName.c_str()); + m->mothurRemove(inName); renameOk = rename(outName.c_str(), inName.c_str()); //renameFile(outName, inName); @@ -295,7 +295,7 @@ OneColumnFile::~OneColumnFile(){ inFile.close(); outFile.close(); - remove(outName.c_str()); + m->mothurRemove(outName); } /***********************************************************************/ @@ -357,7 +357,7 @@ void OneColumnFile::resetFile(){ } counter = 1; - remove(inName.c_str()); + m->mothurRemove(inName); renameOk = rename(outName.c_str(), inName.c_str()); //renameFile(outName, inName); @@ -382,7 +382,7 @@ SharedOneColumnFile::~SharedOneColumnFile(){ inFile.close(); outFile.close(); - remove(outName.c_str()); + m->mothurRemove(outName); } /***********************************************************************/ @@ -454,7 +454,7 @@ void SharedOneColumnFile::resetFile(){ } counter = 1; - remove(inName.c_str()); + m->mothurRemove(inName); renameOk = rename(outName.c_str(), inName.c_str()); //renameFile(outName, inName); diff --git a/filterseqscommand.cpp b/filterseqscommand.cpp index 1204663..173227f 100644 --- a/filterseqscommand.cpp +++ b/filterseqscommand.cpp @@ -298,7 +298,7 @@ int FilterSeqsCommand::execute() { if(filter[i] == '1'){ filteredLength++; } } - if (m->control_pressed) { outputTypes.clear(); for(int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { outputTypes.clear(); for(int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } m->mothurOutEndLine(); @@ -438,7 +438,7 @@ int FilterSeqsCommand::filterSequences() { //append fasta files for(int i=1;iappendFiles((fastafileNames[s] + toString(processIDS[i]) + ".temp"), filteredFasta); - remove((fastafileNames[s] + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((fastafileNames[s] + toString(processIDS[i]) + ".temp")); } } @@ -637,7 +637,7 @@ int FilterSeqsCommand::createProcessesRunFilter(string F, string filename) { string tempFile = filename + toString(processIDS[i]) + ".num.temp"; m->openInputFile(tempFile, in); if (!in.eof()) { int tempNum = 0; in >> tempNum; num += tempNum; } - in.close(); remove(tempFile.c_str()); + in.close(); m->mothurRemove(tempFile); } @@ -1024,7 +1024,7 @@ int FilterSeqsCommand::createProcessesCreateFilter(Filters& F, string filename) for (int k = 0; k < alignmentLength; k++) { in >> temp; F.gap[k] += temp; } m->gobble(in); in.close(); - remove(tempFilename.c_str()); + m->mothurRemove(tempFilename); } return num; diff --git a/fisher2.c b/fisher2.c index 35f0b4d..c861834 100644 --- a/fisher2.c +++ b/fisher2.c @@ -41,8 +41,6 @@ static int iwork(int iwkmax, int *iwkpt, int number, int itype); static double alogam(double *x, int *ifault); - - /* The only public function : */ void fexact(int *nrow, int *ncol, double *table, int *ldtabl, double *expect, double *percnt, double *emin, double *prt, @@ -319,7 +317,7 @@ f2xact(int *nrow, int *ncol, double *table, int *ldtabl, /* AMISS is a missing value indicator which is returned when the probability is not defined. */ const double amiss = -12345.; - + /* TOL is chosen as the square root of the smallest relative spacing. */ #ifndef Macintosh const static double tol = 3.45254e-7; @@ -2117,7 +2115,7 @@ L10: double alogam(double *x, int *ifault) { /* Initialized data */ - + //printf("alogam x = %f\t%d\n",*x,*ifault); static double a1 = .918938533204673; static double a2 = 5.95238095238e-4; static double a3 = 7.93650793651e-4; @@ -2149,6 +2147,8 @@ L20: f = -log(f); L30: z = 1. / (y * y); + + //printf("returning %f\n",(f + (y - .5) * log(y) - y + a1 + (((-a2 * z + a3) * z - a4) * z + a5) / y)); return(f + (y - .5) * log(y) - y + a1 + (((-a2 * z + a3) * z - a4) * z + a5) / y); } diff --git a/formatcolumn.cpp b/formatcolumn.cpp index 4ce73b3..d43f85d 100644 --- a/formatcolumn.cpp +++ b/formatcolumn.cpp @@ -39,7 +39,7 @@ int FormatColumnMatrix::read(NameAssignment* nameMap){ while(fileHandle && lt == 1){ //let's assume it's a triangular matrix... - if (m->control_pressed) { out.close(); remove(tempOutFile.c_str()); fileHandle.close(); delete reading; return 0; } + if (m->control_pressed) { out.close(); m->mothurRemove(tempOutFile); fileHandle.close(); delete reading; return 0; } fileHandle >> firstName >> secondName >> distance; // get the row and column names and distance @@ -90,7 +90,7 @@ int FormatColumnMatrix::read(NameAssignment* nameMap){ system(command.c_str()); #endif - if (m->control_pressed) { remove(tempOutFile.c_str()); remove(outfile.c_str()); delete reading; return 0; } + if (m->control_pressed) { m->mothurRemove(tempOutFile); m->mothurRemove(outfile); delete reading; return 0; } //output to new file distance for each row and save positions in file where new row begins ifstream in; @@ -115,7 +115,7 @@ int FormatColumnMatrix::read(NameAssignment* nameMap){ while(!in.eof()) { - if (m->control_pressed) { in.close(); out.close(); remove(distFile.c_str()); remove(tempOutFile.c_str()); remove(outfile.c_str()); delete reading; return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(distFile); m->mothurRemove(tempOutFile); m->mothurRemove(outfile); delete reading; return 0; } in >> first >> second >> dist; m->gobble(in); @@ -159,17 +159,17 @@ int FormatColumnMatrix::read(NameAssignment* nameMap){ in.close(); out.close(); - if (m->control_pressed) { remove(distFile.c_str()); remove(tempOutFile.c_str()); remove(outfile.c_str()); delete reading; return 0; } + if (m->control_pressed) { m->mothurRemove(distFile); m->mothurRemove(tempOutFile); m->mothurRemove(outfile); delete reading; return 0; } - remove(tempOutFile.c_str()); - remove(outfile.c_str()); + m->mothurRemove(tempOutFile); + m->mothurRemove(outfile); reading->finish(); delete reading; list->setLabel("0"); - if (m->control_pressed) { remove(distFile.c_str()); return 0; } + if (m->control_pressed) { m->mothurRemove(distFile); return 0; } return 1; diff --git a/formatphylip.cpp b/formatphylip.cpp index 0390a80..de49daa 100644 --- a/formatphylip.cpp +++ b/formatphylip.cpp @@ -75,7 +75,7 @@ int FormatPhylipMatrix::read(NameAssignment* nameMap){ for(int j=0;jcontrol_pressed) { outTemp.close(); remove(tempFile.c_str()); fileHandle.close(); delete reading; return 0; } + if (m->control_pressed) { outTemp.close(); m->mothurRemove(tempFile); fileHandle.close(); delete reading; return 0; } fileHandle >> distance; @@ -104,7 +104,7 @@ int FormatPhylipMatrix::read(NameAssignment* nameMap){ system(command.c_str()); #endif - if (m->control_pressed) { remove(tempFile.c_str()); remove(outfile.c_str()); delete reading; return 0; } + if (m->control_pressed) { m->mothurRemove(tempFile); m->mothurRemove(outfile); delete reading; return 0; } //output to new file distance for each row and save positions in file where new row begins ifstream in; @@ -128,7 +128,7 @@ int FormatPhylipMatrix::read(NameAssignment* nameMap){ for(int k = 0; k < firstString.length(); k++) { in.putback(firstString[k]); } while(!in.eof()) { - if (m->control_pressed) { in.close(); out.close(); remove(tempFile.c_str()); remove(distFile.c_str()); remove(outfile.c_str()); delete reading; return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(tempFile); m->mothurRemove(distFile); m->mothurRemove(outfile); delete reading; return 0; } in >> first >> second >> dist; m->gobble(in); @@ -170,10 +170,10 @@ int FormatPhylipMatrix::read(NameAssignment* nameMap){ in.close(); out.close(); - remove(tempFile.c_str()); - remove(outfile.c_str()); + m->mothurRemove(tempFile); + m->mothurRemove(outfile); - if (m->control_pressed) { remove(distFile.c_str()); delete reading; return 0; } + if (m->control_pressed) { m->mothurRemove(distFile); delete reading; return 0; } } else{ //square matrix convert directly to formatted row file @@ -188,7 +188,7 @@ int FormatPhylipMatrix::read(NameAssignment* nameMap){ list->set(i, name); for(int j=0;jcontrol_pressed) { fileHandle.close(); out.close(); remove(distFile.c_str()); delete reading; return 0; } + if (m->control_pressed) { fileHandle.close(); out.close(); m->mothurRemove(distFile); delete reading; return 0; } fileHandle >> distance; @@ -222,7 +222,7 @@ int FormatPhylipMatrix::read(NameAssignment* nameMap){ fileHandle.close(); out.close(); - if (m->control_pressed) { remove(distFile.c_str()); return 0; } + if (m->control_pressed) { m->mothurRemove(distFile); return 0; } list->setLabel("0"); diff --git a/getcommandinfocommand.cpp b/getcommandinfocommand.cpp index ad706ef..03c6b17 100644 --- a/getcommandinfocommand.cpp +++ b/getcommandinfocommand.cpp @@ -92,7 +92,7 @@ int GetCommandInfoCommand::execute(){ //loop through each command outputting info for (it = commands.begin(); it != commands.end(); it++) { - if (m->control_pressed) { m->mothurOut("[ERROR]: did not complete making the file."); m->mothurOutEndLine(); out.close(); remove((output+".temp").c_str()); } + if (m->control_pressed) { m->mothurOut("[ERROR]: did not complete making the file."); m->mothurOutEndLine(); out.close(); m->mothurRemove((output+".temp")); } Command* thisCommand = commandFactory->getCommand(it->first); @@ -186,7 +186,7 @@ int GetCommandInfoCommand::execute(){ out2.close(); m->appendFiles(output+".temp", output); - remove((output+".temp").c_str()); + m->mothurRemove((output+".temp")); m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); diff --git a/getgroupcommand.cpp b/getgroupcommand.cpp index 1190f49..194e8e1 100644 --- a/getgroupcommand.cpp +++ b/getgroupcommand.cpp @@ -146,13 +146,13 @@ int GetgroupCommand::execute(){ in >> inputData; } - if (m->control_pressed) { outputTypes.clear(); in.close(); out.close(); remove(outputFile.c_str()); return 0; } + if (m->control_pressed) { outputTypes.clear(); in.close(); out.close(); m->mothurRemove(outputFile); return 0; } if (in.eof() != true) { in >> nextLabel; } //read the rest of the groups info in while ((nextLabel == holdLabel) && (in.eof() != true)) { - if (m->control_pressed) { outputTypes.clear(); in.close(); out.close(); remove(outputFile.c_str()); return 0; } + if (m->control_pressed) { outputTypes.clear(); in.close(); out.close(); m->mothurRemove(outputFile); return 0; } in >> groupN >> num; count++; @@ -172,7 +172,7 @@ int GetgroupCommand::execute(){ in.close(); out.close(); - if (m->control_pressed) { remove(outputFile.c_str()); return 0; } + if (m->control_pressed) { m->mothurRemove(outputFile); return 0; } m->mothurOutEndLine(); m->mothurOut("Output File Name: "); m->mothurOutEndLine(); diff --git a/getgroupscommand.cpp b/getgroupscommand.cpp index 1ba8aa7..0065ec1 100644 --- a/getgroupscommand.cpp +++ b/getgroupscommand.cpp @@ -243,7 +243,7 @@ int GetGroupsCommand::execute(){ if (listfile != "") { readList(); } if (taxfile != "") { readTax(); } - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } m->mothurOut("Selected " + toString(names.size()) + " sequences. From the groups: "); m->mothurOutEndLine(); for (int i = 0; i < Groups.size(); i++) { m->mothurOut(Groups[i]); m->mothurOut("\t" + toString(groupMap->getNumSeqs(Groups[i]))); m->mothurOutEndLine(); } @@ -309,7 +309,7 @@ int GetGroupsCommand::readFasta(){ bool wroteSomething = false; while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } Sequence currSeq(in); name = currSeq.getName(); @@ -364,7 +364,7 @@ int GetGroupsCommand::readList(){ //for each bin for (int i = 0; i < list.getNumBins(); i++) { - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } //parse out names that are in accnos file string binnames = list.get(i); @@ -427,7 +427,7 @@ int GetGroupsCommand::readName(){ bool wroteSomething = false; while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } in >> firstCol; m->gobble(in); in >> secondCol; @@ -502,7 +502,7 @@ int GetGroupsCommand::readGroup(){ bool wroteSomething = false; while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } in >> name; //read from first column in >> group; //read from second column @@ -544,7 +544,7 @@ int GetGroupsCommand::readTax(){ bool wroteSomething = false; while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } in >> name; //read from first column in >> tax; //read from second column diff --git a/getlineagecommand.cpp b/getlineagecommand.cpp index 0d83613..195c822 100644 --- a/getlineagecommand.cpp +++ b/getlineagecommand.cpp @@ -243,7 +243,7 @@ int GetLineageCommand::execute(){ if (listfile != "") { readList(); } - if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } if (outputNames.size() != 0) { m->mothurOutEndLine(); @@ -306,7 +306,7 @@ int GetLineageCommand::readFasta(){ while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } Sequence currSeq(in); name = currSeq.getName(); @@ -351,7 +351,7 @@ int GetLineageCommand::readList(){ while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } //read in list vector ListVector list(in); @@ -426,7 +426,7 @@ int GetLineageCommand::readName(){ while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } in >> firstCol; in >> secondCol; @@ -511,7 +511,7 @@ int GetLineageCommand::readGroup(){ while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } in >> name; //read from first column @@ -571,7 +571,7 @@ int GetLineageCommand::readTax(){ while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } in >> name; //read from first column in >> tax; //read from second column @@ -774,7 +774,7 @@ int GetLineageCommand::readAlign(){ while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } in >> name; //read from first column diff --git a/getlistcountcommand.cpp b/getlistcountcommand.cpp index 57afd85..980c886 100644 --- a/getlistcountcommand.cpp +++ b/getlistcountcommand.cpp @@ -149,7 +149,7 @@ int GetListCountCommand::execute(){ set processedLabels; set userLabels = labels; - if (m->control_pressed) { delete input; delete list; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { delete input; delete list; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } while((list != NULL) && ((allLines == 1) || (userLabels.size() != 0))) { @@ -157,7 +157,7 @@ int GetListCountCommand::execute(){ process(list); - if (m->control_pressed) { delete input; delete list; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { delete input; delete list; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } processedLabels.insert(list->getLabel()); userLabels.erase(list->getLabel()); @@ -171,7 +171,7 @@ int GetListCountCommand::execute(){ process(list); - if (m->control_pressed) { delete input; delete list; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { delete input; delete list; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } processedLabels.insert(list->getLabel()); @@ -208,7 +208,7 @@ int GetListCountCommand::execute(){ process(list); - if (m->control_pressed) { delete input; delete list; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { delete input; delete list; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } delete list; } diff --git a/getoturepcommand.cpp b/getoturepcommand.cpp index 3e31691..9ed887a 100644 --- a/getoturepcommand.cpp +++ b/getoturepcommand.cpp @@ -394,7 +394,7 @@ int GetOTURepCommand::execute(){ //openfile for getMap to use m->openInputFile(distFile, inRow); - if (m->control_pressed) { inRow.close(); remove(distFile.c_str()); return 0; } + if (m->control_pressed) { inRow.close(); m->mothurRemove(distFile); return 0; } } @@ -417,7 +417,7 @@ int GetOTURepCommand::execute(){ if (m->control_pressed) { - if (large) { inRow.close(); remove(distFile.c_str()); } + if (large) { inRow.close(); m->mothurRemove(distFile); } return 0; } @@ -446,7 +446,7 @@ int GetOTURepCommand::execute(){ set userLabels = labels; if (m->control_pressed) { - if (large) { inRow.close(); remove(distFile.c_str()); } + if (large) { inRow.close(); m->mothurRemove(distFile); } delete input; delete list; return 0; } @@ -460,8 +460,8 @@ int GetOTURepCommand::execute(){ if (error == 1) { return 0; } //there is an error in hte input files, abort command if (m->control_pressed) { - if (large) { inRow.close(); remove(distFile.c_str()); } - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + if (large) { inRow.close(); m->mothurRemove(distFile); } + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); delete input; delete list; return 0; } @@ -479,8 +479,8 @@ int GetOTURepCommand::execute(){ if (error == 1) { return 0; } //there is an error in hte input files, abort command if (m->control_pressed) { - if (large) { inRow.close(); remove(distFile.c_str()); } - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + if (large) { inRow.close(); m->mothurRemove(distFile); } + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); delete input; delete list; return 0; } @@ -519,8 +519,8 @@ int GetOTURepCommand::execute(){ if (error == 1) { return 0; } //there is an error in hte input files, abort command if (m->control_pressed) { - if (large) { inRow.close(); remove(distFile.c_str()); } - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + if (large) { inRow.close(); m->mothurRemove(distFile); } + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); delete input; delete list; return 0; } } @@ -528,7 +528,7 @@ int GetOTURepCommand::execute(){ //close and remove formatted matrix file if (large) { inRow.close(); - remove(distFile.c_str()); + m->mothurRemove(distFile); } delete input; @@ -954,7 +954,7 @@ int GetOTURepCommand::processNames(string filename, string label) { out.close(); out2.close(); - remove(filename.c_str()); + m->mothurRemove(filename); rename(tempNameFile.c_str(), filename.c_str()); return 0; diff --git a/getotuscommand.cpp b/getotuscommand.cpp index d29773c..b94b42a 100644 --- a/getotuscommand.cpp +++ b/getotuscommand.cpp @@ -195,7 +195,7 @@ int GetOtusCommand::execute(){ //read through the list file keeping any otus that contain any sequence from the groups selected readListGroup(); - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } if (outputNames.size() != 0) { m->mothurOutEndLine(); @@ -258,7 +258,7 @@ int GetOtusCommand::readListGroup(){ //as long as you are not at the end of the file or done wih the lines you want while((list != NULL) && (userLabels.size() != 0)) { - if (m->control_pressed) { delete list; delete input; out.close(); outGroup.close(); remove(outputFileName.c_str()); remove(outputGroupFileName.c_str());return 0; } + if (m->control_pressed) { delete list; delete input; out.close(); outGroup.close(); m->mothurRemove(outputFileName); m->mothurRemove(outputGroupFileName);return 0; } if(labels.count(list->getLabel()) == 1){ processList(list, groupMap, out, outGroup, wroteSomething); @@ -292,7 +292,7 @@ int GetOtusCommand::readListGroup(){ } - if (m->control_pressed) { if (list != NULL) { delete list; } delete input; out.close(); outGroup.close(); remove(outputFileName.c_str()); remove(outputGroupFileName.c_str()); return 0; } + if (m->control_pressed) { if (list != NULL) { delete list; } delete input; out.close(); outGroup.close(); m->mothurRemove(outputFileName); m->mothurRemove(outputGroupFileName); return 0; } //output error messages about any remaining user labels set::iterator it; diff --git a/getrabundcommand.cpp b/getrabundcommand.cpp index 9c89f7f..5a33253 100644 --- a/getrabundcommand.cpp +++ b/getrabundcommand.cpp @@ -184,14 +184,14 @@ int GetRAbundCommand::execute(){ set processedLabels; set userLabels = labels; - if (m->control_pressed) { outputTypes.clear(); out.close(); remove(filename.c_str()); delete rabund; delete input; return 0; } + if (m->control_pressed) { outputTypes.clear(); out.close(); m->mothurRemove(filename); delete rabund; delete input; return 0; } while((rabund != NULL) && ((allLines == 1) || (userLabels.size() != 0))) { if(allLines == 1 || labels.count(rabund->getLabel()) == 1){ m->mothurOut(rabund->getLabel()); m->mothurOutEndLine(); - if (m->control_pressed) { outputTypes.clear(); out.close(); remove(filename.c_str()); delete input; delete rabund; return 0; } + if (m->control_pressed) { outputTypes.clear(); out.close(); m->mothurRemove(filename); delete input; delete rabund; return 0; } if(sorted) { rabund->print(out); } else { rabund->nonSortedPrint(out); } @@ -208,7 +208,7 @@ int GetRAbundCommand::execute(){ m->mothurOut(rabund->getLabel()); m->mothurOutEndLine(); - if (m->control_pressed) { outputTypes.clear(); out.close(); remove(filename.c_str()); delete input; delete rabund; return 0; } + if (m->control_pressed) { outputTypes.clear(); out.close(); m->mothurRemove(filename); delete input; delete rabund; return 0; } if(sorted) { rabund->print(out); } else { rabund->nonSortedPrint(out); } @@ -246,7 +246,7 @@ int GetRAbundCommand::execute(){ m->mothurOut(rabund->getLabel()); m->mothurOutEndLine(); - if (m->control_pressed) { outputTypes.clear(); out.close(); remove(filename.c_str()); delete input; delete rabund; return 0; } + if (m->control_pressed) { outputTypes.clear(); out.close(); m->mothurRemove(filename); delete input; delete rabund; return 0; } if(sorted) { rabund->print(out); } else { rabund->nonSortedPrint(out); } diff --git a/getrelabundcommand.cpp b/getrelabundcommand.cpp index 693e36d..26d7958 100644 --- a/getrelabundcommand.cpp +++ b/getrelabundcommand.cpp @@ -170,7 +170,7 @@ int GetRelAbundCommand::execute(){ //as long as you are not at the end of the file or done wih the lines you want while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) { - if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } m->Groups.clear(); delete input; out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } m->Groups.clear(); delete input; out.close(); m->mothurRemove(outputFileName); return 0; } if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){ @@ -202,13 +202,13 @@ int GetRelAbundCommand::execute(){ //prevent memory leak for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; lookup[i] = NULL; } - if (m->control_pressed) { outputTypes.clear(); m->Groups.clear(); delete input; out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { outputTypes.clear(); m->Groups.clear(); delete input; out.close(); m->mothurRemove(outputFileName); return 0; } //get next line to process lookup = input->getSharedRAbundVectors(); } - if (m->control_pressed) { outputTypes.clear(); m->Groups.clear(); delete input; out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { outputTypes.clear(); m->Groups.clear(); delete input; out.close(); m->mothurRemove(outputFileName); return 0; } //output error messages about any remaining user labels set::iterator it; @@ -240,7 +240,7 @@ int GetRelAbundCommand::execute(){ delete input; out.close(); - if (m->control_pressed) { outputTypes.clear(); remove(outputFileName.c_str()); return 0;} + if (m->control_pressed) { outputTypes.clear(); m->mothurRemove(outputFileName); return 0;} m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); diff --git a/getsabundcommand.cpp b/getsabundcommand.cpp index 799d8dc..4ae2eaa 100644 --- a/getsabundcommand.cpp +++ b/getsabundcommand.cpp @@ -178,7 +178,7 @@ int GetSAbundCommand::execute(){ set processedLabels; set userLabels = labels; - if (m->control_pressed) { outputTypes.clear(); out.close(); remove(filename.c_str()); delete sabund; delete input; return 0; } + if (m->control_pressed) { outputTypes.clear(); out.close(); m->mothurRemove(filename); delete sabund; delete input; return 0; } while((sabund != NULL) && ((allLines == 1) || (userLabels.size() != 0))) { @@ -188,7 +188,7 @@ int GetSAbundCommand::execute(){ sabund->print(out); - if (m->control_pressed) { outputTypes.clear(); out.close(); remove(filename.c_str()); delete sabund; delete input; return 0; } + if (m->control_pressed) { outputTypes.clear(); out.close(); m->mothurRemove(filename); delete sabund; delete input; return 0; } processedLabels.insert(sabund->getLabel()); userLabels.erase(sabund->getLabel()); @@ -203,7 +203,7 @@ int GetSAbundCommand::execute(){ m->mothurOut(sabund->getLabel()); m->mothurOutEndLine(); sabund->print(out); - if (m->control_pressed) { outputTypes.clear(); out.close(); remove(filename.c_str()); delete sabund; delete input; return 0; } + if (m->control_pressed) { outputTypes.clear(); out.close(); m->mothurRemove(filename); delete sabund; delete input; return 0; } processedLabels.insert(sabund->getLabel()); userLabels.erase(sabund->getLabel()); @@ -241,7 +241,7 @@ int GetSAbundCommand::execute(){ sabund->print(out); delete sabund; - if (m->control_pressed) { outputTypes.clear(); out.close(); remove(filename.c_str()); delete input; return 0; } + if (m->control_pressed) { outputTypes.clear(); out.close(); m->mothurRemove(filename); delete input; return 0; } } diff --git a/getseqscommand.cpp b/getseqscommand.cpp index 71a2db9..5eba5cc 100644 --- a/getseqscommand.cpp +++ b/getseqscommand.cpp @@ -279,9 +279,8 @@ int GetSeqsCommand::execute(){ if (qualfile != "") { readQual(); } if (accnosfile2 != "") { compareAccnos(); } - if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } - m->mothurOut("Selected " + toString(names.size()) + " sequences."); m->mothurOutEndLine(); if (outputNames.size() != 0) { m->mothurOutEndLine(); @@ -347,10 +346,11 @@ int GetSeqsCommand::readFasta(){ string name; bool wroteSomething = false; + int selectedCount = 0; while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } Sequence currSeq(in); name = currSeq.getName(); @@ -361,6 +361,7 @@ int GetSeqsCommand::readFasta(){ wroteSomething = true; currSeq.printSequence(out); + selectedCount++; } } m->gobble(in); @@ -372,6 +373,8 @@ int GetSeqsCommand::readFasta(){ if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine(); } outputNames.push_back(outputFileName); outputTypes["fasta"].push_back(outputFileName); + m->mothurOut("Selected " + toString(selectedCount) + " sequences from your fasta file."); m->mothurOutEndLine(); + return 0; } @@ -395,6 +398,7 @@ int GetSeqsCommand::readQual(){ string name; bool wroteSomething = false; + int selectedCount = 0; while(!in.eof()){ @@ -426,6 +430,7 @@ int GetSeqsCommand::readQual(){ wroteSomething = true; out << name << endl << scores; + selectedCount++; } m->gobble(in); @@ -437,6 +442,9 @@ int GetSeqsCommand::readQual(){ if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine(); } outputNames.push_back(outputFileName); outputTypes["qfile"].push_back(outputFileName); + m->mothurOut("Selected " + toString(selectedCount) + " sequences from your quality file."); m->mothurOutEndLine(); + + return 0; } @@ -458,10 +466,11 @@ int GetSeqsCommand::readList(){ m->openInputFile(listfile, in); bool wroteSomething = false; + int selectedCount = 0; while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } //read in list vector ListVector list(in); @@ -482,11 +491,11 @@ int GetSeqsCommand::readList(){ binnames = binnames.substr(binnames.find_first_of(',')+1, binnames.length()); //if that name is in the .accnos file, add it - if (names.count(name) != 0) { newNames += name + ","; } + if (names.count(name) != 0) { newNames += name + ","; selectedCount++; } } //get last name - if (names.count(binnames) != 0) { newNames += binnames + ","; } + if (names.count(binnames) != 0) { newNames += binnames + ","; selectedCount++; } //if there are names in this bin add to new list if (newNames != "") { @@ -509,6 +518,8 @@ int GetSeqsCommand::readList(){ if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine(); } outputNames.push_back(outputFileName); outputTypes["list"].push_back(outputFileName); + m->mothurOut("Selected " + toString(selectedCount) + " sequences from your list file."); m->mothurOutEndLine(); + return 0; } @@ -532,11 +543,11 @@ int GetSeqsCommand::readName(){ string name, firstCol, secondCol; bool wroteSomething = false; - + int selectedCount = 0; while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } in >> firstCol; in >> secondCol; @@ -558,7 +569,10 @@ int GetSeqsCommand::readName(){ for (int i = 0; i < parsedNames.size(); i++) { names.insert(parsedNames[i]); } out << firstCol << '\t' << hold << endl; wroteSomething = true; + selectedCount += parsedNames.size(); }else { + selectedCount += validSecond.size(); + //if the name in the first column is in the set then print it and any other names in second column also in set if (names.count(firstCol) != 0) { @@ -594,6 +608,8 @@ int GetSeqsCommand::readName(){ if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine(); } outputNames.push_back(outputFileName); outputTypes["name"].push_back(outputFileName); + m->mothurOut("Selected " + toString(selectedCount) + " sequences from your name file."); m->mothurOutEndLine(); + return 0; } @@ -618,10 +634,11 @@ int GetSeqsCommand::readGroup(){ string name, group; bool wroteSomething = false; + int selectedCount = 0; while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } in >> name; //read from first column @@ -632,6 +649,7 @@ int GetSeqsCommand::readGroup(){ wroteSomething = true; out << name << '\t' << group << endl; + selectedCount++; } m->gobble(in); @@ -642,6 +660,9 @@ int GetSeqsCommand::readGroup(){ if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine(); } outputNames.push_back(outputFileName); outputTypes["group"].push_back(outputFileName); + m->mothurOut("Selected " + toString(selectedCount) + " sequences from your group file."); m->mothurOutEndLine(); + + return 0; } @@ -664,10 +685,11 @@ int GetSeqsCommand::readTax(){ string name, tax; bool wroteSomething = false; + int selectedCount = 0; while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } in >> name; //read from first column in >> tax; //read from second column @@ -677,6 +699,7 @@ int GetSeqsCommand::readTax(){ wroteSomething = true; out << name << '\t' << tax << endl; + selectedCount++; } m->gobble(in); @@ -686,6 +709,8 @@ int GetSeqsCommand::readTax(){ if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine(); } outputNames.push_back(outputFileName); outputTypes["taxonomy"].push_back(outputFileName); + + m->mothurOut("Selected " + toString(selectedCount) + " sequences from your taxonomy file."); m->mothurOutEndLine(); return 0; @@ -711,6 +736,7 @@ int GetSeqsCommand::readAlign(){ string name, junk; bool wroteSomething = false; + int selectedCount = 0; //read column headers for (int i = 0; i < 16; i++) { @@ -721,7 +747,7 @@ int GetSeqsCommand::readAlign(){ while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } in >> name; //read from first column @@ -729,6 +755,7 @@ int GetSeqsCommand::readAlign(){ //if this name is in the accnos file if (names.count(name) != 0) { wroteSomething = true; + selectedCount++; out << name << '\t'; @@ -755,6 +782,8 @@ int GetSeqsCommand::readAlign(){ if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine(); } outputNames.push_back(outputFileName); outputTypes["alignreport"].push_back(outputFileName); + m->mothurOut("Selected " + toString(selectedCount) + " sequences from your alignreport file."); m->mothurOutEndLine(); + return 0; } diff --git a/getsharedotucommand.cpp b/getsharedotucommand.cpp index 046460d..0246136 100644 --- a/getsharedotucommand.cpp +++ b/getsharedotucommand.cpp @@ -266,7 +266,7 @@ int GetSharedOTUCommand::execute(){ if (m->control_pressed) { if (lastlist != NULL) { delete lastlist; } - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); delete groupMap; return 0; } @@ -329,7 +329,7 @@ int GetSharedOTUCommand::execute(){ if (lastlist != NULL) { delete lastlist; } - if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } delete groupMap; return 0; } + if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } delete groupMap; return 0; } //set fasta file as new current fastafile string current = ""; @@ -381,7 +381,7 @@ int GetSharedOTUCommand::process(ListVector* shared) { //go through each bin, find out if shared for (int i = 0; i < shared->getNumBins(); i++) { - if (m->control_pressed) { outNames.close(); remove(outputFileNames.c_str()); return 0; } + if (m->control_pressed) { outNames.close(); m->mothurRemove(outputFileNames); return 0; } bool uniqueOTU = true; @@ -459,7 +459,7 @@ int GetSharedOTUCommand::process(ListVector* shared) { outNames.close(); if (!wroteSomething) { - remove(outputFileNames.c_str()); + m->mothurRemove(outputFileNames); string outputString = "\t" + toString(num) + " - No otus shared by groups"; string groupString = ""; diff --git a/hcluster.cpp b/hcluster.cpp index e6e97fa..f051465 100644 --- a/hcluster.cpp +++ b/hcluster.cpp @@ -551,7 +551,7 @@ int HCluster::combineFile() { in >> first >> second >> dist; m->gobble(in); - if (m->control_pressed) { in.close(); out.close(); remove(tempDistFile.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(tempDistFile); return 0; } //while there are still values in mergedMin that are smaller than the distance read from file while (count < mergedMin.size()) { @@ -630,7 +630,7 @@ int HCluster::combineFile() { mergedMin.clear(); //rename tempfile to distfile - remove(distfile.c_str()); + m->mothurRemove(distfile); rename(tempDistFile.c_str(), distfile.c_str()); //cout << "remove = "<< renameOK << " rename = " << ok << endl; @@ -767,7 +767,7 @@ int HCluster::processFile() { //get entry while (!in.eof()) { - if (m->control_pressed) { in.close(); out.close(); remove(outTemp.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outTemp); return 0; } in >> firstName >> secondName >> distance; m->gobble(in); @@ -787,7 +787,7 @@ int HCluster::processFile() { in.close(); out.close(); - remove(distfile.c_str()); + m->mothurRemove(distfile); rename(outTemp.c_str(), distfile.c_str()); return 0; diff --git a/hclustercommand.cpp b/hclustercommand.cpp index ec4d35c..b2af034 100644 --- a/hclustercommand.cpp +++ b/hclustercommand.cpp @@ -260,7 +260,7 @@ int HClusterCommand::execute(){ sabundFile.close(); rabundFile.close(); listFile.close(); - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); return 0; } @@ -276,7 +276,7 @@ int HClusterCommand::execute(){ sabundFile.close(); rabundFile.close(); listFile.close(); - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); return 0; } @@ -306,7 +306,7 @@ int HClusterCommand::execute(){ sabundFile.close(); rabundFile.close(); listFile.close(); - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); return 0; } @@ -326,7 +326,7 @@ int HClusterCommand::execute(){ sabundFile.close(); rabundFile.close(); listFile.close(); - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); return 0; } @@ -340,7 +340,7 @@ int HClusterCommand::execute(){ sabundFile.close(); rabundFile.close(); listFile.close(); - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); return 0; } @@ -373,7 +373,7 @@ int HClusterCommand::execute(){ sabundFile.close(); rabundFile.close(); listFile.close(); - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); return 0; } @@ -390,7 +390,7 @@ int HClusterCommand::execute(){ delete cluster; if (m->control_pressed) { - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); return 0; } diff --git a/heatmapcommand.cpp b/heatmapcommand.cpp index 0d8c5b0..9051a5d 100644 --- a/heatmapcommand.cpp +++ b/heatmapcommand.cpp @@ -286,7 +286,7 @@ int HeatMapCommand::execute(){ while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) { if (m->control_pressed) { for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } - for (int i = 0; i < outputNames.size(); i++) { if (outputNames[i] != "control") { remove(outputNames[i].c_str()); } } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { if (outputNames[i] != "control") { m->mothurRemove(outputNames[i]); } } outputTypes.clear(); m->Groups.clear(); delete input; delete heatmap; return 0; } @@ -329,7 +329,7 @@ int HeatMapCommand::execute(){ if (m->control_pressed) { - for (int i = 0; i < outputNames.size(); i++) { if (outputNames[i] != "control") { remove(outputNames[i].c_str()); } } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { if (outputNames[i] != "control") { m->mothurRemove(outputNames[i]); } } outputTypes.clear(); m->Groups.clear(); delete input; delete heatmap; return 0; } @@ -365,7 +365,7 @@ int HeatMapCommand::execute(){ while((rabund != NULL) && ((allLines == 1) || (userLabels.size() != 0))) { if (m->control_pressed) { - for (int i = 0; i < outputNames.size(); i++) { if (outputNames[i] != "control") { remove(outputNames[i].c_str()); } } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { if (outputNames[i] != "control") { m->mothurRemove(outputNames[i]); } } outputTypes.clear(); delete rabund; delete input; delete heatmap; return 0; } @@ -404,7 +404,7 @@ int HeatMapCommand::execute(){ } if (m->control_pressed) { - for (int i = 0; i < outputNames.size(); i++) { if (outputNames[i] != "control") { remove(outputNames[i].c_str()); } } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { if (outputNames[i] != "control") { m->mothurRemove(outputNames[i]); } } outputTypes.clear(); delete input; delete heatmap; return 0; } @@ -439,7 +439,7 @@ int HeatMapCommand::execute(){ while((lookupFloat[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) { if (m->control_pressed) { for (int i = 0; i < lookupFloat.size(); i++) { delete lookupFloat[i]; } - for (int i = 0; i < outputNames.size(); i++) { if (outputNames[i] != "control") { remove(outputNames[i].c_str()); } } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { if (outputNames[i] != "control") { m->mothurRemove(outputNames[i]); } } outputTypes.clear(); m->Groups.clear(); delete input; delete heatmap; return 0; } @@ -481,7 +481,7 @@ int HeatMapCommand::execute(){ if (m->control_pressed) { - for (int i = 0; i < outputNames.size(); i++) { if (outputNames[i] != "control") { remove(outputNames[i].c_str()); } } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { if (outputNames[i] != "control") { m->mothurRemove(outputNames[i]); } } outputTypes.clear(); m->Groups.clear(); delete input; delete heatmap; return 0; } @@ -519,7 +519,7 @@ int HeatMapCommand::execute(){ delete heatmap; if (m->control_pressed) { - for (int i = 0; i < outputNames.size(); i++) { if (outputNames[i] != "control") { remove(outputNames[i].c_str()); } } outputTypes.clear(); return 0; + for (int i = 0; i < outputNames.size(); i++) { if (outputNames[i] != "control") { m->mothurRemove(outputNames[i]); } } outputTypes.clear(); return 0; } m->mothurOutEndLine(); diff --git a/heatmapsimcommand.cpp b/heatmapsimcommand.cpp index 38e344d..e791f0c 100644 --- a/heatmapsimcommand.cpp +++ b/heatmapsimcommand.cpp @@ -294,7 +294,7 @@ int HeatMapSimCommand::execute(){ delete heatmap; - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); return 0; } m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); diff --git a/indicatorcommand.cpp b/indicatorcommand.cpp index e8863f7..6fccaba 100644 --- a/indicatorcommand.cpp +++ b/indicatorcommand.cpp @@ -353,7 +353,7 @@ int IndicatorCommand::execute(){ if (sharedfile != "") { for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } } else { for (int i = 0; i < lookupFloat.size(); i++) { delete lookupFloat[i]; } } - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } //set tree file as new current treefile if (treefile != "") { @@ -1183,7 +1183,7 @@ vector IndicatorCommand::getPValues(vector< vector> numTemp; m->gobble(in); pvalues[j] += numTemp; } - in.close(); remove(tempFile.c_str()); + in.close(); m->mothurRemove(tempFile); } for (int i = 0; i < pvalues.size(); i++) { pvalues[i] /= (double)iters; } } @@ -1296,7 +1296,7 @@ vector IndicatorCommand::getPValues(vector< vector > in >> numTemp; m->gobble(in); pvalues[j] += numTemp; } - in.close(); remove(tempFile.c_str()); + in.close(); m->mothurRemove(tempFile); } for (int i = 0; i < pvalues.size(); i++) { pvalues[i] /= (double)iters; } } diff --git a/libshuffcommand.cpp b/libshuffcommand.cpp index c993a06..96abbbe 100644 --- a/libshuffcommand.cpp +++ b/libshuffcommand.cpp @@ -222,7 +222,7 @@ int LibShuffCommand::execute(){ m->openOutputFile(newGroupFile, outGroups); for (int i = 0; i < matrix->getNumSeqs(); i++) { - if (m->control_pressed) { delete groupMap; delete matrix; outGroups.close(); remove(newGroupFile.c_str()); return 0; } + if (m->control_pressed) { delete groupMap; delete matrix; outGroups.close(); m->mothurRemove(newGroupFile); return 0; } Names temp = matrix->getRowInfo(i); outGroups << temp.seqName << '\t' << temp.groupName << endl; @@ -238,7 +238,7 @@ int LibShuffCommand::execute(){ groupMap = new GroupMap(groupfile); groupMap->readMap(); - if (m->control_pressed) { delete groupMap; delete matrix; remove(newGroupFile.c_str()); return 0; } + if (m->control_pressed) { delete groupMap; delete matrix; m->mothurRemove(newGroupFile); return 0; } } @@ -320,7 +320,7 @@ int LibShuffCommand::execute(){ delete matrix; delete groupMap; - if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); diff --git a/listseqscommand.cpp b/listseqscommand.cpp index 3fe8360..ef15158 100644 --- a/listseqscommand.cpp +++ b/listseqscommand.cpp @@ -223,13 +223,13 @@ int ListSeqsCommand::execute(){ //output to .accnos file for (int i = 0; i < names.size(); i++) { - if (m->control_pressed) { outputTypes.clear(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { outputTypes.clear(); out.close(); m->mothurRemove(outputFileName); return 0; } out << names[i] << endl; } out.close(); - if (m->control_pressed) { outputTypes.clear(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { outputTypes.clear(); m->mothurRemove(outputFileName); return 0; } m->setAccnosFile(outputFileName); diff --git a/makefastqcommand.cpp b/makefastqcommand.cpp index 82f7301..8e1a7f5 100644 --- a/makefastqcommand.cpp +++ b/makefastqcommand.cpp @@ -181,7 +181,7 @@ int MakeFastQCommand::execute(){ qFile.close(); out.close(); - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); diff --git a/makegroupcommand.cpp b/makegroupcommand.cpp index 2cab212..e32af21 100644 --- a/makegroupcommand.cpp +++ b/makegroupcommand.cpp @@ -205,7 +205,7 @@ int MakeGroupCommand::execute(){ for (int i = 0; i < fastaFileNames.size(); i++) { - if (m->control_pressed) { outputTypes.clear(); out.close(); remove(filename.c_str()); return 0; } + if (m->control_pressed) { outputTypes.clear(); out.close(); m->mothurRemove(filename); return 0; } ifstream in; m->openInputFile(fastaFileNames[i], in); @@ -214,7 +214,7 @@ int MakeGroupCommand::execute(){ Sequence seq(in, "no align"); m->gobble(in); - if (m->control_pressed) { outputTypes.clear(); in.close(); out.close(); remove(filename.c_str()); return 0; } + if (m->control_pressed) { outputTypes.clear(); in.close(); out.close(); m->mothurRemove(filename); return 0; } if (seq.getName() != "") { out << seq.getName() << '\t' << groupsNames[i] << endl; } } diff --git a/matrixoutputcommand.cpp b/matrixoutputcommand.cpp index 7800910..35a4553 100644 --- a/matrixoutputcommand.cpp +++ b/matrixoutputcommand.cpp @@ -335,7 +335,7 @@ int MatrixOutputCommand::execute(){ //as long as you are not at the end of the file or done wih the lines you want while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) { - if (m->control_pressed) { outputTypes.clear(); delete input; for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } m->Groups.clear(); return 0; } + if (m->control_pressed) { outputTypes.clear(); delete input; for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } m->Groups.clear(); return 0; } if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){ m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine(); @@ -368,7 +368,7 @@ int MatrixOutputCommand::execute(){ lookup = input->getSharedRAbundVectors(); } - if (m->control_pressed) { outputTypes.clear(); delete input; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } m->Groups.clear(); return 0; } + if (m->control_pressed) { outputTypes.clear(); delete input; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } m->Groups.clear(); return 0; } //output error messages about any remaining user labels set::iterator it; @@ -383,7 +383,7 @@ int MatrixOutputCommand::execute(){ } } - if (m->control_pressed) { outputTypes.clear(); delete input; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } m->Groups.clear(); return 0; } + if (m->control_pressed) { outputTypes.clear(); delete input; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } m->Groups.clear(); return 0; } //run last label if you need to if (needToRun == true) { @@ -395,7 +395,7 @@ int MatrixOutputCommand::execute(){ for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } } - if (m->control_pressed) { outputTypes.clear(); delete input; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } m->Groups.clear(); return 0; } + if (m->control_pressed) { outputTypes.clear(); delete input; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } m->Groups.clear(); return 0; } //reset groups parameter m->Groups.clear(); @@ -527,7 +527,7 @@ int MatrixOutputCommand::process(vector thisLookup){ } } intemp.close(); - remove(tempdistFileName.c_str()); + m->mothurRemove(tempdistFileName); } } diff --git a/mergefilecommand.cpp b/mergefilecommand.cpp index c944e3b..04c92fa 100644 --- a/mergefilecommand.cpp +++ b/mergefilecommand.cpp @@ -140,7 +140,7 @@ int MergeFileCommand::execute(){ m->openInputFile(fileNames[i], inputFile); while(!inputFile.eof()){ - if (m->control_pressed) { outputTypes.clear(); inputFile.close(); outputFile.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { outputTypes.clear(); inputFile.close(); outputFile.close(); m->mothurRemove(outputFileName); return 0; } c = inputFile.get(); //-1 is eof char @@ -152,7 +152,7 @@ int MergeFileCommand::execute(){ outputFile.close(); - if (m->control_pressed) { outputTypes.clear(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { outputTypes.clear(); m->mothurRemove(outputFileName); return 0; } m->mothurOutEndLine(); m->mothurOut("Output File Name: "); m->mothurOutEndLine(); diff --git a/mergegroupscommand.cpp b/mergegroupscommand.cpp index a01441e..8df6b62 100644 --- a/mergegroupscommand.cpp +++ b/mergegroupscommand.cpp @@ -187,7 +187,7 @@ int MergeGroupsCommand::execute(){ //as long as you are not at the end of the file or done wih the lines you want while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) { - if (m->control_pressed) { out.close(); for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } m->Groups.clear(); delete designMap; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { out.close(); for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } m->Groups.clear(); delete designMap; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){ @@ -221,13 +221,13 @@ int MergeGroupsCommand::execute(){ //prevent memory leak for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; lookup[i] = NULL; } - if (m->control_pressed) { out.close(); m->Groups.clear(); delete designMap; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { out.close(); m->Groups.clear(); delete designMap; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } //get next line to process lookup = input.getSharedRAbundVectors(); } - if (m->control_pressed) { out.close(); m->Groups.clear(); delete designMap; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { out.close(); m->Groups.clear(); delete designMap; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } //output error messages about any remaining user labels set::iterator it; @@ -260,7 +260,7 @@ int MergeGroupsCommand::execute(){ m->Groups.clear(); delete designMap; - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0;} + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0;} //set shared file as new current sharedfile diff --git a/metastats2.c b/metastats2.c index 6601b09..70edc3d 100644 --- a/metastats2.c +++ b/metastats2.c @@ -86,7 +86,7 @@ int metastat_main (char* outputFileName, int numRows, int numCols, double thresh ratio[i]=total[i]/min; } - // Change matrix into an array as received by R for compatibility. + //Change matrix into an array as received by R for compatibility. c=0; for(i=0;i.999999999){ *pre=1; } + + //printf("feaxt = %f\t%f\t%f\t%f\t%f\t%f\n", *expect, *pre, f11, f12, f21, f22); storage[i][8] = *pre; pvalues[i]=*pre; } diff --git a/metastatscommand.cpp b/metastatscommand.cpp index 0704f55..2a55ff0 100644 --- a/metastatscommand.cpp +++ b/metastatscommand.cpp @@ -10,6 +10,7 @@ #include "metastatscommand.h" #include "metastats.h" #include "sharedutilities.h" +#include "mothurmetastats.h" //********************************************************************************************************************** vector MetaStatsCommand::setParameters(){ @@ -249,7 +250,7 @@ int MetaStatsCommand::execute(){ //as long as you are not at the end of the file or done wih the lines you want while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) { - if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } m->Groups.clear(); delete input; delete designMap; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } m->Groups.clear(); delete input; delete designMap; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){ @@ -280,13 +281,13 @@ int MetaStatsCommand::execute(){ //prevent memory leak for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; lookup[i] = NULL; } - if (m->control_pressed) { outputTypes.clear(); m->Groups.clear(); delete input; delete designMap; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { outputTypes.clear(); m->Groups.clear(); delete input; delete designMap; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } //get next line to process lookup = input->getSharedRAbundVectors(); } - if (m->control_pressed) { outputTypes.clear(); m->Groups.clear(); delete input; delete designMap; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { outputTypes.clear(); m->Groups.clear(); delete input; delete designMap; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } //output error messages about any remaining user labels set::iterator it; @@ -318,7 +319,7 @@ int MetaStatsCommand::execute(){ delete input; delete designMap; - if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0;} + if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0;} m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); @@ -404,6 +405,8 @@ int MetaStatsCommand::driver(int start, int num, vector& th double** data; data = new double*[thisLookUp[0]->getNumBins()]; + vector< vector > data2; data2.resize(thisLookUp[0]->getNumBins()); + vector subset; int setACount = 0; int setBCount = 0; @@ -428,14 +431,21 @@ int MetaStatsCommand::driver(int start, int num, vector& th //fill data for (int j = 0; j < thisLookUp[0]->getNumBins(); j++) { data[j] = new double[subset.size()]; + data2[j].resize(subset.size(), 0.0); for (int i = 0; i < subset.size(); i++) { data[j][i] = (subset[i]->getAbundance(j)); + data2[j][i] = (subset[i]->getAbundance(j)); } } m->mothurOut("Comparing " + setA + " and " + setB + "..."); m->mothurOutEndLine(); metastat_main(output, thisLookUp[0]->getNumBins(), subset.size(), threshold, iters, data, setACount); + m->mothurOutEndLine(); + MothurMetastats mothurMeta(threshold, iters); + mothurMeta.runMetastats(outputFileName+".myVersion" , data2, setACount); + m->mothurOutEndLine(); + m->mothurOutEndLine(); } diff --git a/mgclustercommand.cpp b/mgclustercommand.cpp index b982b8d..f0886c8 100644 --- a/mgclustercommand.cpp +++ b/mgclustercommand.cpp @@ -230,7 +230,7 @@ int MGClusterCommand::execute(){ if (m->control_pressed) { delete nameMap; delete read; delete list; delete rabund; - listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str()); + listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund")); outputTypes.clear(); return 0; } @@ -253,7 +253,7 @@ int MGClusterCommand::execute(){ if (m->control_pressed) { delete nameMap; delete distMatrix; delete list; delete rabund; delete cluster; - listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str()); + listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund")); outputTypes.clear(); return 0; } @@ -265,7 +265,7 @@ int MGClusterCommand::execute(){ if (m->control_pressed) { delete nameMap; delete distMatrix; delete list; delete rabund; delete cluster; - listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str()); + listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund")); outputTypes.clear(); return 0; } @@ -288,7 +288,7 @@ int MGClusterCommand::execute(){ if (m->control_pressed) { delete nameMap; delete distMatrix; delete list; delete rabund; delete cluster; delete temp; - listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str()); + listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund")); outputTypes.clear(); return 0; } @@ -319,7 +319,7 @@ int MGClusterCommand::execute(){ if (m->control_pressed) { delete nameMap; delete distMatrix; delete list; delete rabund; delete cluster; delete temp; - listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str()); + listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund")); outputTypes.clear(); return 0; } @@ -349,7 +349,7 @@ int MGClusterCommand::execute(){ if (m->control_pressed) { delete nameMap; delete list; delete rabund; - listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str()); + listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund")); outputTypes.clear(); return 0; } @@ -366,7 +366,7 @@ int MGClusterCommand::execute(){ if (m->control_pressed) { delete nameMap; delete list; delete rabund; delete hcluster; - listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str()); + listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund")); outputTypes.clear(); return 0; } @@ -382,9 +382,9 @@ int MGClusterCommand::execute(){ if (m->control_pressed) { delete nameMap; delete list; delete rabund; delete hcluster; - listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str()); - remove(distFile.c_str()); - remove(overlapFile.c_str()); + listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund")); + m->mothurRemove(distFile); + m->mothurRemove(overlapFile); outputTypes.clear(); return 0; } @@ -397,9 +397,9 @@ int MGClusterCommand::execute(){ if (m->control_pressed) { delete nameMap; delete list; delete rabund; delete hcluster; - listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str()); - remove(distFile.c_str()); - remove(overlapFile.c_str()); + listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund")); + m->mothurRemove(distFile); + m->mothurRemove(overlapFile); outputTypes.clear(); return 0; } @@ -421,9 +421,9 @@ int MGClusterCommand::execute(){ if (m->control_pressed) { delete nameMap; delete list; delete rabund; delete hcluster; delete temp; - listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str()); - remove(distFile.c_str()); - remove(overlapFile.c_str()); + listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund")); + m->mothurRemove(distFile); + m->mothurRemove(overlapFile); outputTypes.clear(); return 0; } @@ -457,9 +457,9 @@ int MGClusterCommand::execute(){ if (m->control_pressed) { delete nameMap; delete list; delete rabund; delete hcluster; delete temp; - listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str()); - remove(distFile.c_str()); - remove(overlapFile.c_str()); + listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund")); + m->mothurRemove(distFile); + m->mothurRemove(overlapFile); outputTypes.clear(); return 0; } @@ -474,8 +474,8 @@ int MGClusterCommand::execute(){ } delete hcluster; - remove(distFile.c_str()); - remove(overlapFile.c_str()); + m->mothurRemove(distFile); + m->mothurRemove(overlapFile); } delete list; @@ -486,7 +486,7 @@ int MGClusterCommand::execute(){ if (m->control_pressed) { delete nameMap; - listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str()); + listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund")); outputTypes.clear(); return 0; } @@ -658,12 +658,12 @@ void MGClusterCommand::sortHclusterFiles(string unsortedDist, string unsortedOve try { //sort distFile string sortedDistFile = m->sortFile(unsortedDist, outputDir); - remove(unsortedDist.c_str()); //delete unsorted file + m->mothurRemove(unsortedDist); //delete unsorted file distFile = sortedDistFile; //sort overlap file string sortedOverlapFile = m->sortFile(unsortedOverlap, outputDir); - remove(unsortedOverlap.c_str()); //delete unsorted file + m->mothurRemove(unsortedOverlap); //delete unsorted file overlapFile = sortedOverlapFile; } catch(exception& e) { diff --git a/mothur.cpp b/mothur.cpp index 5838811..c991422 100644 --- a/mothur.cpp +++ b/mothur.cpp @@ -228,7 +228,7 @@ int main(int argc, char *argv[]){ outNewLog.close(); m->appendFiles(logFileName, newlogFileName); - remove(logFileName.c_str()); + m->mothurRemove(logFileName); } }else{ newlogFileName = outputDir + logFileName; diff --git a/mothurfisher.cpp b/mothurfisher.cpp new file mode 100644 index 0000000..8cf332b --- /dev/null +++ b/mothurfisher.cpp @@ -0,0 +1,193 @@ +/* + * mothurfisher.cpp + * Mothur + * + * Created by westcott on 7/8/11. + * Copyright 2011 Schloss Lab. All rights reserved. + * + */ + +//translated to c++ using source code http://www.langsrud.com/stat/fisher.htm as a reference + +#include "mothurfisher.h" +/***********************************************************/ +double MothurFisher::fexact(double n11_, double n12_, double n21_, double n22_) { + try { + sleft = 0.0; sright = 0.0; sless = 0.0; slarg = 0.0; + + if(n11_<0) n11_ *= -1; + if(n12_<0) n12_ *= -1; + if(n21_<0) n21_ *= -1; + if(n22_<0) n22_ *= -1; + + double n1_ = n11_+n12_; + double n_1 = n11_+n21_; + double n = n11_ +n12_ +n21_ +n22_; + exact(n11_,n1_,n_1,n); + double twotail = sleft+sright; + + if(twotail>1) twotail=1; + double result = twotail; + return result; + + }catch(exception& e) { + m->errorOut(e, "MothurFisher", "fexact"); + exit(1); + } +} +/***********************************************************/ +double MothurFisher::lngamm(double z) { + // Reference: "Lanczos, C. 'A precision approximation + // of the gamma function', J. SIAM Numer. Anal., B, 1, 86-96, 1964." + // Translation of Alan Miller's FORTRAN-implementation + // See http://lib.stat.cmu.edu/apstat/245 + try { + double x = 0; + x += 0.1659470187408462e-06/(z+7); + x += 0.9934937113930748e-05/(z+6); + x -= 0.1385710331296526 /(z+5); + x += 12.50734324009056 /(z+4); + x -= 176.6150291498386 /(z+3); + x += 771.3234287757674 /(z+2); + x -= 1259.139216722289 /(z+1); + x += 676.5203681218835 /(z); + x += 0.9999999999995183; + + return(log(x)-5.58106146679532777-z+(z-0.5)*log(z+6.5)); + + }catch(exception& e) { + m->errorOut(e, "MothurFisher", "lngamm"); + exit(1); + } +} + +/***********************************************************/ +double MothurFisher::lnfact(double n){ + try { + if(n <= 1) return(0); + return(lngamm(n+1)); + }catch(exception& e) { + m->errorOut(e, "MothurFisher", "lnfact"); + exit(1); + } +} +/***********************************************************/ +double MothurFisher::lnbico(double n, double k){ + try { + return(lnfact(n)-lnfact(k)-lnfact(n-k)); + }catch(exception& e) { + m->errorOut(e, "MothurFisher", "lnbico"); + exit(1); + } +} +/***********************************************************/ +double MothurFisher::hyper_323(double n11, double n1_, double n_1, double n){ + try { + return(exp(lnbico(n1_,n11)+lnbico(n-n1_,n_1-n11)-lnbico(n,n_1))); + }catch(exception& e) { + m->errorOut(e, "MothurFisher", "hyper_323"); + exit(1); + } +} +/***********************************************************/ +//var sn11,sn1_,sn_1,sn,sprob; +double MothurFisher::hyper(double n11){ + try { + return(hyper0(n11,0,0,0)); + }catch(exception& e) { + m->errorOut(e, "MothurFisher", "hyper"); + exit(1); + } +} +/***********************************************************/ +double MothurFisher::hyper0(double n11i, double n1_i, double n_1i, double ni) { + try { + if (!((n1_i != 0)&&(n_1i != 0)&&(ni != 0))) { + if(!(((int)n11i % 10) == 0)){ + if(n11i==sn11+1) + { + sprob *= ((sn1_-sn11)/(n11i))*((sn_1-sn11)/(n11i+sn-sn1_-sn_1)); + sn11 = n11i; + return sprob; + } + if(n11i==sn11-1) + { + sprob *= ((sn11)/(sn1_-n11i))*((sn11+sn-sn1_-sn_1)/(sn_1-n11i)); + sn11 = n11i; + return sprob; + } + } + sn11 = n11i; + }else{ + sn11 = n11i; + sn1_=n1_i; + sn_1=n_1i; + sn=ni; + } + + sprob = hyper_323(sn11,sn1_,sn_1,sn); + return sprob; + + }catch(exception& e) { + m->errorOut(e, "MothurFisher", "hyper0"); + exit(1); + } +} +/***********************************************************/ +double MothurFisher::exact(double n11, double n1_, double n_1, double n){ + try { + double p,i,j,prob; + double max=n1_; + if(n_1errorOut(e, "MothurFisher", "hyper0"); + exit(1); + } +} +/***********************************************************/ + + + diff --git a/mothurfisher.h b/mothurfisher.h new file mode 100644 index 0000000..88557d4 --- /dev/null +++ b/mothurfisher.h @@ -0,0 +1,39 @@ +#ifndef MOTHUR_FISHER +#define MOTHUR_FISHER + +/* + * mothurfisher.h + * Mothur + * + * Created by westcott on 7/8/11. + * Copyright 2011 Schloss Lab. All rights reserved. + * + */ + + +#include "mothurout.h" + +class MothurFisher { + +public: + MothurFisher(){} + ~MothurFisher(){} + + double fexact(double, double, double, double); + +private: + MothurOut* m; + double sleft, sright, sless, slarg; + double sn11,sn1_,sn_1,sn,sprob; + double lngamm(double); + double lnfact(double); + double lnbico(double, double); + double hyper_323(double, double, double, double); + double hyper(double); + double hyper0(double, double, double, double); + double exact(double, double, double, double); +}; + + +#endif + diff --git a/mothurmetastats.cpp b/mothurmetastats.cpp new file mode 100644 index 0000000..ed0aaef --- /dev/null +++ b/mothurmetastats.cpp @@ -0,0 +1,496 @@ +/* + * mothurmetastats.cpp + * Mothur + * + * Created by westcott on 7/6/11. + * Copyright 2011 Schloss Lab. All rights reserved. + * + */ + +#include "mothurmetastats.h" +#include "mothurfisher.h" + +/***********************************************************/ +MothurMetastats::MothurMetastats(double t, int n) { + try { + m = MothurOut::getInstance(); + threshold = t; + numPermutations = n; + + }catch(exception& e) { + m->errorOut(e, "MothurMetastats", "MothurMetastats"); + exit(1); + } +} +/***********************************************************/ +MothurMetastats::~MothurMetastats() { + try { + + + }catch(exception& e) { + m->errorOut(e, "MothurMetastats", "~MothurMetastats"); + exit(1); + } +} +/***********************************************************/ +//main metastats function +int MothurMetastats::runMetastats(string outputFileName, vector< vector >& data, int secondGroupingStart) { + try { + int bflag = 0; + row = data.size(); //numBins + column = data[0].size(); //numGroups in subset + int size = row*column; + + //consistent with original, but this should never be true + if ((secondGroupingStart >= column) || (secondGroupingStart <= 0)) { m->mothurOut("[ERROR]: Check your g value."); m->mothurOutEndLine(); return 0; } + + //Initialize the matrices + vector pmatrix; pmatrix.resize(size, 0.0); + vector permuted; permuted.resize(size, 0.0); + vector< vector > storage; storage.resize(row); + for (int i = 0; i < storage.size(); i++) { storage[i].resize(9, 0.0); } + + //Produces the sum of each column + vector total; total.resize(column, 0.0); + vector ratio; ratio.resize(column, 0.0); + double total1 = 0.0; double total2 = 0.0; + + //total[i] = total abundance for group[i] + for (int i = 0; i < column; i++) { + for (int j = 0; j < row; j++) { + total[i] += data[j][i]; + } + } + + //total for first grouping + for (int i = 0; i < (secondGroupingStart-1); i++) { total1 += total[i]; } + + //total for second grouping + for (int i = (secondGroupingStart-1); i < column; i++) { total2 += total[i]; } + + //Creates the ratios by first finding the minimum of totals + double min = total[0]; + for (int i = 0; i < total.size(); i++) { + if (total[i] < min) { min = total[i]; } + } + + //sanity check + if (min <= 0.0) { m->mothurOut("[ERROR]: the sum of one of the columns <= 0."); m->mothurOutEndLine(); return 0; } + + //Ratio time... + for(int i = 0; i < ratio.size(); i++){ ratio[i] = total[i] / min; } + + //Change matrix into an array as received by R for compatibility - kept to be consistent with original + int count = 0; + for(int i = 0; i < column; i++){ + for(int j = 0; j < row; j++){ + pmatrix[count]=data[j][i]; + count++; + } + } + + if(row == 1){ + for (int i =0; i < column; i++){ pmatrix[i] /= ratio[i]; } + }else { + count = 0; int j=-1; + + for (int i=0; i < size; i++) { + if (count % row == 0) { j++; } + pmatrix[i] /= ratio[j]; + count++; + } + } + + vector permuted_ttests; permuted_ttests.resize(row, 0.0); + vector pvalues; pvalues.resize(row, 0.0); + vector tinitial; tinitial.resize(row, 0.0); + + if (m->control_pressed) { return 1; } + + //Find the initial values for the matrix. + start(pmatrix, secondGroupingStart, tinitial, storage); + + if (m->control_pressed) { return 1; } + + // Start the calculations. + if ( (column == 2) || ((secondGroupingStart-1) < 8) || ((column-secondGroupingStart+1) < 8) ){ + + vector fish; fish.resize(row, 0.0); + vector fish2; fish2.resize(row, 0.0); + + for(int i = 0; i < row; i++){ + + for(int j = 0; j < (secondGroupingStart-1); j++) { fish[i] += data[i][j]; } + for(int j = (secondGroupingStart-1); j < column; j++) { fish2[i] += data[i][j]; } + + //vector tempData; tempData.resize(4, 0.0); + double f11, f12, f21, f22; + f11 = fish[i]; + f12 = fish2[i]; + f21 = total1 - fish[i]; + f22 = total2 - fish2[i]; + + double pre = 0.0; + + MothurFisher fisher; + pre = fisher.fexact(f11, f12, f21, f22); + + if (m->control_pressed) { return 1; } + + if (pre > 0.999999999) { pre = 1.0; } + storage[i][8] = pre; + pvalues[i] = pre; + } + + }else { + + testp(permuted_ttests, permuted, pmatrix, secondGroupingStart, tinitial, pvalues); + + if (m->control_pressed) { return 1; } + + // Checks to make sure the matrix isn't sparse. + vector sparse; sparse.resize(row, 0.0); + vector sparse2; sparse2.resize(row, 0.0); + + int c = 0; + + for(int i = 0; i < row; i++){ + + for(int j = 0; j < (secondGroupingStart-1); j++){ sparse[i] += data[i][j]; } + if(sparse[i] < (double)(secondGroupingStart-1)){ c++; } + + // ?<= for col + for(int j = (secondGroupingStart-1); j < column; j++){ sparse2[i] += data[i][j]; } + if( (sparse2[i] < (double)(column-secondGroupingStart+1))) { c++; } + + if (c == 2) { + c=0; + double f11,f12,f21,f22; + + f11=sparse[i]; sparse[i]=0; + f12=sparse2[i]; sparse2[i]=0; + f21 = total1 - f11; + f22 = total2 - f12; + + double pre = 0.0; + + MothurFisher fisher; + pre = fisher.fexact(f11, f12, f21, f22); + + if (m->control_pressed) { return 1; } + + if (pre > 0.999999999){ + pre = 1.0; + } + + storage[i][8] = pre; + pvalues[i] = pre; + } + } + + bflag = 1; + } + + // Calculates the mean of counts (not normalized) + vector< vector > temp; temp.resize(row); + for (int i = 0; i < temp.size(); i++) { temp[i].resize(2, 0.0); } + + for (int j = 0; j < row; j++){ + if (m->control_pressed) { return 1; } + + for (int i = 1; i <= (secondGroupingStart-1); i++){ temp[j][0] += data[j][i-1]; } + temp[j][0] /= (double)(secondGroupingStart-1); + + for(int i = secondGroupingStart; i <= column; i++){ temp[j][1] += data[j][i-1]; } + temp[j][1] /= (double)(column-secondGroupingStart+1); + } + + for(int i = 0; i < row; i++){ + if (m->control_pressed) { return 1; } + + storage[i][3]=temp[i][0]; + storage[i][7]=temp[i][1]; + storage[i][8]=pvalues[i]; + } + + // BACKUP checks + cout.setf(ios::fixed, ios::floatfield); cout.setf(ios::showpoint); + for (int i = 0; i < row; i++){ + + if (m->control_pressed) { return 1; } + + if(pvalues[i] < threshold){ + m->mothurOut("Feature " + toString((i+1)) + " is significant, p = "); + cout << pvalues[i]; + m->mothurOutJustToLog(toString(pvalues[i])); m->mothurOutEndLine(); + } + } + + // And now we write the files to a text file. + struct tm *local; + time_t t; t = time(NULL); + local = localtime(&t); + + ofstream out; + m->openOutputFile(outputFileName, out); + out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint); + + out << "Local time and date of test: " << asctime(local) << endl; + out << "# rows = " << row << ", # col = " << column << ", g = " << secondGroupingStart << endl << endl; + if (bflag == 1){ out << numPermutations << " permutations" << endl << endl; } + + //output column headings - not really sure... documentation labels 9 columns, there are 10 in the output file + //storage 0 = meanGroup1 - line 529, 1 = varGroup1 - line 532, 2 = err rate1 - line 534, 3 = mean of counts group1?? - line 291, 4 = meanGroup2 - line 536, 5 = varGroup2 - line 539, 6 = err rate2 - line 541, 7 = mean of counts group2?? - line 292, 8 = pvalues - line 293 + out << "OTU\tmean(group1)\tvariance(group1)\tstderr(group1)\tmean_of_counts(group1)\tmean(group2)\tvariance(group2)\tstderr(group2)\tmean_of_counts(group1)\tp-value\n"; + + for(int i = 0; i < row; i++){ + if (m->control_pressed) { out.close(); return 0; } + + out << (i+1); + for(int j = 0; j < 9; j++){ out << '\t' << storage[i][j]; } + out << endl; + } + + out << endl << endl; + out.close(); + + return 0; + + }catch(exception& e) { + m->errorOut(e, "MothurMetastats", "runMetastats"); + exit(1); + } +} +/***********************************************************/ +//Find the initial values for the matrix +int MothurMetastats::start(vector& Imatrix, int secondGroupingStart, vector& initial, vector< vector >& storage) { + try { + + int a = row; a*=4; + + double xbardiff = 0.0; double denom = 0.0; + vector store; store.resize(a, 0.0); + vector tool; tool.resize(a, 0.0); + vector< vector > C1; C1.resize(row); + for (int i = 0; i < C1.size(); i++) { C1[i].resize(3, 0.0); } + vector< vector > C2; C2.resize(row); + for (int i = 0; i < C2.size(); i++) { C2[i].resize(3, 0.0); } + + meanvar(Imatrix, secondGroupingStart, store); + + if (m->control_pressed) { return 0; } + + //copy store into tool + tool = store; + + for (int i = 0; i < row; i++){ + C1[i][0]=tool[i]; //mean group 1 + storage[i][0]=C1[i][0]; + C1[i][1]=tool[i+row+row]; // var group 1 + storage[i][1]=C1[i][1]; + C1[i][2]=C1[i][1]/(secondGroupingStart-1); + storage[i][2]=sqrt(C1[i][2]); + + C2[i][0]=tool[i+row]; // mean group 2 + storage[i][4]=C2[i][0]; + C2[i][1]=tool[i+row+row+row]; // var group 2 + storage[i][5]=C2[i][1]; + C2[i][2]=C2[i][1]/(column-secondGroupingStart+1); + storage[i][6]=sqrt(C2[i][2]); + } + + if (m->control_pressed) { return 0; } + + for (int i = 0; i < row; i++){ + xbardiff = C1[i][0]-C2[i][0]; + denom = sqrt(C1[i][2]+C2[i][2]); + initial[i]=fabs(xbardiff/denom); + } + + return 0; + + }catch(exception& e) { + m->errorOut(e, "MothurMetastats", "start"); + exit(1); + } +} +/***********************************************************/ +int MothurMetastats::meanvar(vector& pmatrix, int secondGroupingStart, vector& store) { + try { + vector temp; temp.resize(row, 0.0); + vector temp2; temp2.resize(row, 0.0); + vector var; var.resize(row, 0.0); + vector var2; var2.resize(row, 0.0); + + double a = secondGroupingStart-1; + double b = column - a; + int m = a * row; + int n = row * column; + + for (int i = 0; i < m; i++) { temp[i%row] += pmatrix[i]; } + for (int i = 0; i < n; i++) { temp2[i%row]+= pmatrix[i]; } + for (int i = 0; i < row; i++) { temp2[i] -= temp[i]; } + for (int i = 0; i <= row-1;i++) { + store[i] = temp[i]/a; + store[i+row]=temp2[i]/b; + } + + //That completes the mean calculations. + + for (int i = 0; i < m; i++) { var[i%row] += pow((pmatrix[i]-store[i%row]),2); } + for (int i = m; i < n; i++) { var2[i%row]+= pow((pmatrix[i]-store[(i%row)+row]),2); } + for (int i = 0; i <= row-1; i++){ + store[i+2*row]=var[i]/(a-1); + store[i+3*row]=var2[i]/(b-1); + } + + // That completes var calculations. + + return 0; + + }catch(exception& e) { + m->errorOut(e, "MothurMetastats", "meanvar"); + exit(1); + } +} +/***********************************************************/ +int MothurMetastats::testp(vector& permuted_ttests, vector& permuted, vector& Imatrix, int secondGroupingStart, vector& Tinitial, vector& ps) { + try { + + vector Tvalues; Tvalues.resize(row, 0.0); + vector counter; counter.resize(row, 0.0); + int a, b, n; + + a = numPermutations; + b = row; + n = a*b; + + for (int j = 1; j <= row; j++) { + if (m->control_pressed) { return 0; } + permute_matrix(Imatrix, permuted, secondGroupingStart, Tvalues, Tinitial, counter); + } + + for(int j = 0; j < row; j++) { + if (m->control_pressed) { return 0; } + ps[j] = ((counter[j]+1)/(double)(a+1)); + } + + return 0; + + }catch(exception& e) { + m->errorOut(e, "MothurMetastats", "testp"); + exit(1); + } +} +/***********************************************************/ +int MothurMetastats::permute_matrix(vector& Imatrix, vector& permuted, int secondGroupingStart, vector& trial_ts, vector& Tinitial, vector& counter1){ + try { + + vector y; y.resize(column, 0); + for (int i = 1; i <= column; i++){ y[i-1] = i; } + + permute_array(y); + + int f = 0; int c = 0; int k = 0; + for (int i = 0; i < column; i++){ + + if (m->control_pressed) { return 0; } + + f = y[i]; //column number + c = 1; + c *= (f-1); + c *= row; + if (f == 1){ c = 0; } // starting value position in the Imatrix + + for(int j = 1; j <= row; j++){ + permuted[k] = Imatrix[c]; + c++; k++; + } + } + + calc_twosample_ts(permuted, secondGroupingStart, trial_ts, Tinitial, counter1); + + return 0; + + }catch(exception& e) { + m->errorOut(e, "MothurMetastats", "permute_matrix"); + exit(1); + } +} +/***********************************************************/ +int MothurMetastats::permute_array(vector& array) { + try { + static int seeded = 0; + + if (! seeded) { + seeded = 1; + srand(time(NULL)); + } + + for (int i = 0; i < array.size(); i++) { + if (m->control_pressed) { return 0; } + + int selection = rand() % (array.size() - i); + int tmp = array[i + selection]; + array[i + selection] = array[i]; + array[i] = tmp; + } + + return 0; + + }catch(exception& e) { + m->errorOut(e, "MothurMetastats", "permute_array"); + exit(1); + } +} +/***********************************************************/ +int MothurMetastats::calc_twosample_ts(vector& Pmatrix, int secondGroupingStart, vector& Ts, vector& Tinitial, vector& counter) { + try { + int a = row * 4; + + vector< vector > C1; C1.resize(row); + for (int i = 0; i < C1.size(); i++) { C1[i].resize(3, 0.0); } + vector< vector > C2; C2.resize(row); + for (int i = 0; i < C2.size(); i++) { C2[i].resize(3, 0.0); } + vector storage; storage.resize(row, 0.0); + vector tool; tool.resize(row, 0.0); + double xbardiff = 0.0; double denom = 0.0; + + meanvar(Pmatrix, secondGroupingStart, storage); + + for(int i = 0;i <= (a-1); i++) { + if (m->control_pressed) { return 0; } + tool[i] = storage[i]; + } + + for (int i = 0; i < row; i++){ + if (m->control_pressed) { return 0; } + C1[i][0]=tool[i]; + C1[i][1]=tool[i+row+row]; + C1[i][2]=C1[i][1]/(secondGroupingStart-1); + + C2[i][0]=tool[i+row]; + C2[i][1]=tool[i+row+row+row]; // var group 2 + C2[i][2]=C2[i][1]/(column-secondGroupingStart+1); + } + + for (int i = 0; i < row; i++){ + if (m->control_pressed) { return 0; } + xbardiff = C1[i][0]-C2[i][0]; + denom = sqrt(C1[i][2]+C2[i][2]); + Ts[i]=fabs(xbardiff/denom); + if (fabs(Ts[i])>(fabs(Tinitial[i])+.0000000000001)){ //13th place + counter[i]++; + } + } + + return 0; + + }catch(exception& e) { + m->errorOut(e, "MothurMetastats", "calc_twosample_ts"); + exit(1); + } +} +/***********************************************************/ + + diff --git a/mothurmetastats.h b/mothurmetastats.h new file mode 100644 index 0000000..37d6166 --- /dev/null +++ b/mothurmetastats.h @@ -0,0 +1,57 @@ +#ifndef MOTHUR_METASTATS +#define MOTHUR_METASTATS + +/* + * mothurmetastats.h + * Mothur + * + * Created by westcott on 7/6/11. + * Copyright 2011 Schloss Lab. All rights reserved. + * + */ + + +#include "mothurout.h" + +class MothurMetastats { + + public: + MothurMetastats(double, int); //threshold, numPermutations + ~MothurMetastats(); + + int runMetastats(string, vector< vector >&, int); //outputFileName, data, secondGroupingStart + + private: + MothurOut* m; + int row, column, numPermutations; + double threshold; + + int start(vector&, int, vector&, vector< vector >&); //Find the initial values for the matrix + int meanvar(vector&, int, vector&); + int testp(vector&, vector&, vector&, int, vector&, vector&); + int permute_matrix(vector&, vector&, int, vector&, vector&, vector&); + int permute_array(vector&); + int calc_twosample_ts(vector&, int, vector&, vector&, vector&); + + + + +}; + + //void testp(double *permuted_ttests,int *B,double *permuted,double + // *Imatrix,int *nc,int *nr,int *g,double *Tinitial,double *ps); + //void permute_matrix(double *Imatrix,int *nc,int *nr,double + // *permuted,int *g,double *trial_ts,double *Tinitial,double + // *counter); + //void permute_array(int *array, int n); + //void calc_twosample_ts(double *Pmatrix,int *g,int *nc,int *nr,double + // *Ts,double *Tinitial,double *counter1); + //void meanvar(double *pmatrix,int *g,int *nr,int *nc,double *storage); + //void start(double *Imatrix,int *g,int *nr,int *nc,double *testing, + // double storage[][9]); + + //int metastat_main (char*, int, int, double, int, double**, int); + + +#endif + diff --git a/mothurout.cpp b/mothurout.cpp index 9896157..367f5d1 100644 --- a/mothurout.cpp +++ b/mothurout.cpp @@ -811,7 +811,7 @@ int MothurOut::openInputFile(string fileName, ifstream& fileHandle, string m){ cerr << "Decompressing " << completeFileName << " via temporary named pipe " << tempName << "\n"; system(command.c_str()); cerr << "Done decompressing " << completeFileName << "\n"; - remove(tempName.c_str()); + mothurRemove(tempName); exit(EXIT_SUCCESS); } else { cerr << "waiting on child process " << fork_result << "\n"; @@ -857,7 +857,7 @@ int MothurOut::openInputFile(string fileName, ifstream& fileHandle){ cerr << "Decompressing " << completeFileName << " via temporary named pipe " << tempName << "\n"; system(command.c_str()); cerr << "Done decompressing " << completeFileName << "\n"; - remove(tempName.c_str()); + mothurRemove(tempName); exit(EXIT_SUCCESS); } else { cerr << "waiting on child process " << fork_result << "\n"; @@ -902,7 +902,7 @@ int MothurOut::renameFile(string oldName, string newName){ string command = "mv " + oldName + " " + newName; system(command.c_str()); #else - remove(newName.c_str()); + m->mothurRemove(newName); int renameOk = rename(oldName.c_str(), newName.c_str()); #endif return 0; @@ -1038,8 +1038,8 @@ string MothurOut::sortFile(string distFile, string outputDir){ output.close(); //remove temp files - remove(tempDistFile.c_str()); - remove(tempOutfile.c_str()); + mothurRemove(tempDistFile); + mothurRemove(tempOutfile); #endif return outfile; @@ -1407,7 +1407,18 @@ int MothurOut::getNumNames(string names){ exit(1); } } +/***********************************************************************/ +void MothurOut::mothurRemove(string filename){ + try { + filename = getFullPathName(filename); + remove(filename.c_str()); + } + catch(exception& e) { + errorOut(e, "MothurOut", "mothurRemove"); + exit(1); + } +} /**************************************************************************************************/ vector > MothurOut::binomial(int maxOrder){ diff --git a/mothurout.h b/mothurout.h index f68e453..6cdf493 100644 --- a/mothurout.h +++ b/mothurout.h @@ -70,6 +70,7 @@ class MothurOut { map readNames(string); int readNames(string, map&); int readNames(string, vector&, map&); + void mothurRemove(string); //searchs and checks bool checkReleaseVersion(ifstream&, string); diff --git a/nmdscommand.cpp b/nmdscommand.cpp index 946aa68..da82784 100644 --- a/nmdscommand.cpp +++ b/nmdscommand.cpp @@ -217,21 +217,21 @@ int NMDSCommand::execute(){ vector< vector > thisConfig; if (axesfile == "") { thisConfig = generateStartingConfiguration(names.size(), i); } else { thisConfig = getConfiguration(axes, i); } - if (m->control_pressed) { out.close(); out2.close(); for (int k = 0; k < outputNames.size(); k++) { remove(outputNames[k].c_str()); } return 0; } + if (m->control_pressed) { out.close(); out2.close(); for (int k = 0; k < outputNames.size(); k++) { m->mothurRemove(outputNames[k]); } return 0; } //calc nmds for this dimension double stress; vector< vector > endConfig = nmdsCalc(matrix, thisConfig, stress); - if (m->control_pressed) { out.close(); out2.close(); for (int k = 0; k < outputNames.size(); k++) { remove(outputNames[k].c_str()); } return 0; } + if (m->control_pressed) { out.close(); out2.close(); for (int k = 0; k < outputNames.size(); k++) { m->mothurRemove(outputNames[k]); } return 0; } //calc euclid distances for new config vector< vector > newEuclid = linearCalc.calculateEuclidianDistance(endConfig); - if (m->control_pressed) { out.close(); out2.close(); for (int k = 0; k < outputNames.size(); k++) { remove(outputNames[k].c_str()); } return 0; } + if (m->control_pressed) { out.close(); out2.close(); for (int k = 0; k < outputNames.size(); k++) { m->mothurRemove(outputNames[k]); } return 0; } //calc correlation between original distances and euclidean distances from this config double rsquared = linearCalc.calcPearson(newEuclid, matrix); rsquared *= rsquared; - if (m->control_pressed) { out.close(); out2.close(); for (int k = 0; k < outputNames.size(); k++) { remove(outputNames[k].c_str()); } return 0; } + if (m->control_pressed) { out.close(); out2.close(); for (int k = 0; k < outputNames.size(); k++) { m->mothurRemove(outputNames[k]); } return 0; } //output results out << "Config" << (j+1) << '\t'; @@ -249,7 +249,7 @@ int NMDSCommand::execute(){ bestConfig = endConfig; } - if (m->control_pressed) { out.close(); out2.close(); for (int k = 0; k < outputNames.size(); k++) { remove(outputNames[k].c_str()); } return 0; } + if (m->control_pressed) { out.close(); out2.close(); for (int k = 0; k < outputNames.size(); k++) { m->mothurRemove(outputNames[k]); } return 0; } } } @@ -276,7 +276,7 @@ int NMDSCommand::execute(){ outBest.close(); - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); diff --git a/normalizesharedcommand.cpp b/normalizesharedcommand.cpp index a4bdd47..10c7a30 100644 --- a/normalizesharedcommand.cpp +++ b/normalizesharedcommand.cpp @@ -244,7 +244,7 @@ int NormalizeSharedCommand::execute(){ //as long as you are not at the end of the file or done wih the lines you want while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) { - if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } m->Groups.clear(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } m->Groups.clear(); out.close(); m->mothurRemove(outputFileName); return 0; } if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){ @@ -276,13 +276,13 @@ int NormalizeSharedCommand::execute(){ //prevent memory leak for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; lookup[i] = NULL; } - if (m->control_pressed) { outputTypes.clear(); m->Groups.clear(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { outputTypes.clear(); m->Groups.clear(); out.close(); m->mothurRemove(outputFileName); return 0; } //get next line to process lookup = input->getSharedRAbundVectors(); } - if (m->control_pressed) { outputTypes.clear(); m->Groups.clear(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { outputTypes.clear(); m->Groups.clear(); out.close(); m->mothurRemove(outputFileName); return 0; } //output error messages about any remaining user labels set::iterator it; @@ -348,7 +348,7 @@ int NormalizeSharedCommand::execute(){ //as long as you are not at the end of the file or done wih the lines you want while((lookupFloat[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) { - if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < lookupFloat.size(); i++) { delete lookupFloat[i]; } m->Groups.clear(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < lookupFloat.size(); i++) { delete lookupFloat[i]; } m->Groups.clear(); out.close(); m->mothurRemove(outputFileName); return 0; } if(allLines == 1 || labels.count(lookupFloat[0]->getLabel()) == 1){ @@ -382,13 +382,13 @@ int NormalizeSharedCommand::execute(){ //prevent memory leak for (int i = 0; i < lookupFloat.size(); i++) { delete lookupFloat[i]; lookupFloat[i] = NULL; } - if (m->control_pressed) { outputTypes.clear(); m->Groups.clear(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { outputTypes.clear(); m->Groups.clear(); out.close(); m->mothurRemove(outputFileName); return 0; } //get next line to process lookupFloat = input->getSharedRAbundFloatVectors(); } - if (m->control_pressed) { outputTypes.clear(); m->Groups.clear(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { outputTypes.clear(); m->Groups.clear(); out.close(); m->mothurRemove(outputFileName); return 0; } //output error messages about any remaining user labels set::iterator it; @@ -422,7 +422,7 @@ int NormalizeSharedCommand::execute(){ delete input; out.close(); - if (m->control_pressed) { outputTypes.clear(); remove(outputFileName.c_str()); return 0;} + if (m->control_pressed) { outputTypes.clear(); m->mothurRemove(outputFileName); return 0;} m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); @@ -450,6 +450,10 @@ int NormalizeSharedCommand::normalize(vector& thisLookUp, o if (pickedGroups) { eliminateZeroOTUS(thisLookUp); } if (method == "totalgroup") { + + //save numSeqs since they will change as the data is normalized + vector sizes; + for (int i = 0; i < thisLookUp.size(); i++) { sizes.push_back(thisLookUp[i]->getNumSeqs()); } for (int j = 0; j < thisLookUp[0]->getNumBins(); j++) { @@ -459,7 +463,7 @@ int NormalizeSharedCommand::normalize(vector& thisLookUp, o int abund = thisLookUp[i]->getAbundance(j); - float relabund = abund / (float) thisLookUp[i]->getNumSeqs(); + float relabund = abund / (float) sizes[i]; float newNorm = relabund * norm; //round to nearest int @@ -525,6 +529,10 @@ int NormalizeSharedCommand::normalize(vector& thisLook if (method == "totalgroup") { + //save numSeqs since they will change as the data is normalized + vector sizes; + for (int i = 0; i < thisLookUp.size(); i++) { sizes.push_back(thisLookUp[i]->getNumSeqs()); } + for (int j = 0; j < thisLookUp[0]->getNumBins(); j++) { for (int i = 0; i < thisLookUp.size(); i++) { @@ -533,7 +541,7 @@ int NormalizeSharedCommand::normalize(vector& thisLook float abund = thisLookUp[i]->getAbundance(j); - float relabund = abund / (float) thisLookUp[i]->getNumSeqs(); + float relabund = abund / (float) sizes[i]; float newNorm = relabund * norm; thisLookUp[i]->set(j, newNorm, thisLookUp[i]->getGroup()); diff --git a/otuhierarchycommand.cpp b/otuhierarchycommand.cpp index b1f0539..2f99aa6 100644 --- a/otuhierarchycommand.cpp +++ b/otuhierarchycommand.cpp @@ -186,7 +186,7 @@ int OtuHierarchyCommand::execute(){ //go through each bin in "big" otu and output the bins in "little" otu which created it for (int i = 0; i < lists[1].getNumBins(); i++) { - if (m->control_pressed) { outputTypes.clear(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { outputTypes.clear(); out.close(); m->mothurRemove(outputFileName); return 0; } string names = lists[1].get(i); @@ -219,7 +219,7 @@ int OtuHierarchyCommand::execute(){ out.close(); - if (m->control_pressed) { outputTypes.clear(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { outputTypes.clear(); m->mothurRemove(outputFileName); return 0; } m->mothurOutEndLine(); m->mothurOut("Output File Name: "); m->mothurOutEndLine(); diff --git a/pairwiseseqscommand.cpp b/pairwiseseqscommand.cpp index 75a1388..ebbf686 100644 --- a/pairwiseseqscommand.cpp +++ b/pairwiseseqscommand.cpp @@ -312,14 +312,14 @@ int PairwiseSeqsCommand::execute(){ if (output == "lt") { //does the user want lower triangle phylip formatted file outputFile = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "phylip.dist"; - remove(outputFile.c_str()); outputTypes["phylip"].push_back(outputFile); + m->mothurRemove(outputFile); outputTypes["phylip"].push_back(outputFile); }else if (output == "column") { //user wants column format outputFile = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "dist"; outputTypes["column"].push_back(outputFile); - remove(outputFile.c_str()); + m->mothurRemove(outputFile); }else { //assume square outputFile = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "square.dist"; - remove(outputFile.c_str()); + m->mothurRemove(outputFile); outputTypes["phylip"].push_back(outputFile); } @@ -357,11 +357,11 @@ int PairwiseSeqsCommand::execute(){ driverMPI(start, end, outMPI, cutoff); - if (m->control_pressed) { outputTypes.clear(); MPI_File_close(&outMPI); remove(outputFile.c_str()); delete distCalculator; return 0; } + if (m->control_pressed) { outputTypes.clear(); MPI_File_close(&outMPI); m->mothurRemove(outputFile); delete distCalculator; return 0; } //wait on chidren for(int i = 1; i < processors; i++) { - if (m->control_pressed) { outputTypes.clear(); MPI_File_close(&outMPI); remove(outputFile.c_str()); delete distCalculator; return 0; } + if (m->control_pressed) { outputTypes.clear(); MPI_File_close(&outMPI); m->mothurRemove(outputFile); delete distCalculator; return 0; } char buf[5]; MPI_Recv(buf, 5, MPI_CHAR, i, tag, MPI_COMM_WORLD, &status); @@ -370,7 +370,7 @@ int PairwiseSeqsCommand::execute(){ //do your part driverMPI(start, end, outMPI, cutoff); - if (m->control_pressed) { outputTypes.clear(); MPI_File_close(&outMPI); remove(outputFile.c_str()); delete distCalculator; return 0; } + if (m->control_pressed) { outputTypes.clear(); MPI_File_close(&outMPI); m->mothurRemove(outputFile); delete distCalculator; return 0; } char buf[5]; strcpy(buf, "done"); @@ -390,7 +390,7 @@ int PairwiseSeqsCommand::execute(){ if (output != "square"){ driverMPI(start, end, outputFile, mySize); } else { driverMPI(start, end, outputFile, mySize, output); } - if (m->control_pressed) { outputTypes.clear(); remove(outputFile.c_str()); delete distCalculator; return 0; } + if (m->control_pressed) { outputTypes.clear(); m->mothurRemove(outputFile); delete distCalculator; return 0; } int amode=MPI_MODE_APPEND|MPI_MODE_WRONLY|MPI_MODE_CREATE; // MPI_File outMPI; @@ -405,7 +405,7 @@ int PairwiseSeqsCommand::execute(){ for(int b = 1; b < processors; b++) { unsigned long int fileSize; - if (m->control_pressed) { outputTypes.clear(); MPI_File_close(&outMPI); remove(outputFile.c_str()); delete distCalculator; return 0; } + if (m->control_pressed) { outputTypes.clear(); MPI_File_close(&outMPI); m->mothurRemove(outputFile); delete distCalculator; return 0; } MPI_Recv(&fileSize, 1, MPI_LONG, b, tag, MPI_COMM_WORLD, &status); @@ -472,7 +472,7 @@ int PairwiseSeqsCommand::execute(){ #endif #endif - if (m->control_pressed) { outputTypes.clear(); delete distCalculator; remove(outputFile.c_str()); return 0; } + if (m->control_pressed) { outputTypes.clear(); delete distCalculator; m->mothurRemove(outputFile); return 0; } #ifdef USE_MPI MPI_Comm_rank(MPI_COMM_WORLD, &pid); @@ -500,7 +500,7 @@ int PairwiseSeqsCommand::execute(){ m->mothurOut("It took " + toString(time(NULL) - startTime) + " to calculate the distances for " + toString(numSeqs) + " sequences."); m->mothurOutEndLine(); - if (m->control_pressed) { outputTypes.clear(); delete distCalculator; remove(outputFile.c_str()); return 0; } + if (m->control_pressed) { outputTypes.clear(); delete distCalculator; m->mothurRemove(outputFile); return 0; } } delete distCalculator; @@ -571,7 +571,7 @@ void PairwiseSeqsCommand::createProcesses(string filename) { //append and remove temp files for (int i=0;iappendFiles((filename + toString(processIDS[i]) + ".temp"), filename); - remove((filename + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((filename + toString(processIDS[i]) + ".temp")); } #endif } diff --git a/parsefastaqcommand.cpp b/parsefastaqcommand.cpp index 1033ba5..9cba70b 100644 --- a/parsefastaqcommand.cpp +++ b/parsefastaqcommand.cpp @@ -169,7 +169,7 @@ int ParseFastaQCommand::execute(){ outFasta.close(); outQual.close(); - if (m->control_pressed) { outputTypes.clear(); remove(fastaFile.c_str()); remove(qualFile.c_str()); return 0; } + if (m->control_pressed) { outputTypes.clear(); m->mothurRemove(fastaFile); m->mothurRemove(qualFile); return 0; } //set fasta file as new current fastafile string current = ""; diff --git a/parselistscommand.cpp b/parselistscommand.cpp index e2c3e01..9459294 100644 --- a/parselistscommand.cpp +++ b/parselistscommand.cpp @@ -195,7 +195,7 @@ int ParseListCommand::execute(){ if (m->control_pressed) { delete input; delete list; delete groupMap; for (i=0; inamesOfGroups.size(); i++) { (*(filehandles[groupMap->namesOfGroups[i]])).close(); delete filehandles[groupMap->namesOfGroups[i]]; } - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); return 0; } @@ -204,7 +204,7 @@ int ParseListCommand::execute(){ if (m->control_pressed) { delete input; delete list; delete groupMap; for (i=0; inamesOfGroups.size(); i++) { (*(filehandles[groupMap->namesOfGroups[i]])).close(); delete filehandles[groupMap->namesOfGroups[i]]; } - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); return 0; } @@ -243,7 +243,7 @@ int ParseListCommand::execute(){ if (m->control_pressed) { delete input; delete groupMap; for (i=0; inamesOfGroups.size(); i++) { (*(filehandles[groupMap->namesOfGroups[i]])).close(); delete filehandles[groupMap->namesOfGroups[i]]; } - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); return 0; } @@ -264,7 +264,7 @@ int ParseListCommand::execute(){ if (m->control_pressed) { delete input; delete groupMap; for (i=0; inamesOfGroups.size(); i++) { (*(filehandles[groupMap->namesOfGroups[i]])).close(); delete filehandles[groupMap->namesOfGroups[i]]; } - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); return 0; } @@ -289,7 +289,7 @@ int ParseListCommand::execute(){ delete input; if (m->control_pressed) { - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); return 0; } diff --git a/parsimony.cpp b/parsimony.cpp index 54a3ffd..6ec6c57 100644 --- a/parsimony.cpp +++ b/parsimony.cpp @@ -155,7 +155,7 @@ EstOutput Parsimony::createProcesses(Tree* t, vector< vector > namesOfGr m->gobble(in); } in.close(); - remove(s.c_str()); + m->mothurRemove(s); } return results; diff --git a/parsimonycommand.cpp b/parsimonycommand.cpp index 6e69cad..ff12092 100644 --- a/parsimonycommand.cpp +++ b/parsimonycommand.cpp @@ -241,7 +241,7 @@ int ParsimonyCommand::execute() { if (m->control_pressed) { delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; } - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); m->Groups.clear(); return 0; } @@ -296,7 +296,7 @@ int ParsimonyCommand::execute() { delete reading; delete pars; delete output; delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; } if (randomtree == "") { outSum.close(); } - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); m->Groups.clear(); return 0; } @@ -321,7 +321,7 @@ int ParsimonyCommand::execute() { delete reading; delete pars; delete output; delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; } if (randomtree == "") { outSum.close(); } - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); m->Groups.clear(); return 0; } @@ -359,7 +359,7 @@ int ParsimonyCommand::execute() { if (m->control_pressed) { delete reading; delete pars; delete output; delete randT; if (randomtree == "") { outSum.close(); } - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; } m->Groups.clear(); return 0; @@ -397,7 +397,7 @@ int ParsimonyCommand::execute() { if (m->control_pressed) { delete reading; delete pars; delete output; delete randT; delete tmap; - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); m->Groups.clear(); return 0; } @@ -409,7 +409,7 @@ int ParsimonyCommand::execute() { if (m->control_pressed) { delete reading; delete pars; delete output; delete randT; delete tmap; - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); m->Groups.clear(); return 0; } @@ -466,7 +466,7 @@ int ParsimonyCommand::execute() { delete reading; delete pars; delete output; delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; } if (randomtree == "") { outSum.close(); } - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); m->Groups.clear(); return 0; } @@ -485,7 +485,7 @@ int ParsimonyCommand::execute() { delete pars; delete output; delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; } - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); return 0;} + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); return 0;} m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); diff --git a/pcacommand.cpp b/pcacommand.cpp index 8dee743..3a92fa0 100644 --- a/pcacommand.cpp +++ b/pcacommand.cpp @@ -203,7 +203,7 @@ int PCACommand::execute(){ //as long as you are not at the end of the file or done wih the lines you want while((lookupFloat[0] != NULL) && (userLabels.size() != 0)) { - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } delete input; for (int i = 0; i < lookupFloat.size(); i++) { delete lookupFloat[i]; } lookupFloat.clear(); return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } delete input; for (int i = 0; i < lookupFloat.size(); i++) { delete lookupFloat[i]; } lookupFloat.clear(); return 0; } if(labels.count(lookupFloat[0]->getLabel()) == 1){ processedLabels.insert(lookupFloat[0]->getLabel()); @@ -236,7 +236,7 @@ int PCACommand::execute(){ } - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } delete input; for (int i = 0; i < lookupFloat.size(); i++) { delete lookupFloat[i]; } lookupFloat.clear(); return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } delete input; for (int i = 0; i < lookupFloat.size(); i++) { delete lookupFloat[i]; } lookupFloat.clear(); return 0; } //output error messages about any remaining user labels set::iterator it; @@ -264,7 +264,7 @@ int PCACommand::execute(){ for (int i = 0; i < lookupFloat.size(); i++) { if (lookupFloat[i] != NULL) { delete lookupFloat[i]; } } lookupFloat.clear(); delete input; - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); @@ -375,13 +375,13 @@ int PCACommand::process(vector& lookupFloat){ vector< vector > PCAEuclidDists = linearCalc.calculateEuclidianDistance(X, i); //G is the pca file - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } double corr = linearCalc.calcPearson(PCAEuclidDists, observedEuclideanDistance); m->mothurOut("Rsq " + toString(i) + " axis: " + toString(corr * corr)); m->mothurOutEndLine(); - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } } } diff --git a/pcoacommand.cpp b/pcoacommand.cpp index 20e8e1b..02e165e 100644 --- a/pcoacommand.cpp +++ b/pcoacommand.cpp @@ -172,7 +172,7 @@ int PCOACommand::execute(){ output(fbase, names, G, d); - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } if (metric) { @@ -180,13 +180,13 @@ int PCOACommand::execute(){ vector< vector > EuclidDists = linearCalc.calculateEuclidianDistance(G, i); //G is the pcoa file - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } double corr = linearCalc.calcPearson(EuclidDists, D); //G is the pcoa file, D is the users distance matrix m->mothurOut("Rsq " + toString(i) + " axis: " + toString(corr * corr)); m->mothurOutEndLine(); - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } } } diff --git a/phylodiversitycommand.cpp b/phylodiversitycommand.cpp index abb1243..d273e1d 100644 --- a/phylodiversitycommand.cpp +++ b/phylodiversitycommand.cpp @@ -257,7 +257,7 @@ int PhyloDiversityCommand::execute(){ if (m->control_pressed) { delete tmap; for (int i = 0; i < trees.size(); i++) { delete trees[i]; } - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); m->Groups.clear(); return 0; } @@ -288,7 +288,7 @@ int PhyloDiversityCommand::execute(){ //for each of the users trees for(int i = 0; i < trees.size(); i++) { - if (m->control_pressed) { delete tmap; for (int j = 0; j < trees.size(); j++) { delete trees[j]; } for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } return 0; } + if (m->control_pressed) { delete tmap; for (int j = 0; j < trees.size(); j++) { delete trees[j]; } for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } return 0; } ofstream outSum, outRare, outCollect; string outSumFile = outputDir + m->getRootName(m->getSimpleName(treefile)) + toString(i+1) + ".phylodiv.summary"; @@ -377,7 +377,7 @@ int PhyloDiversityCommand::execute(){ } - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); @@ -467,7 +467,7 @@ int PhyloDiversityCommand::createProcesses(vector& procIters, Tree* t, map< } in.close(); - remove(inTemp.c_str()); + m->mothurRemove(inTemp); } #endif diff --git a/phylosummary.cpp b/phylosummary.cpp index 26ae3a8..873e5d1 100644 --- a/phylosummary.cpp +++ b/phylosummary.cpp @@ -343,7 +343,7 @@ void PhyloSummary::print(ofstream& out){ try { if (ignore) { assignRank(0); } - + //print labels out << "taxlevel\t rankID\t taxon\t daughterlevels\t total\t"; if (groupmap != NULL) { @@ -412,6 +412,7 @@ void PhyloSummary::print(int i, ofstream& out){ for (int i = 0; i < groupmap->namesOfGroups.size(); i++) { out << tree[it->second].groupCount[groupmap->namesOfGroups[i]] << '\t'; } } out << endl; + } print(it->second, out); diff --git a/phylotypecommand.cpp b/phylotypecommand.cpp index ef23375..e6dace8 100644 --- a/phylotypecommand.cpp +++ b/phylotypecommand.cpp @@ -215,7 +215,7 @@ int PhylotypeCommand::execute(){ if (m->control_pressed) { outRabund.close(); outSabund.close(); outList.close(); - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } delete tree; return 0; } @@ -286,7 +286,7 @@ int PhylotypeCommand::execute(){ delete tree; if (m->control_pressed) { - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } diff --git a/pintail.cpp b/pintail.cpp index f793535..f6e7aa5 100644 --- a/pintail.cpp +++ b/pintail.cpp @@ -612,7 +612,7 @@ void Pintail::createProcessesQuan() { } in.close(); - remove(s.c_str()); + m->mothurRemove(s); } #else diff --git a/preclustercommand.cpp b/preclustercommand.cpp index f13b29c..3f6e0c9 100644 --- a/preclustercommand.cpp +++ b/preclustercommand.cpp @@ -226,7 +226,7 @@ int PreClusterCommand::execute(){ m->mothurOut("It took " + toString(time(NULL) - start) + " secs to cluster " + toString(numSeqs) + " sequences."); m->mothurOutEndLine(); - if (m->control_pressed) { remove(newFastaFile.c_str()); remove(newNamesFile.c_str()); return 0; } + if (m->control_pressed) { m->mothurRemove(newFastaFile); m->mothurRemove(newNamesFile); return 0; } m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); diff --git a/qualityscores.cpp b/qualityscores.cpp index b23ee19..5b64b13 100644 --- a/qualityscores.cpp +++ b/qualityscores.cpp @@ -36,7 +36,7 @@ QualityScores::QualityScores(ifstream& qFile){ qFile >> seqName; m->getline(qFile); - + //cout << seqName << endl; if (seqName == "") { m->mothurOut("Error reading quality file, name blank at position, " + toString(qFile.tellg())); m->mothurOutEndLine(); @@ -46,16 +46,26 @@ QualityScores::QualityScores(ifstream& qFile){ } string qScoreString = m->getline(qFile); + //cout << qScoreString << endl; while(qFile.peek() != '>' && qFile.peek() != EOF){ - qScoreString += ' ' + m->getline(qFile); + if (m->control_pressed) { break; } + string temp = m->getline(qFile); + //cout << temp << endl; + qScoreString += ' ' + temp; } - + //cout << "done reading " << endl; istringstream qScoreStringStream(qScoreString); int count = 0; while(!qScoreStringStream.eof()){ if (m->control_pressed) { break; } - qScoreStringStream >> score; m->gobble(qScoreStringStream); - + string temp; + qScoreStringStream >> temp; m->gobble(qScoreStringStream); + + //check temp to make sure its a number + if (!m->isContainingOnlyDigits(temp)) { m->mothurOut("[ERROR]: In sequence " + seqName + "'s quality scores, expected a number and got " + temp + ", setting score to 0."); m->mothurOutEndLine(); temp = "0"; } + convert(temp, score); + + //cout << count << '\t' << score << endl; qScores.push_back(score); count++; } @@ -104,7 +114,7 @@ QualityScores::QualityScores(ifstream& qFile){ // qScores.pop_back(); seqLength = qScores.size(); - //cout << "seqlenght = " << seqLength << '\t' << count << endl; + //cout << "seqlength = " << seqLength << '\t' << count << endl; } catch(exception& e) { diff --git a/rarefact.cpp b/rarefact.cpp index d8a6b5c..ca105b7 100644 --- a/rarefact.cpp +++ b/rarefact.cpp @@ -157,7 +157,7 @@ int Rarefact::createProcesses(vector& procIters, RarefactionCurveData* rcd, for(int j=0;jinputTempFiles(s); - remove(s.c_str()); + m->mothurRemove(s); } } diff --git a/rarefactcommand.cpp b/rarefactcommand.cpp index b9007f4..8221114 100644 --- a/rarefactcommand.cpp +++ b/rarefactcommand.cpp @@ -286,7 +286,7 @@ int RareFactCommand::execute(){ string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(inputFileNames[p])); - if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } m->Groups.clear(); return 0; } + if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } m->Groups.clear(); return 0; } if (inputFileNames.size() > 1) { m->mothurOutEndLine(); m->mothurOut("Processing group " + groups[p]); m->mothurOutEndLine(); m->mothurOutEndLine(); @@ -360,12 +360,12 @@ int RareFactCommand::execute(){ set processedLabels; set userLabels = labels; - if (m->control_pressed) { for(int i=0;icontrol_pressed) { for(int i=0;imothurRemove(outputNames[i]); } return 0; } //as long as you are not at the end of the file or done wih the lines you want while((order != NULL) && ((allLines == 1) || (userLabels.size() != 0))) { - if (m->control_pressed) { for(int i=0;icontrol_pressed) { for(int i=0;imothurRemove(outputNames[i]); } return 0; } if(allLines == 1 || labels.count(order->getLabel()) == 1){ @@ -403,7 +403,7 @@ int RareFactCommand::execute(){ order = (input->getOrderVector()); } - if (m->control_pressed) { for(int i=0;icontrol_pressed) { for(int i=0;imothurRemove(outputNames[i]); } return 0; } //output error messages about any remaining user labels set::iterator it; @@ -418,7 +418,7 @@ int RareFactCommand::execute(){ } } - if (m->control_pressed) { for(int i=0;icontrol_pressed) { for(int i=0;imothurRemove(outputNames[i]); } return 0; } //run last label if you need to if (needToRun == true) { @@ -440,7 +440,7 @@ int RareFactCommand::execute(){ } - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); @@ -469,7 +469,7 @@ vector RareFactCommand::parseSharedFile(string filename) { //clears file before we start to write to it below for (int i=0; igetGroup() + ".rabund").c_str()); + m->mothurRemove((sharedFileRoot + lookup[i]->getGroup() + ".rabund")); filenames.push_back((sharedFileRoot + lookup[i]->getGroup() + ".rabund")); } diff --git a/rarefactsharedcommand.cpp b/rarefactsharedcommand.cpp index 717fec2..02f434a 100644 --- a/rarefactsharedcommand.cpp +++ b/rarefactsharedcommand.cpp @@ -214,7 +214,7 @@ int RareFactSharedCommand::execute(){ m->Groups.clear(); delete input; for(int i=0;imothurRemove(outputNames[i]); } for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } return 0; } @@ -236,7 +236,7 @@ int RareFactSharedCommand::execute(){ m->Groups.clear(); delete input; for(int i=0;imothurRemove(outputNames[i]); } for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } return 0; } @@ -281,7 +281,7 @@ int RareFactSharedCommand::execute(){ m->Groups.clear(); delete input; for(int i=0;imothurRemove(outputNames[i]); } return 0; } @@ -302,7 +302,7 @@ int RareFactSharedCommand::execute(){ m->Groups.clear(); delete input; for(int i=0;imothurRemove(outputNames[i]); } return 0; } @@ -322,7 +322,7 @@ int RareFactSharedCommand::execute(){ m->Groups.clear(); delete input; - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); diff --git a/readblast.cpp b/readblast.cpp index 66f1db2..2d49477 100644 --- a/readblast.cpp +++ b/readblast.cpp @@ -66,7 +66,7 @@ int ReadBlast::read(NameAssignment* nameMap) { if (m->control_pressed) { fileHandle.close(); if (!hclusterWanted) { delete matrix; } - else { outOverlap.close(); remove(overlapFile.c_str()); outDist.close(); remove(distFile.c_str()); } + else { outOverlap.close(); m->mothurRemove(overlapFile); outDist.close(); m->mothurRemove(distFile); } return 0; } @@ -117,7 +117,7 @@ int ReadBlast::read(NameAssignment* nameMap) { if (m->control_pressed) { fileHandle.close(); if (!hclusterWanted) { delete matrix; } - else { outOverlap.close(); remove(overlapFile.c_str()); outDist.close(); remove(distFile.c_str()); } + else { outOverlap.close(); m->mothurRemove(overlapFile); outDist.close(); m->mothurRemove(distFile); } delete reading; return 0; } @@ -271,7 +271,7 @@ int ReadBlast::read(NameAssignment* nameMap) { if (m->control_pressed) { fileHandle.close(); if (!hclusterWanted) { delete matrix; } - else { outOverlap.close(); remove(overlapFile.c_str()); outDist.close(); remove(distFile.c_str()); } + else { outOverlap.close(); m->mothurRemove(overlapFile); outDist.close(); m->mothurRemove(distFile); } delete reading; return 0; } @@ -286,7 +286,7 @@ int ReadBlast::read(NameAssignment* nameMap) { if (m->control_pressed) { fileHandle.close(); if (!hclusterWanted) { delete matrix; } - else { remove(overlapFile.c_str()); remove(distFile.c_str()); } + else { m->mothurRemove(overlapFile); m->mothurRemove(distFile); } delete reading; return 0; } diff --git a/readcluster.cpp b/readcluster.cpp index d822710..b6cb71d 100644 --- a/readcluster.cpp +++ b/readcluster.cpp @@ -109,7 +109,7 @@ int ReadCluster::convertPhylip2Column(NameAssignment*& nameMap){ for(int j=0;jcontrol_pressed) { in.close(); out.close(); remove(tempFile.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(tempFile); return 0; } in >> distance; @@ -126,7 +126,7 @@ int ReadCluster::convertPhylip2Column(NameAssignment*& nameMap){ for(int j=0;jcontrol_pressed) { in.close(); out.close(); remove(tempFile.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(tempFile); return 0; } in >> distance; @@ -148,7 +148,7 @@ int ReadCluster::convertPhylip2Column(NameAssignment*& nameMap){ if(nameMap == NULL){ list->set(i, name); for(int j=0;jcontrol_pressed) { in.close(); out.close(); remove(tempFile.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(tempFile); return 0; } in >> distance; @@ -163,7 +163,7 @@ int ReadCluster::convertPhylip2Column(NameAssignment*& nameMap){ if(nameMap->count(name)==0){ m->mothurOut("Error: Sequence '" + name + "' was not found in the names file, please correct"); m->mothurOutEndLine(); } for(int j=0;jcontrol_pressed) { in.close(); out.close(); remove(tempFile.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(tempFile); return 0; } in >> distance; @@ -201,7 +201,7 @@ int ReadCluster::convertPhylip2Column(NameAssignment*& nameMap){ float dist; while (in2) { - if (m->control_pressed) { in2.close(); out2.close(); remove(tempFile.c_str()); remove(outputFile.c_str()); return 0; } + if (m->control_pressed) { in2.close(); out2.close(); m->mothurRemove(tempFile); m->mothurRemove(outputFile); return 0; } in2 >> first >> second >> dist; out2 << rowToName[first] << '\t' << rowToName[second] << '\t' << dist << endl; @@ -210,10 +210,10 @@ int ReadCluster::convertPhylip2Column(NameAssignment*& nameMap){ in2.close(); out2.close(); - remove(tempFile.c_str()); + m->mothurRemove(tempFile); distFile = outputFile; - if (m->control_pressed) { remove(outputFile.c_str()); } + if (m->control_pressed) { m->mothurRemove(outputFile); } return 0; } diff --git a/readdistcommand.cpp b/readdistcommand.cpp index 8dadc7e..788bdcb 100644 --- a/readdistcommand.cpp +++ b/readdistcommand.cpp @@ -197,7 +197,7 @@ int ReadDistCommand::execute(){ m->openOutputFile(newGroupFile, outGroups); for (int i = 0; i < matrix->getNumSeqs(); i++) { - if (m->control_pressed) { delete groupMap; delete matrix; outGroups.close(); remove(newGroupFile.c_str()); return 0; } + if (m->control_pressed) { delete groupMap; delete matrix; outGroups.close(); m->mothurRemove(newGroupFile); return 0; } Names temp = matrix->getRowInfo(i); outGroups << temp.seqName << '\t' << temp.groupName << endl; @@ -214,7 +214,7 @@ int ReadDistCommand::execute(){ groupMap = new GroupMap(groupfile); groupMap->readMap(); - if (m->control_pressed) { delete groupMap; delete matrix; remove(newGroupFile.c_str()); return 0; } + if (m->control_pressed) { delete groupMap; delete matrix; m->mothurRemove(newGroupFile); return 0; } globaldata->gGroupmap = groupMap; } diff --git a/removegroupscommand.cpp b/removegroupscommand.cpp index 9b53728..c9908fb 100644 --- a/removegroupscommand.cpp +++ b/removegroupscommand.cpp @@ -245,7 +245,7 @@ int RemoveGroupsCommand::execute(){ if (listfile != "") { readList(); } if (taxfile != "") { readTax(); } - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } m->mothurOut("Removed " + toString(names.size()) + " sequences. From the groups: "); m->mothurOutEndLine(); for (int i = 0; i < Groups.size(); i++) { m->mothurOut(Groups[i]); m->mothurOut("\t" + toString(groupMap->getNumSeqs(Groups[i]))); m->mothurOutEndLine(); } @@ -311,7 +311,7 @@ int RemoveGroupsCommand::readFasta(){ bool wroteSomething = false; while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } Sequence currSeq(in); name = currSeq.getName(); @@ -366,7 +366,7 @@ int RemoveGroupsCommand::readList(){ //for each bin for (int i = 0; i < list.getNumBins(); i++) { - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } //parse out names that are in accnos file string binnames = list.get(i); @@ -429,7 +429,7 @@ int RemoveGroupsCommand::readName(){ bool wroteSomething = false; while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } in >> firstCol; m->gobble(in); in >> secondCol; @@ -505,7 +505,7 @@ int RemoveGroupsCommand::readGroup(){ bool wroteSomething = false; while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } in >> name; //read from first column in >> group; //read from second column @@ -547,7 +547,7 @@ int RemoveGroupsCommand::readTax(){ bool wroteSomething = false; while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } in >> name; //read from first column in >> tax; //read from second column diff --git a/removelineagecommand.cpp b/removelineagecommand.cpp index d1db13f..b72f4b6 100644 --- a/removelineagecommand.cpp +++ b/removelineagecommand.cpp @@ -247,7 +247,7 @@ int RemoveLineageCommand::execute(){ if (listfile != "") { readList(); } - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } if (outputNames.size() != 0) { m->mothurOutEndLine(); @@ -309,7 +309,7 @@ int RemoveLineageCommand::readFasta(){ bool wroteSomething = false; while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } Sequence currSeq(in); name = currSeq.getName(); @@ -363,7 +363,7 @@ int RemoveLineageCommand::readList(){ //for each bin for (int i = 0; i < list.getNumBins(); i++) { - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } //parse out names that are in accnos file string binnames = list.get(i); @@ -426,7 +426,7 @@ int RemoveLineageCommand::readName(){ bool wroteSomething = false; while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } in >> firstCol; in >> secondCol; @@ -504,7 +504,7 @@ int RemoveLineageCommand::readGroup(){ bool wroteSomething = false; while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } in >> name; //read from first column in >> group; //read from second column @@ -562,7 +562,7 @@ int RemoveLineageCommand::readTax(){ while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } in >> name; //read from first column in >> tax; //read from second column @@ -774,7 +774,7 @@ int RemoveLineageCommand::readAlign(){ out << endl; while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } in >> name; //read from first column diff --git a/removeotuscommand.cpp b/removeotuscommand.cpp index 0fbed18..3390c20 100644 --- a/removeotuscommand.cpp +++ b/removeotuscommand.cpp @@ -195,7 +195,7 @@ int RemoveOtusCommand::execute(){ //read through the list file keeping any otus that contain any sequence from the groups selected readListGroup(); - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } if (outputNames.size() != 0) { m->mothurOutEndLine(); @@ -258,7 +258,7 @@ int RemoveOtusCommand::readListGroup(){ //as long as you are not at the end of the file or done wih the lines you want while((list != NULL) && (userLabels.size() != 0)) { - if (m->control_pressed) { delete list; delete input; out.close(); outGroup.close(); remove(outputFileName.c_str()); remove(outputGroupFileName.c_str());return 0; } + if (m->control_pressed) { delete list; delete input; out.close(); outGroup.close(); m->mothurRemove(outputFileName); m->mothurRemove(outputGroupFileName);return 0; } if(labels.count(list->getLabel()) == 1){ processList(list, groupMap, out, outGroup, wroteSomething); @@ -292,7 +292,7 @@ int RemoveOtusCommand::readListGroup(){ } - if (m->control_pressed) { if (list != NULL) { delete list; } delete input; out.close(); outGroup.close(); remove(outputFileName.c_str()); remove(outputGroupFileName.c_str()); return 0; } + if (m->control_pressed) { if (list != NULL) { delete list; } delete input; out.close(); outGroup.close(); m->mothurRemove(outputFileName); m->mothurRemove(outputGroupFileName); return 0; } //output error messages about any remaining user labels set::iterator it; diff --git a/removerarecommand.cpp b/removerarecommand.cpp index c320fa4..f82c4b0 100644 --- a/removerarecommand.cpp +++ b/removerarecommand.cpp @@ -251,7 +251,7 @@ int RemoveRareCommand::execute(){ if (listfile != "") { processList(); } if (sharedfile != "") { processShared(); } - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } if (outputNames.size() != 0) { m->mothurOutEndLine(); @@ -365,7 +365,7 @@ int RemoveRareCommand::processList(){ //for each bin for (int i = 0; i < list->getNumBins(); i++) { - if (m->control_pressed) { if (groupfile != "") { delete groupMap; outGroup.close(); remove(outputGroupFileName.c_str()); } out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { if (groupfile != "") { delete groupMap; outGroup.close(); m->mothurRemove(outputGroupFileName); } out.close(); m->mothurRemove(outputFileName); return 0; } //parse out names that are in accnos file string binnames = list->get(i); diff --git a/removeseqscommand.cpp b/removeseqscommand.cpp index b8bb464..abd3c23 100644 --- a/removeseqscommand.cpp +++ b/removeseqscommand.cpp @@ -266,10 +266,8 @@ int RemoveSeqsCommand::execute(){ if (taxfile != "") { readTax(); } if (qualfile != "") { readQual(); } - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } - - m->mothurOut("Removed " + toString(names.size()) + " sequences."); m->mothurOutEndLine(); - + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } + if (outputNames.size() != 0) { m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); @@ -333,9 +331,10 @@ int RemoveSeqsCommand::readFasta(){ string name; bool wroteSomething = false; + int removedCount = 0; while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } Sequence currSeq(in); name = currSeq.getName(); @@ -346,7 +345,7 @@ int RemoveSeqsCommand::readFasta(){ wroteSomething = true; currSeq.printSequence(out); - } + }else { removedCount++; } } m->gobble(in); } @@ -356,6 +355,8 @@ int RemoveSeqsCommand::readFasta(){ if (wroteSomething == false) { m->mothurOut("Your file contains only sequences from the .accnos file."); m->mothurOutEndLine(); } outputTypes["fasta"].push_back(outputFileName); outputNames.push_back(outputFileName); + m->mothurOut("Removed " + toString(removedCount) + " sequences from your fasta file."); m->mothurOutEndLine(); + return 0; } @@ -379,6 +380,7 @@ int RemoveSeqsCommand::readQual(){ string name; bool wroteSomething = false; + int removedCount = 0; while(!in.eof()){ @@ -410,7 +412,7 @@ int RemoveSeqsCommand::readQual(){ wroteSomething = true; out << name << endl << scores; - } + }else { removedCount++; } m->gobble(in); } @@ -421,6 +423,8 @@ int RemoveSeqsCommand::readQual(){ if (wroteSomething == false) { m->mothurOut("Your file contains only sequences from the .accnos file."); m->mothurOutEndLine(); } outputNames.push_back(outputFileName); outputTypes["qfile"].push_back(outputFileName); + m->mothurOut("Removed " + toString(removedCount) + " sequences from your quality file."); m->mothurOutEndLine(); + return 0; } @@ -443,6 +447,7 @@ int RemoveSeqsCommand::readList(){ m->openInputFile(listfile, in); bool wroteSomething = false; + int removedCount = 0; while(!in.eof()){ //read in list vector @@ -454,7 +459,7 @@ int RemoveSeqsCommand::readList(){ //for each bin for (int i = 0; i < list.getNumBins(); i++) { - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } //parse out names that are in accnos file string binnames = list.get(i); @@ -466,10 +471,12 @@ int RemoveSeqsCommand::readList(){ //if that name is in the .accnos file, add it if (names.count(name) == 0) { newNames += name + ","; } + else { removedCount++; } } //get last name if (names.count(binnames) == 0) { newNames += binnames + ","; } + else { removedCount++; } //if there are names in this bin add to new list if (newNames != "") { @@ -491,7 +498,9 @@ int RemoveSeqsCommand::readList(){ if (wroteSomething == false) { m->mothurOut("Your file contains only sequences from the .accnos file."); m->mothurOutEndLine(); } outputTypes["list"].push_back(outputFileName); outputNames.push_back(outputFileName); - + + m->mothurOut("Removed " + toString(removedCount) + " sequences from your list file."); m->mothurOutEndLine(); + return 0; } @@ -515,10 +524,10 @@ int RemoveSeqsCommand::readName(){ string name, firstCol, secondCol; bool wroteSomething = false; - + int removedCount = 0; while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } in >> firstCol; m->gobble(in); in >> secondCol; @@ -535,7 +544,9 @@ int RemoveSeqsCommand::readName(){ if ((dups) && (validSecond.size() != parsedNames.size())) { //if dups is true and we want to get rid of anyone, get rid of everyone for (int i = 0; i < parsedNames.size(); i++) { names.insert(parsedNames[i]); } + removedCount += parsedNames.size(); }else { + removedCount += parsedNames.size()-validSecond.size(); //if the name in the first column is in the set then print it and any other names in second column also in set if (names.count(firstCol) == 0) { @@ -571,6 +582,8 @@ int RemoveSeqsCommand::readName(){ if (wroteSomething == false) { m->mothurOut("Your file contains only sequences from the .accnos file."); m->mothurOutEndLine(); } outputTypes["name"].push_back(outputFileName); outputNames.push_back(outputFileName); + m->mothurOut("Removed " + toString(removedCount) + " sequences from your name file."); m->mothurOutEndLine(); + return 0; } catch(exception& e) { @@ -594,9 +607,10 @@ int RemoveSeqsCommand::readGroup(){ string name, group; bool wroteSomething = false; + int removedCount = 0; while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } in >> name; //read from first column in >> group; //read from second column @@ -605,7 +619,7 @@ int RemoveSeqsCommand::readGroup(){ if (names.count(name) == 0) { wroteSomething = true; out << name << '\t' << group << endl; - } + }else { removedCount++; } m->gobble(in); } @@ -615,6 +629,9 @@ int RemoveSeqsCommand::readGroup(){ if (wroteSomething == false) { m->mothurOut("Your file contains only sequences from the .accnos file."); m->mothurOutEndLine(); } outputTypes["group"].push_back(outputFileName); outputNames.push_back(outputFileName); + m->mothurOut("Removed " + toString(removedCount) + " sequences from your group file."); m->mothurOutEndLine(); + + return 0; } catch(exception& e) { @@ -636,9 +653,10 @@ int RemoveSeqsCommand::readTax(){ string name, tax; bool wroteSomething = false; + int removedCount = 0; while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } in >> name; //read from first column in >> tax; //read from second column @@ -647,7 +665,7 @@ int RemoveSeqsCommand::readTax(){ if (names.count(name) == 0) { wroteSomething = true; out << name << '\t' << tax << endl; - } + }else { removedCount++; } m->gobble(in); } @@ -657,6 +675,8 @@ int RemoveSeqsCommand::readTax(){ if (wroteSomething == false) { m->mothurOut("Your file contains only sequences from the .accnos file."); m->mothurOutEndLine(); } outputTypes["taxonomy"].push_back(outputFileName); outputNames.push_back(outputFileName); + m->mothurOut("Removed " + toString(removedCount) + " sequences from your taxonomy file."); m->mothurOutEndLine(); + return 0; } catch(exception& e) { @@ -680,6 +700,7 @@ int RemoveSeqsCommand::readAlign(){ string name, junk; bool wroteSomething = false; + int removedCount = 0; //read column headers for (int i = 0; i < 16; i++) { @@ -689,7 +710,7 @@ int RemoveSeqsCommand::readAlign(){ out << endl; while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } in >> name; //read from first column @@ -707,6 +728,7 @@ int RemoveSeqsCommand::readAlign(){ out << endl; }else {//still read just don't do anything with it + removedCount++; //read rest for (int i = 0; i < 15; i++) { @@ -723,6 +745,9 @@ int RemoveSeqsCommand::readAlign(){ if (wroteSomething == false) { m->mothurOut("Your file contains only sequences from the .accnos file."); m->mothurOutEndLine(); } outputTypes["alignreport"].push_back(outputFileName); outputNames.push_back(outputFileName); + m->mothurOut("Removed " + toString(removedCount) + " sequences from your alignreport file."); m->mothurOutEndLine(); + + return 0; } diff --git a/reversecommand.cpp b/reversecommand.cpp index ea2ddeb..c664ad7 100644 --- a/reversecommand.cpp +++ b/reversecommand.cpp @@ -166,7 +166,7 @@ int ReverseSeqsCommand::execute(){ m->openOutputFile(fastaReverseFileName, outFASTA); while(!inFASTA.eof()){ - if (m->control_pressed) { inFASTA.close(); outFASTA.close(); remove(fastaReverseFileName.c_str()); return 0; } + if (m->control_pressed) { inFASTA.close(); outFASTA.close(); m->mothurRemove(fastaReverseFileName); return 0; } Sequence currSeq(inFASTA); m->gobble(inFASTA); if (currSeq.getName() != "") { @@ -194,7 +194,7 @@ int ReverseSeqsCommand::execute(){ m->openOutputFile(qualReverseFileName, outQual); while(!inQual.eof()){ - if (m->control_pressed) { inQual.close(); outQual.close(); remove(qualReverseFileName.c_str()); return 0; } + if (m->control_pressed) { inQual.close(); outQual.close(); m->mothurRemove(qualReverseFileName); return 0; } currQual = QualityScores(inQual); m->gobble(inQual); currQual.flipQScores(); currQual.printQScores(outQual); @@ -204,7 +204,7 @@ int ReverseSeqsCommand::execute(){ outputNames.push_back(qualReverseFileName); outputTypes["qfile"].push_back(qualReverseFileName); } - if (m->control_pressed) { remove(qualReverseFileName.c_str()); remove(fastaReverseFileName.c_str()); return 0; } + if (m->control_pressed) { m->mothurRemove(qualReverseFileName); m->mothurRemove(fastaReverseFileName); return 0; } //set fasta file as new current fastafile string current = ""; diff --git a/screenseqscommand.cpp b/screenseqscommand.cpp index 9f7aa40..f751525 100644 --- a/screenseqscommand.cpp +++ b/screenseqscommand.cpp @@ -394,7 +394,7 @@ int ScreenSeqsCommand::execute(){ if(processors == 1){ numFastaSeqs = driver(lines[0], goodSeqFile, badAccnosFile, fastafile, badSeqNames); - if (m->control_pressed) { remove(goodSeqFile.c_str()); return 0; } + if (m->control_pressed) { m->mothurRemove(goodSeqFile); return 0; } }else{ processIDS.resize(0); @@ -407,13 +407,13 @@ int ScreenSeqsCommand::execute(){ //append alignment and report files for(int i=1;iappendFiles((goodSeqFile + toString(processIDS[i]) + ".temp"), goodSeqFile); - remove((goodSeqFile + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((goodSeqFile + toString(processIDS[i]) + ".temp")); m->appendFiles((badAccnosFile + toString(processIDS[i]) + ".temp"), badAccnosFile); - remove((badAccnosFile + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((badAccnosFile + toString(processIDS[i]) + ".temp")); } - if (m->control_pressed) { remove(goodSeqFile.c_str()); return 0; } + if (m->control_pressed) { m->mothurRemove(goodSeqFile); return 0; } //read badSeqs in because root process doesnt know what other "bad" seqs the children found ifstream inBad; @@ -432,7 +432,7 @@ int ScreenSeqsCommand::execute(){ #else numFastaSeqs = driver(lines[0], goodSeqFile, badAccnosFile, fastafile, badSeqNames); - if (m->control_pressed) { remove(goodSeqFile.c_str()); return 0; } + if (m->control_pressed) { m->mothurRemove(goodSeqFile); return 0; } #endif @@ -473,18 +473,18 @@ int ScreenSeqsCommand::execute(){ if(namefile != "" && groupfile != "") { screenNameGroupFile(badSeqNames); - if (m->control_pressed) { remove(goodSeqFile.c_str()); return 0; } + if (m->control_pressed) { m->mothurRemove(goodSeqFile); return 0; } }else if(namefile != "") { screenNameGroupFile(badSeqNames); - if (m->control_pressed) { remove(goodSeqFile.c_str()); return 0; } + if (m->control_pressed) { m->mothurRemove(goodSeqFile); return 0; } }else if(groupfile != "") { screenGroupFile(badSeqNames); } // this screens just the group - if (m->control_pressed) { remove(goodSeqFile.c_str()); return 0; } + if (m->control_pressed) { m->mothurRemove(goodSeqFile); return 0; } if(alignreport != "") { screenAlignReport(badSeqNames); } if(qualfile != "") { screenQual(badSeqNames); } - if (m->control_pressed) { remove(goodSeqFile.c_str()); return 0; } + if (m->control_pressed) { m->mothurRemove(goodSeqFile); return 0; } #ifdef USE_MPI } @@ -547,7 +547,7 @@ int ScreenSeqsCommand::screenNameGroupFile(set badSeqNames){ ofstream goodNameOut; m->openOutputFile(goodNameFile, goodNameOut); while(!inputNames.eof()){ - if (m->control_pressed) { goodNameOut.close(); inputNames.close(); remove(goodNameFile.c_str()); return 0; } + if (m->control_pressed) { goodNameOut.close(); inputNames.close(); m->mothurRemove(goodNameFile); return 0; } inputNames >> seqName >> seqList; it = badSeqNames.find(seqName); @@ -593,7 +593,7 @@ int ScreenSeqsCommand::screenNameGroupFile(set badSeqNames){ ofstream goodGroupOut; m->openOutputFile(goodGroupFile, goodGroupOut); while(!inputGroups.eof()){ - if (m->control_pressed) { goodGroupOut.close(); inputGroups.close(); remove(goodNameFile.c_str()); remove(goodGroupFile.c_str()); return 0; } + if (m->control_pressed) { goodGroupOut.close(); inputGroups.close(); m->mothurRemove(goodNameFile); m->mothurRemove(goodGroupFile); return 0; } inputGroups >> seqName >> group; @@ -806,7 +806,7 @@ int ScreenSeqsCommand::createProcessesCreateSummary(vector& startPosition, for (int k = 0; k < tempNum; k++) { in >> temp; longHomoPolymer.push_back(temp); } m->gobble(in); in.close(); - remove(tempFilename.c_str()); + m->mothurRemove(tempFilename); } return num; @@ -832,7 +832,7 @@ int ScreenSeqsCommand::screenGroupFile(set badSeqNames){ ofstream goodGroupOut; m->openOutputFile(goodGroupFile, goodGroupOut); while(!inputGroups.eof()){ - if (m->control_pressed) { goodGroupOut.close(); inputGroups.close(); remove(goodGroupFile.c_str()); return 0; } + if (m->control_pressed) { goodGroupOut.close(); inputGroups.close(); m->mothurRemove(goodGroupFile); return 0; } inputGroups >> seqName >> group; it = badSeqNames.find(seqName); @@ -846,7 +846,7 @@ int ScreenSeqsCommand::screenGroupFile(set badSeqNames){ m->gobble(inputGroups); } - if (m->control_pressed) { goodGroupOut.close(); inputGroups.close(); remove(goodGroupFile.c_str()); return 0; } + if (m->control_pressed) { goodGroupOut.close(); inputGroups.close(); m->mothurRemove(goodGroupFile); return 0; } //we were unable to remove some of the bad sequences if (badSeqNames.size() != 0) { @@ -859,7 +859,7 @@ int ScreenSeqsCommand::screenGroupFile(set badSeqNames){ inputGroups.close(); goodGroupOut.close(); - if (m->control_pressed) { remove(goodGroupFile.c_str()); } + if (m->control_pressed) { m->mothurRemove(goodGroupFile); } return 0; @@ -890,7 +890,7 @@ int ScreenSeqsCommand::screenAlignReport(set badSeqNames){ } while(!inputAlignReport.eof()){ - if (m->control_pressed) { goodAlignReportOut.close(); inputAlignReport.close(); remove(goodAlignReportFile.c_str()); return 0; } + if (m->control_pressed) { goodAlignReportOut.close(); inputAlignReport.close(); m->mothurRemove(goodAlignReportFile); return 0; } inputAlignReport >> seqName; it = badSeqNames.find(seqName); @@ -910,7 +910,7 @@ int ScreenSeqsCommand::screenAlignReport(set badSeqNames){ m->gobble(inputAlignReport); } - if (m->control_pressed) { goodAlignReportOut.close(); inputAlignReport.close(); remove(goodAlignReportFile.c_str()); return 0; } + if (m->control_pressed) { goodAlignReportOut.close(); inputAlignReport.close(); m->mothurRemove(goodAlignReportFile); return 0; } //we were unable to remove some of the bad sequences if (badSeqNames.size() != 0) { @@ -923,7 +923,7 @@ int ScreenSeqsCommand::screenAlignReport(set badSeqNames){ inputAlignReport.close(); goodAlignReportOut.close(); - if (m->control_pressed) { remove(goodAlignReportFile.c_str()); return 0; } + if (m->control_pressed) { m->mothurRemove(goodAlignReportFile); return 0; } return 0; @@ -948,7 +948,7 @@ int ScreenSeqsCommand::screenQual(set badSeqNames){ while(!in.eof()){ - if (m->control_pressed) { goodQual.close(); in.close(); remove(goodQualFile.c_str()); return 0; } + if (m->control_pressed) { goodQual.close(); in.close(); m->mothurRemove(goodQualFile); return 0; } string saveName = ""; string name = ""; @@ -996,7 +996,7 @@ int ScreenSeqsCommand::screenQual(set badSeqNames){ } } - if (m->control_pressed) { remove(goodQualFile.c_str()); return 0; } + if (m->control_pressed) { m->mothurRemove(goodQualFile); return 0; } return 0; @@ -1196,7 +1196,7 @@ int ScreenSeqsCommand::createProcesses(string goodFileName, string badAccnos, st string tempFile = filename + toString(processIDS[i]) + ".num.temp"; m->openInputFile(tempFile, in); if (!in.eof()) { int tempNum = 0; in >> tempNum; num += tempNum; } - in.close(); remove(tempFile.c_str()); + in.close(); m->mothurRemove(tempFile); } return num; diff --git a/secondarystructurecommand.cpp b/secondarystructurecommand.cpp index cc53ee0..fe80b78 100644 --- a/secondarystructurecommand.cpp +++ b/secondarystructurecommand.cpp @@ -183,7 +183,7 @@ int AlignCheckCommand::execute(){ int count = 0; while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outfile.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outfile); return 0; } Sequence seq(in); m->gobble(in); if (seq.getName() != "") { @@ -220,7 +220,7 @@ int AlignCheckCommand::execute(){ in.close(); out.close(); - if (m->control_pressed) { remove(outfile.c_str()); return 0; } + if (m->control_pressed) { m->mothurRemove(outfile); return 0; } sort(pound.begin(), pound.end()); sort(dash.begin(), dash.end()); @@ -238,7 +238,7 @@ int AlignCheckCommand::execute(){ int ptile97_5 = int(size * 0.975); int ptile100 = size - 1; - if (m->control_pressed) { remove(outfile.c_str()); return 0; } + if (m->control_pressed) { m->mothurRemove(outfile); return 0; } m->mothurOutEndLine(); m->mothurOut("\t\tPound\tDash\tPlus\tEqual\tLoop\tTilde\tTotal"); m->mothurOutEndLine(); diff --git a/seqerrorcommand.cpp b/seqerrorcommand.cpp index fc027b9..5c80047 100644 --- a/seqerrorcommand.cpp +++ b/seqerrorcommand.cpp @@ -306,7 +306,7 @@ int SeqErrorCommand::execute(){ printErrorFRFile(errorForward, errorReverse); - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } string errorCountFileName = queryFileName.substr(0,queryFileName.find_last_of('.')) + ".error.count"; ofstream errorCountFile; @@ -321,7 +321,7 @@ int SeqErrorCommand::execute(){ } errorCountFile.close(); - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } printSubMatrix(); @@ -478,11 +478,11 @@ int SeqErrorCommand::createProcesses(string filename, string qFileName, string r m->mothurOut("Appending files from process " + toString(processIDS[i])); m->mothurOutEndLine(); m->appendFiles((summaryFileName + toString(processIDS[i]) + ".temp"), summaryFileName); - remove((summaryFileName + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((summaryFileName + toString(processIDS[i]) + ".temp")); m->appendFiles((errorOutputFileName + toString(processIDS[i]) + ".temp"), errorOutputFileName); - remove((errorOutputFileName + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((errorOutputFileName + toString(processIDS[i]) + ".temp")); m->appendFiles((chimeraOutputFileName + toString(processIDS[i]) + ".temp"), chimeraOutputFileName); - remove((chimeraOutputFileName + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((chimeraOutputFileName + toString(processIDS[i]) + ".temp")); ifstream in; string tempFile = filename + toString(processIDS[i]) + ".info.temp"; @@ -577,7 +577,7 @@ int SeqErrorCommand::createProcesses(string filename, string qFileName, string r } m->gobble(in); - in.close(); remove(tempFile.c_str()); + in.close(); m->mothurRemove(tempFile); } #endif diff --git a/seqsummarycommand.cpp b/seqsummarycommand.cpp index 8c7b9b6..2fbf6d1 100644 --- a/seqsummarycommand.cpp +++ b/seqsummarycommand.cpp @@ -297,7 +297,7 @@ int SeqSummaryCommand::execute(){ //append files for(int i=1;iappendFiles((summaryFile + toString(processIDS[i]) + ".temp"), summaryFile); - remove((summaryFile + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((summaryFile + toString(processIDS[i]) + ".temp")); } } @@ -330,7 +330,7 @@ int SeqSummaryCommand::execute(){ if (startPosition[0] == -1) { startPosition[0] = 0; } if (endPosition[0] == -1) { endPosition[0] = 0; } - if (m->control_pressed) { remove(summaryFile.c_str()); return 0; } + if (m->control_pressed) { m->mothurRemove(summaryFile); return 0; } m->mothurOutEndLine(); m->mothurOut("\t\tStart\tEnd\tNBases\tAmbigs\tPolymer"); m->mothurOutEndLine(); @@ -344,7 +344,7 @@ int SeqSummaryCommand::execute(){ if (namefile == "") { m->mothurOut("# of Seqs:\t" + toString(numSeqs)); m->mothurOutEndLine(); } else { m->mothurOut("# of unique seqs:\t" + toString(numSeqs)); m->mothurOutEndLine(); m->mothurOut("total # of seqs:\t" + toString(startPosition.size())); m->mothurOutEndLine(); } - if (m->control_pressed) { remove(summaryFile.c_str()); return 0; } + if (m->control_pressed) { m->mothurRemove(summaryFile); return 0; } m->mothurOutEndLine(); m->mothurOut("Output File Name: "); m->mothurOutEndLine(); @@ -567,7 +567,7 @@ int SeqSummaryCommand::createProcessesCreateSummary(vector& startPosition, for (int k = 0; k < tempNum; k++) { in >> temp; longHomoPolymer.push_back(temp); } m->gobble(in); in.close(); - remove(tempFilename.c_str()); + m->mothurRemove(tempFilename); } return num; diff --git a/setdircommand.cpp b/setdircommand.cpp index ff1e2fe..0b3379c 100644 --- a/setdircommand.cpp +++ b/setdircommand.cpp @@ -129,7 +129,7 @@ int SetDirectoryCommand::execute(){ m->mothurOut(output + " directory does not exist or is not writable."); m->mothurOutEndLine(); }else{ out.close(); - remove(outTemp.c_str()); + m->mothurRemove(outTemp); m->mothurOut("outputDir=" + output); m->mothurOutEndLine(); commandFactory->setOutputDirectory(output); } @@ -161,7 +161,7 @@ int SetDirectoryCommand::execute(){ m->mothurOut(input + " directory does not exist or is not writable."); m->mothurOutEndLine(); }else{ in.close(); - remove(inTemp.c_str()); + m->mothurRemove(inTemp); m->mothurOut("inputDir=" + input); m->mothurOutEndLine(); commandFactory->setInputDirectory(input); } diff --git a/sffinfocommand.cpp b/sffinfocommand.cpp index 2073282..341dd18 100644 --- a/sffinfocommand.cpp +++ b/sffinfocommand.cpp @@ -303,7 +303,7 @@ int SffInfoCommand::execute(){ for (int s = 0; s < filenames.size(); s++) { - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } int start = time(NULL); @@ -319,7 +319,7 @@ int SffInfoCommand::execute(){ if (sfftxtFilename != "") { parseSffTxt(); } - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } //set fasta file as new current fastafile string current = ""; diff --git a/sharedcommand.cpp b/sharedcommand.cpp index 38bc480..040fad8 100644 --- a/sharedcommand.cpp +++ b/sharedcommand.cpp @@ -219,7 +219,7 @@ int SharedCommand::execute(){ //clears file before we start to write to it below for (int i=0; imothurRemove((fileroot + Groups[i] + ".rabund")); outputNames.push_back((fileroot + Groups[i] + ".rabund")); outputTypes["rabund"].push_back((fileroot + Groups[i] + ".rabund")); } @@ -239,8 +239,8 @@ int SharedCommand::execute(){ if (m->control_pressed) { delete input; delete SharedList; delete groupMap; for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) { delete it3->second; } - out.close(); remove(filename.c_str()); - for (int i=0; imothurRemove(filename); + for (int i=0; imothurRemove((fileroot + Groups[i] + ".rabund")); } return 0; } @@ -248,7 +248,7 @@ int SharedCommand::execute(){ m->mothurOut("Your group file contains " + toString(groupMap->getNumSeqs()) + " sequences and list file contains " + toString(SharedList->getNumSeqs()) + " sequences. Please correct."); m->mothurOutEndLine(); out.close(); - remove(filename.c_str()); //remove blank shared file you made + m->mothurRemove(filename); //remove blank shared file you made createMisMatchFile(); @@ -296,8 +296,8 @@ int SharedCommand::execute(){ if (m->control_pressed) { delete input; delete SharedList; delete groupMap; for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) { delete it3->second; } - out.close(); remove(filename.c_str()); - for (int i=0; imothurRemove(filename); + for (int i=0; imothurRemove((fileroot + Groups[i] + ".rabund")); } return 0; } @@ -314,8 +314,8 @@ int SharedCommand::execute(){ delete input; delete SharedList; delete groupMap; for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) { delete it3->second; } - out.close(); remove(filename.c_str()); - for (int i=0; imothurRemove(filename); + for (int i=0; imothurRemove((fileroot + Groups[i] + ".rabund")); } return 0; } @@ -344,8 +344,8 @@ int SharedCommand::execute(){ delete input; delete SharedList; delete groupMap; for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) { delete it3->second; } - out.close(); remove(filename.c_str()); - for (int i=0; imothurRemove(filename); + for (int i=0; imothurRemove((fileroot + Groups[i] + ".rabund")); } return 0; } @@ -390,8 +390,8 @@ int SharedCommand::execute(){ if (m->control_pressed) { delete input; delete groupMap; for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) { delete it3->second; } - out.close(); remove(filename.c_str()); - for (int i=0; imothurRemove(filename); + for (int i=0; imothurRemove((fileroot + Groups[i] + ".rabund")); } return 0; } @@ -410,8 +410,8 @@ int SharedCommand::execute(){ delete input; delete groupMap; if (m->control_pressed) { - remove(filename.c_str()); - for (int i=0; imothurRemove(filename); + for (int i=0; imothurRemove((fileroot + Groups[i] + ".rabund")); } return 0; } @@ -564,7 +564,7 @@ int SharedCommand::createMisMatchFile() { //go through list and if group returns "not found" output it for (int i = 0; i < SharedList->getNumBins(); i++) { - if (m->control_pressed) { outMisMatch.close(); remove(outputMisMatchName.c_str()); return 0; } + if (m->control_pressed) { outMisMatch.close(); m->mothurRemove(outputMisMatchName); return 0; } string names = SharedList->get(i); @@ -635,7 +635,7 @@ int SharedCommand::createMisMatchFile() { //loop through names in seqNames and if they aren't in namesIn list output them for (int i = 0; i < seqNames.size(); i++) { - if (m->control_pressed) { outMisMatch.close(); remove(outputMisMatchName.c_str()); return 0; } + if (m->control_pressed) { outMisMatch.close(); m->mothurRemove(outputMisMatchName); return 0; } itMatch = namesInList.find(seqNames[i]); diff --git a/shhhercommand.cpp b/shhhercommand.cpp index a6fee2a..5017f88 100644 --- a/shhhercommand.cpp +++ b/shhhercommand.cpp @@ -373,7 +373,7 @@ int ShhherCommand::execute(){ MPI_Recv(&done, 1, MPI_INT, i, tag, MPI_COMM_WORLD, &status); m->appendFiles((distFileName + ".temp." + toString(i)), distFileName); - remove((distFileName + ".temp." + toString(i)).c_str()); + m->mothurRemove((distFileName + ".temp." + toString(i))); } string namesFileName = createNamesFile(); @@ -383,9 +383,9 @@ int ShhherCommand::execute(){ getOTUData(listFileName); - remove(distFileName.c_str()); - remove(namesFileName.c_str()); - remove(listFileName.c_str()); + m->mothurRemove(distFileName); + m->mothurRemove(namesFileName); + m->mothurRemove(listFileName); initPyroCluster(); @@ -759,9 +759,9 @@ int ShhherCommand::execute(){ string listFileName = cluster(distFileName, namesFileName); getOTUData(listFileName); - remove(distFileName.c_str()); - remove(namesFileName.c_str()); - remove(listFileName.c_str()); + m->mothurRemove(distFileName); + m->mothurRemove(namesFileName); + m->mothurRemove(listFileName); initPyroCluster(); @@ -1167,7 +1167,7 @@ string ShhherCommand::createDistFile(int processors){ //append and remove temp files for (int i=0;iappendFiles((fDistFileName + toString(processIDs[i]) + ".temp"), fDistFileName); - remove((fDistFileName + toString(processIDs[i]) + ".temp").c_str()); + m->mothurRemove((fDistFileName + toString(processIDs[i]) + ".temp")); } } diff --git a/splitabundcommand.cpp b/splitabundcommand.cpp index aa47940..29ffdb4 100644 --- a/splitabundcommand.cpp +++ b/splitabundcommand.cpp @@ -250,11 +250,11 @@ int SplitAbundCommand::execute(){ if (namefile != "") { readNamesFile(); } else { createNameMap(list); } - if (m->control_pressed) { delete input; delete list; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { delete input; delete list; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } while((list != NULL) && ((allLines == 1) || (userLabels.size() != 0))) { - if (m->control_pressed) { delete input; delete list; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { delete input; delete list; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } if(allLines == 1 || labels.count(list->getLabel()) == 1){ @@ -288,7 +288,7 @@ int SplitAbundCommand::execute(){ list = input->getListVector(); //get new list vector to process } - if (m->control_pressed) { delete input; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { delete input; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } //output error messages about any remaining user labels set::iterator it; @@ -304,7 +304,7 @@ int SplitAbundCommand::execute(){ } - if (m->control_pressed) { delete input; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { delete input; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } //run last label if you need to if (needToRun == true) { @@ -319,7 +319,7 @@ int SplitAbundCommand::execute(){ delete input; - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } }else { //you are using the namefile to determine abundance if (outputDir == "") { outputDir = m->hasPath(namefile); } diff --git a/splitgroupscommand.cpp b/splitgroupscommand.cpp index 6dd6206..00d9a9d 100644 --- a/splitgroupscommand.cpp +++ b/splitgroupscommand.cpp @@ -174,7 +174,7 @@ int SplitGroupCommand::execute(){ delete groupMap; - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } string current = ""; itTypes = outputTypes.find("fasta"); @@ -328,7 +328,7 @@ int SplitGroupCommand::splitFasta() { //remove blank files for (int i = 0; i < outputNames.size(); i++) { if (m->isBlank(outputNames[i])) { - remove(outputNames[i].c_str()); + m->mothurRemove(outputNames[i]); }else { newOutputNames.push_back(outputNames[i]); } } outputNames = newOutputNames; diff --git a/splitmatrix.cpp b/splitmatrix.cpp index 8ccb867..dabcd04 100644 --- a/splitmatrix.cpp +++ b/splitmatrix.cpp @@ -146,7 +146,7 @@ int SplitMatrix::createDistanceFilesFromTax(map& seqGroup, int numG set names; for (int i = 0; i < numGroups; i++) { //remove old temp files, just in case - remove((fastafile + "." + toString(i) + ".temp").c_str()); + m->mothurRemove((fastafile + "." + toString(i) + ".temp")); } ifstream in; @@ -193,10 +193,10 @@ int SplitMatrix::createDistanceFilesFromTax(map& seqGroup, int numG command->execute(); delete command; - remove((fastafile + "." + toString(i) + ".temp").c_str()); + m->mothurRemove((fastafile + "." + toString(i) + ".temp")); //remove old names files just in case - remove((namefile + "." + toString(i) + ".temp").c_str()); + m->mothurRemove((namefile + "." + toString(i) + ".temp")); } singleton = namefile + ".extra.temp"; @@ -250,7 +250,7 @@ int SplitMatrix::createDistanceFilesFromTax(map& seqGroup, int numG remainingNames << name << '\t' << nameList << endl; } in.close(); - remove(tempNameFile.c_str()); + m->mothurRemove(tempNameFile); } } fileHandle.close(); @@ -258,11 +258,11 @@ int SplitMatrix::createDistanceFilesFromTax(map& seqGroup, int numG remainingNames.close(); if (!wroteExtra) { - remove(singleton.c_str()); + m->mothurRemove(singleton); singleton = "none"; } - if (m->control_pressed) { for (int i = 0; i < dists.size(); i++) { remove((dists[i].begin()->first).c_str()); remove((dists[i].begin()->second).c_str()); } dists.clear(); } + if (m->control_pressed) { for (int i = 0; i < dists.size(); i++) { m->mothurRemove((dists[i].begin()->first)); m->mothurRemove((dists[i].begin()->second)); } dists.clear(); } return 0; } @@ -282,7 +282,7 @@ int SplitMatrix::splitDistanceFileByTax(map& seqGroup, int numGroup ofstream outFile; for (int i = 0; i < numGroups; i++) { //remove old temp files, just in case - remove((distFile + "." + toString(i) + ".temp").c_str()); + m->mothurRemove((distFile + "." + toString(i) + ".temp")); } //for buffering the io to improve speed @@ -299,7 +299,7 @@ int SplitMatrix::splitDistanceFileByTax(map& seqGroup, int numGroup string seqA, seqB; float dist; - if (m->control_pressed) { dFile.close(); for (int i = 0; i < numGroups; i++) { remove((distFile + "." + toString(i) + ".temp").c_str()); } } + if (m->control_pressed) { dFile.close(); for (int i = 0; i < numGroups; i++) { m->mothurRemove((distFile + "." + toString(i) + ".temp")); } } dFile >> seqA >> seqB >> dist; m->gobble(dFile); @@ -326,7 +326,7 @@ int SplitMatrix::splitDistanceFileByTax(map& seqGroup, int numGroup dFile.close(); for (int i = 0; i < numGroups; i++) { //remove old temp files, just in case - remove((namefile + "." + toString(i) + ".temp").c_str()); + m->mothurRemove((namefile + "." + toString(i) + ".temp")); //write out any remaining buffers if (numOutputs[i] > 0) { @@ -385,21 +385,21 @@ int SplitMatrix::splitDistanceFileByTax(map& seqGroup, int numGroup remainingNames << name << '\t' << nameList << endl; } in.close(); - remove(tempNameFile.c_str()); + m->mothurRemove(tempNameFile); } } remainingNames.close(); if (!wroteExtra) { - remove(singleton.c_str()); + m->mothurRemove(singleton); singleton = "none"; } if (m->control_pressed) { for (int i = 0; i < dists.size(); i++) { - remove((dists[i].begin()->first).c_str()); - remove((dists[i].begin()->second).c_str()); + m->mothurRemove((dists[i].begin()->first)); + m->mothurRemove((dists[i].begin()->second)); } dists.clear(); } @@ -434,7 +434,7 @@ int SplitMatrix::splitDistanceLarge(){ dFile >> seqA >> seqB >> dist; - if (m->control_pressed) { dFile.close(); for(int i=0;i 0){ remove((distFile + "." + toString(i) + ".temp").c_str()); } } return 0; } + if (m->control_pressed) { dFile.close(); for(int i=0;i 0){ m->mothurRemove((distFile + "." + toString(i) + ".temp")); } } return 0; } if(dist < cutoff){ //cout << "in cutoff: " << dist << endl; @@ -562,7 +562,7 @@ int SplitMatrix::splitDistanceLarge(){ delete memblock; fileB.close(); - remove(fileName2.c_str()); + m->mothurRemove(fileName2); //write out the merged memory if (numOutputs[groupID] > 60) { @@ -622,7 +622,7 @@ int SplitMatrix::splitDistanceLarge(){ delete memblock; fileB.close(); - remove(fileName2.c_str()); + m->mothurRemove(fileName2); //write out the merged memory if (numOutputs[groupID] > 60) { @@ -725,8 +725,8 @@ int SplitMatrix::splitNames(vector >& groups){ if (m->control_pressed) { for (int i = 0; i < dists.size(); i++) { - remove((dists[i].begin()->first).c_str()); - remove((dists[i].begin()->second).c_str()); + m->mothurRemove((dists[i].begin()->first)); + m->mothurRemove((dists[i].begin()->second)); } dists.clear(); } @@ -755,7 +755,7 @@ int SplitMatrix::splitDistanceRAM(){ dFile >> seqA >> seqB >> dist; - if (m->control_pressed) { dFile.close(); for(int i=0;i 0){ remove((distFile + "." + toString(i) + ".temp").c_str()); } } return 0; } + if (m->control_pressed) { dFile.close(); for(int i=0;i 0){ m->mothurRemove((distFile + "." + toString(i) + ".temp")); } } return 0; } if(dist < cutoff){ //cout << "in cutoff: " << dist << endl; diff --git a/subsamplecommand.cpp b/subsamplecommand.cpp index 95a0442..d538889 100644 --- a/subsamplecommand.cpp +++ b/subsamplecommand.cpp @@ -270,19 +270,19 @@ int SubSampleCommand::execute(){ if (abort == true) { if (calledHelp) { return 0; } return 2; } if (sharedfile != "") { getSubSampleShared(); } - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); return 0; } } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); return 0; } } if (listfile != "") { getSubSampleList(); } - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); return 0; } } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); return 0; } } if (rabundfile != "") { getSubSampleRabund(); } - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); return 0; } } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); return 0; } } if (sabundfile != "") { getSubSampleSabund(); } - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); return 0; } } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); return 0; } } if (fastafile != "") { getSubSampleFasta(); } - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); return 0; } } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); return 0; } } //set fasta file as new current fastafile string current = ""; diff --git a/summarycommand.cpp b/summarycommand.cpp index 2bb8877..629750b 100644 --- a/summarycommand.cpp +++ b/summarycommand.cpp @@ -337,7 +337,7 @@ int SummaryCommand::execute(){ } //if the users entered no valid calculators don't execute command - if (sumCalculators.size() == 0) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (sumCalculators.size() == 0) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } ofstream outputFileHandle; m->openOutputFile(fileNameRoot, outputFileHandle); @@ -363,11 +363,11 @@ int SummaryCommand::execute(){ set processedLabels; set userLabels = labels; - if (m->control_pressed) { outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } for(int i=0;icontrol_pressed) { outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } for(int i=0;icontrol_pressed) { outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } for(int i=0;icontrol_pressed) { outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } for(int i=0;igetLabel()) == 1){ @@ -379,7 +379,7 @@ int SummaryCommand::execute(){ for(int i=0;i data = sumCalculators[i]->getValues(sabund); - if (m->control_pressed) { outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } for(int i=0;icontrol_pressed) { outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } for(int i=0;iprint(outputFileHandle); @@ -402,7 +402,7 @@ int SummaryCommand::execute(){ for(int i=0;i data = sumCalculators[i]->getValues(sabund); - if (m->control_pressed) { outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } for(int i=0;icontrol_pressed) { outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } for(int i=0;iprint(outputFileHandle); @@ -420,7 +420,7 @@ int SummaryCommand::execute(){ sabund = input->getSAbundVector(); } - if (m->control_pressed) { outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } for(int i=0;icontrol_pressed) { outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } for(int i=0;i::iterator it; @@ -445,7 +445,7 @@ int SummaryCommand::execute(){ for(int i=0;i data = sumCalculators[i]->getValues(sabund); - if (m->control_pressed) { outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } for(int i=0;icontrol_pressed) { outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } for(int i=0;iprint(outputFileHandle); @@ -457,19 +457,19 @@ int SummaryCommand::execute(){ outputFileHandle.close(); - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } for(int i=0;icontrol_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } for(int i=0;icontrol_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } //create summary file containing all the groups data for each label - this function just combines the info from the files already created. if ((sharedfile != "") && (groupMode)) { outputNames.push_back(createGroupSummaryFile(numLines, numCols, outputNames)); } - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); @@ -498,7 +498,7 @@ vector SummaryCommand::parseSharedFile(string filename) { //clears file before we start to write to it below for (int i=0; igetGroup() + ".rabund").c_str()); + m->mothurRemove((sharedFileRoot + lookup[i]->getGroup() + ".rabund")); filenames.push_back((sharedFileRoot + lookup[i]->getGroup() + ".rabund")); } @@ -592,7 +592,7 @@ string SummaryCommand::createGroupSummaryFile(int numLines, int numCols, vector< files[outputNames[i]] = thisFilesLines; temp.close(); - remove(outputNames[i].c_str()); + m->mothurRemove(outputNames[i]); } //output label line to new file diff --git a/summarysharedcommand.cpp b/summarysharedcommand.cpp index b3b4b18..77db937 100644 --- a/summarysharedcommand.cpp +++ b/summarysharedcommand.cpp @@ -364,19 +364,19 @@ int SummarySharedCommand::execute(){ for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } //close files and clean up - remove(outputFileName.c_str()); - if (mult == true) { remove(outAllFileName.c_str()); } + m->mothurRemove(outputFileName); + if (mult == true) { m->mothurRemove(outAllFileName); } return 0; //if you only have 2 groups you don't need a .sharedmultiple file }else if ((lookup.size() == 2) && (mult == true)) { mult = false; - remove(outAllFileName.c_str()); + m->mothurRemove(outAllFileName); outputNames.pop_back(); } if (m->control_pressed) { - if (mult) { remove(outAllFileName.c_str()); } - remove(outputFileName.c_str()); + if (mult) { m->mothurRemove(outAllFileName); } + m->mothurRemove(outputFileName); delete input; for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } for(int i=0;icontrol_pressed) { - if (mult) { remove(outAllFileName.c_str()); } - remove(outputFileName.c_str()); + if (mult) { m->mothurRemove(outAllFileName); } + m->mothurRemove(outputFileName); delete input; for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } for(int i=0;icontrol_pressed) { - if (mult) { remove(outAllFileName.c_str()); } - remove(outputFileName.c_str()); + if (mult) { m->mothurRemove(outAllFileName); } + m->mothurRemove(outputFileName); delete input; for(int i=0;iGroups.clear(); @@ -485,8 +485,8 @@ int SummarySharedCommand::execute(){ delete input; if (m->control_pressed) { - remove(outAllFileName.c_str()); - remove(outputFileName.c_str()); + m->mothurRemove(outAllFileName); + m->mothurRemove(outputFileName); return 0; } @@ -515,10 +515,10 @@ int SummarySharedCommand::process(vector thisLookup, string if(processors == 1){ driver(thisLookup, 0, numGroups, sumFileName+".temp", sumAllFileName+".temp", calcDists); m->appendFiles((sumFileName + ".temp"), sumFileName); - remove((sumFileName + ".temp").c_str()); + m->mothurRemove((sumFileName + ".temp")); if (mult) { m->appendFiles((sumAllFileName + ".temp"), sumAllFileName); - remove((sumAllFileName + ".temp").c_str()); + m->mothurRemove((sumAllFileName + ".temp")); } }else{ int process = 1; @@ -561,7 +561,7 @@ int SummarySharedCommand::process(vector thisLookup, string //parent do your part driver(thisLookup, lines[0].start, lines[0].end, sumFileName + toString(getpid()) + ".temp", sumAllFileName + toString(getpid()) + ".temp", calcDists); m->appendFiles((sumFileName + toString(getpid()) + ".temp"), sumFileName); - remove((sumFileName + toString(getpid()) + ".temp").c_str()); + m->mothurRemove((sumFileName + toString(getpid()) + ".temp")); if (mult) { m->appendFiles((sumAllFileName + toString(getpid()) + ".temp"), sumAllFileName); } //force parent to wait until all the processes are done @@ -572,8 +572,8 @@ int SummarySharedCommand::process(vector thisLookup, string for (int i = 0; i < processIDS.size(); i++) { m->appendFiles((sumFileName + toString(processIDS[i]) + ".temp"), sumFileName); - remove((sumFileName + toString(processIDS[i]) + ".temp").c_str()); - if (mult) { remove((sumAllFileName + toString(processIDS[i]) + ".temp").c_str()); } + m->mothurRemove((sumFileName + toString(processIDS[i]) + ".temp")); + if (mult) { m->mothurRemove((sumAllFileName + toString(processIDS[i]) + ".temp")); } if (createPhylip) { string tempdistFileName = m->getRootName(m->getSimpleName(sumFileName)) + toString(processIDS[i]) + ".dist"; @@ -596,7 +596,7 @@ int SummarySharedCommand::process(vector thisLookup, string } } intemp.close(); - remove(tempdistFileName.c_str()); + m->mothurRemove(tempdistFileName); } } @@ -604,10 +604,10 @@ int SummarySharedCommand::process(vector thisLookup, string #else driver(thisLookup, 0, numGroups, (sumFileName + ".temp"), (sumAllFileName + ".temp"), calcDists); m->appendFiles((sumFileName + ".temp"), sumFileName); - remove((sumFileName + ".temp").c_str()); + m->mothurRemove((sumFileName + ".temp")); if (mult) { m->appendFiles((sumAllFileName + ".temp"), sumAllFileName); - remove((sumAllFileName + ".temp").c_str()); + m->mothurRemove((sumAllFileName + ".temp")); } #endif diff --git a/systemcommand.cpp b/systemcommand.cpp index ab9674f..d0057e8 100644 --- a/systemcommand.cpp +++ b/systemcommand.cpp @@ -106,7 +106,7 @@ int SystemCommand::execute(){ in.close(); m->mothurOut(output); m->mothurOutEndLine(); - remove(filename.c_str()); + m->mothurRemove(filename); return 0; } diff --git a/taxonomyequalizer.cpp b/taxonomyequalizer.cpp index d3b24d1..2f6fc77 100644 --- a/taxonomyequalizer.cpp +++ b/taxonomyequalizer.cpp @@ -61,7 +61,7 @@ TaxEqualizer::TaxEqualizer(string tfile, int c, string o) : cutoff(c), outputDir in.close(); out.close(); - if (m->control_pressed) { remove(equalizedFile.c_str()); } + if (m->control_pressed) { m->mothurRemove(equalizedFile); } }else { inTax.close(); } } diff --git a/treegroupscommand.cpp b/treegroupscommand.cpp index 902b9a2..f1be7cb 100644 --- a/treegroupscommand.cpp +++ b/treegroupscommand.cpp @@ -409,7 +409,7 @@ int TreeGroupCommand::execute(){ //create tree file makeSimsShared(); - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } }else{ //read in dist file filename = inputfile; @@ -564,7 +564,7 @@ int TreeGroupCommand::createTree(){ //delete tree delete t; - if (m->control_pressed) { remove(outputFile.c_str()); outputNames.pop_back(); return 1; } + if (m->control_pressed) { m->mothurRemove(outputFile); outputNames.pop_back(); return 1; } return 0; diff --git a/trimflowscommand.cpp b/trimflowscommand.cpp index ec04336..d17e000 100644 --- a/trimflowscommand.cpp +++ b/trimflowscommand.cpp @@ -270,7 +270,7 @@ int TrimFlowsCommand::execute(){ } if(size < 10){ - remove(barcodePrimerComboFileNames[i][j].c_str()); + m->mothurRemove(barcodePrimerComboFileNames[i][j]); } else{ output << barcodePrimerComboFileNames[i][j] << endl; @@ -1058,23 +1058,23 @@ int TrimFlowsCommand::createProcessesCreateTrim(string flowFileName, string trim m->mothurOut("Appending files from process " + toString(processIDS[i])); m->mothurOutEndLine(); m->appendFiles((trimFlowFileName + toString(processIDS[i]) + ".temp"), trimFlowFileName); - remove((trimFlowFileName + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((trimFlowFileName + toString(processIDS[i]) + ".temp")); // m->mothurOut("\tDone with trim.flow file"); m->mothurOutEndLine(); m->appendFiles((scrapFlowFileName + toString(processIDS[i]) + ".temp"), scrapFlowFileName); - remove((scrapFlowFileName + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((scrapFlowFileName + toString(processIDS[i]) + ".temp")); // m->mothurOut("\tDone with scrap.flow file"); m->mothurOutEndLine(); if(fasta){ m->appendFiles((fastaFileName + toString(processIDS[i]) + ".temp"), fastaFileName); - remove((fastaFileName + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((fastaFileName + toString(processIDS[i]) + ".temp")); // m->mothurOut("\tDone with flow.fasta file"); m->mothurOutEndLine(); } if(allFiles){ for (int j = 0; j < barcodePrimerComboFileNames.size(); j++) { for (int k = 0; k < barcodePrimerComboFileNames[0].size(); k++) { m->appendFiles((barcodePrimerComboFileNames[j][k] + toString(processIDS[i]) + ".temp"), barcodePrimerComboFileNames[j][k]); - remove((barcodePrimerComboFileNames[j][k] + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((barcodePrimerComboFileNames[j][k] + toString(processIDS[i]) + ".temp")); } } } diff --git a/trimseqscommand.cpp b/trimseqscommand.cpp index a2c8021..21de6ac 100644 --- a/trimseqscommand.cpp +++ b/trimseqscommand.cpp @@ -380,16 +380,16 @@ int TrimSeqsCommand::execute(){ if (fastaFileNames[i][j] != "") { if (namesToRemove.count(fastaFileNames[i][j]) == 0) { if(m->isBlank(fastaFileNames[i][j])){ - remove(fastaFileNames[i][j].c_str()); + m->mothurRemove(fastaFileNames[i][j]); namesToRemove.insert(fastaFileNames[i][j]); if(qFileName != ""){ - remove(qualFileNames[i][j].c_str()); + m->mothurRemove(qualFileNames[i][j]); namesToRemove.insert(qualFileNames[i][j]); } if(nameFile != ""){ - remove(nameFileNames[i][j].c_str()); + m->mothurRemove(nameFileNames[i][j]); namesToRemove.insert(nameFileNames[i][j]); } }else{ @@ -428,7 +428,7 @@ int TrimSeqsCommand::execute(){ } } - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } //output group counts m->mothurOutEndLine(); @@ -439,7 +439,7 @@ int TrimSeqsCommand::execute(){ } if (total != 0) { m->mothurOut("Total of all groups is " + toString(total)); m->mothurOutEndLine(); } - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } //set fasta file as new current fastafile string current = ""; @@ -546,7 +546,7 @@ int TrimSeqsCommand::driverCreateTrim(string filename, string qFileName, string if(qFileName != ""){ qFile.close(); } - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } @@ -556,11 +556,12 @@ int TrimSeqsCommand::driverCreateTrim(string filename, string qFileName, string int currentSeqsDiffs = 0; Sequence currSeq(inFASTA); m->gobble(inFASTA); + //cout << currSeq.getName() << '\t' << currSeq.getUnaligned().length() << endl; QualityScores currQual; if(qFileName != ""){ currQual = QualityScores(qFile); m->gobble(qFile); } - //cout << currSeq.getName() << '\t' << currSeq.getUnaligned().length() << endl; + string origSeq = currSeq.getUnaligned(); if (origSeq != "") { @@ -846,27 +847,27 @@ int TrimSeqsCommand::createProcessesCreateTrim(string filename, string qFileName m->mothurOut("Appending files from process " + toString(processIDS[i])); m->mothurOutEndLine(); m->appendFiles((trimFASTAFileName + toString(processIDS[i]) + ".temp"), trimFASTAFileName); - remove((trimFASTAFileName + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((trimFASTAFileName + toString(processIDS[i]) + ".temp")); m->appendFiles((scrapFASTAFileName + toString(processIDS[i]) + ".temp"), scrapFASTAFileName); - remove((scrapFASTAFileName + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((scrapFASTAFileName + toString(processIDS[i]) + ".temp")); if(qFileName != ""){ m->appendFiles((trimQualFileName + toString(processIDS[i]) + ".temp"), trimQualFileName); - remove((trimQualFileName + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((trimQualFileName + toString(processIDS[i]) + ".temp")); m->appendFiles((scrapQualFileName + toString(processIDS[i]) + ".temp"), scrapQualFileName); - remove((scrapQualFileName + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((scrapQualFileName + toString(processIDS[i]) + ".temp")); } if(nameFile != ""){ m->appendFiles((trimNameFileName + toString(processIDS[i]) + ".temp"), trimNameFileName); - remove((trimNameFileName + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((trimNameFileName + toString(processIDS[i]) + ".temp")); m->appendFiles((scrapNameFileName + toString(processIDS[i]) + ".temp"), scrapNameFileName); - remove((scrapNameFileName + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((scrapNameFileName + toString(processIDS[i]) + ".temp")); } if(oligoFile != ""){ m->appendFiles((groupFile + toString(processIDS[i]) + ".temp"), groupFile); - remove((groupFile + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((groupFile + toString(processIDS[i]) + ".temp")); } @@ -875,16 +876,16 @@ int TrimSeqsCommand::createProcessesCreateTrim(string filename, string qFileName for(int k=0;kappendFiles((fastaFileNames[j][k] + toString(processIDS[i]) + ".temp"), fastaFileNames[j][k]); - remove((fastaFileNames[j][k] + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((fastaFileNames[j][k] + toString(processIDS[i]) + ".temp")); if(qFileName != ""){ m->appendFiles((qualFileNames[j][k] + toString(processIDS[i]) + ".temp"), qualFileNames[j][k]); - remove((qualFileNames[j][k] + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((qualFileNames[j][k] + toString(processIDS[i]) + ".temp")); } if(nameFile != ""){ m->appendFiles((nameFileNames[j][k] + toString(processIDS[i]) + ".temp"), nameFileNames[j][k]); - remove((nameFileNames[j][k] + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((nameFileNames[j][k] + toString(processIDS[i]) + ".temp")); } } } @@ -909,7 +910,7 @@ int TrimSeqsCommand::createProcessesCreateTrim(string filename, string qFileName else { groupCounts[it->first] += tempNum; } } } - in.close(); remove(tempFile.c_str()); + in.close(); m->mothurRemove(tempFile); } } diff --git a/unifracunweightedcommand.cpp b/unifracunweightedcommand.cpp index 058555e..501e612 100644 --- a/unifracunweightedcommand.cpp +++ b/unifracunweightedcommand.cpp @@ -258,7 +258,7 @@ int UnifracUnweightedCommand::execute() { if (m->control_pressed) { delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; } - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); m->Groups.clear(); return 0; } @@ -307,7 +307,7 @@ int UnifracUnweightedCommand::execute() { delete tmap; delete unweighted; for (int i = 0; i < T.size(); i++) { delete T[i]; } outSum.close(); - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } @@ -329,7 +329,7 @@ int UnifracUnweightedCommand::execute() { userData = unweighted->getValues(T[i], processors, outputDir); //userData[0] = unweightedscore if (m->control_pressed) { delete tmap; delete unweighted; - for (int i = 0; i < T.size(); i++) { delete T[i]; }if (random) { delete output; } outSum.close(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); }return 0; } + for (int i = 0; i < T.size(); i++) { delete T[i]; }if (random) { delete output; } outSum.close(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); }return 0; } //output scores for each combination for(int k = 0; k < numComp; k++) { @@ -347,7 +347,7 @@ int UnifracUnweightedCommand::execute() { randomData = unweighted->getValues(T[i], "", "", processors, outputDir); if (m->control_pressed) { delete tmap; delete unweighted; - for (int i = 0; i < T.size(); i++) { delete T[i]; }if (random) { delete output; } outSum.close(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + for (int i = 0; i < T.size(); i++) { delete T[i]; }if (random) { delete output; } outSum.close(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } for(int k = 0; k < numComp; k++) { //add trees unweighted score to map of scores @@ -385,7 +385,7 @@ int UnifracUnweightedCommand::execute() { } if (m->control_pressed) { delete tmap; delete unweighted; - for (int i = 0; i < T.size(); i++) { delete T[i]; }if (random) { delete output; } outSum.close(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + for (int i = 0; i < T.size(); i++) { delete T[i]; }if (random) { delete output; } outSum.close(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } //print output files printUWSummaryFile(i); @@ -405,7 +405,7 @@ int UnifracUnweightedCommand::execute() { delete tmap; delete unweighted; for (int i = 0; i < T.size(); i++) { delete T[i]; } - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } m->mothurOut("It took " + toString(time(NULL) - start) + " secs to run unifrac.unweighted."); m->mothurOutEndLine(); diff --git a/unifracweightedcommand.cpp b/unifracweightedcommand.cpp index 00bb5d6..d6431a0 100644 --- a/unifracweightedcommand.cpp +++ b/unifracweightedcommand.cpp @@ -252,7 +252,7 @@ int UnifracWeightedCommand::execute() { if (m->control_pressed) { delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; } - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); m->Groups.clear(); return 0; } @@ -295,7 +295,7 @@ int UnifracWeightedCommand::execute() { for (int i = 0; i < T.size(); i++) { if (m->control_pressed) { delete tmap; delete weighted; - for (int i = 0; i < T.size(); i++) { delete T[i]; } outSum.close(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + for (int i = 0; i < T.size(); i++) { delete T[i]; } outSum.close(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } counter = 0; rScores.resize(numComp); //data[0] = weightedscore AB, data[1] = weightedscore AC... @@ -310,7 +310,7 @@ int UnifracWeightedCommand::execute() { userData = weighted->getValues(T[i], processors, outputDir); //userData[0] = weightedscore if (m->control_pressed) { delete tmap; delete weighted; - for (int i = 0; i < T.size(); i++) { delete T[i]; } if (random) { delete output; } outSum.close(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + for (int i = 0; i < T.size(); i++) { delete T[i]; } if (random) { delete output; } outSum.close(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } //save users score for (int s=0; scontrol_pressed) { delete tmap; delete weighted; - for (int i = 0; i < T.size(); i++) { delete T[i]; } delete output; outSum.close(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + for (int i = 0; i < T.size(); i++) { delete T[i]; } delete output; outSum.close(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } //report progress // m->mothurOut("Iter: " + toString(j+1)); m->mothurOutEndLine(); @@ -402,7 +402,7 @@ int UnifracWeightedCommand::execute() { if (m->control_pressed) { delete tmap; delete weighted; - for (int i = 0; i < T.size(); i++) { delete T[i]; } outSum.close(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + for (int i = 0; i < T.size(); i++) { delete T[i]; } outSum.close(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } printWSummaryFile(); @@ -415,7 +415,7 @@ int UnifracWeightedCommand::execute() { if (m->control_pressed) { - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } @@ -500,7 +500,7 @@ int UnifracWeightedCommand::createProcesses(Tree* t, vector< vector > na double tempScore; for (int j = lines[(i+1)].start; j < (lines[(i+1)].start + lines[(i+1)].num); j++) { in >> tempScore; scores[j].push_back(tempScore); } in.close(); - remove(s.c_str()); + m->mothurRemove(s); } return 0; diff --git a/unweighted.cpp b/unweighted.cpp index 90b6476..98bfa45 100644 --- a/unweighted.cpp +++ b/unweighted.cpp @@ -151,7 +151,7 @@ EstOutput Unweighted::createProcesses(Tree* t, vector< vector > namesOfG m->gobble(in); } in.close(); - remove(s.c_str()); + m->mothurRemove(s); } m->mothurOut("DONE."); m->mothurOutEndLine(); m->mothurOutEndLine(); @@ -393,7 +393,7 @@ EstOutput Unweighted::createProcesses(Tree* t, vector< vector > namesOfG m->gobble(in); } in.close(); - remove(s.c_str()); + m->mothurRemove(s); } return results; diff --git a/venncommand.cpp b/venncommand.cpp index 6d4c2a0..7ee0489 100644 --- a/venncommand.cpp +++ b/venncommand.cpp @@ -275,7 +275,7 @@ int VennCommand::execute(){ for (int i = 0; i < vennCalculators.size(); i++) { delete vennCalculators[i]; } for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } m->Groups.clear(); delete venn; delete input; - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } @@ -358,7 +358,7 @@ int VennCommand::execute(){ if (m->control_pressed) { for (int i = 0; i < vennCalculators.size(); i++) { delete vennCalculators[i]; } m->Groups.clear(); delete venn; delete input; - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } @@ -419,7 +419,7 @@ int VennCommand::execute(){ if (m->control_pressed) { m->Groups.clear(); delete venn; delete input; for (int i = 0; i < vennCalculators.size(); i++) { delete vennCalculators[i]; } - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } @@ -431,7 +431,7 @@ int VennCommand::execute(){ if (m->control_pressed) { for (int i = 0; i < vennCalculators.size(); i++) { delete vennCalculators[i]; } delete sabund; delete venn; delete input; - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } @@ -472,7 +472,7 @@ int VennCommand::execute(){ if (m->control_pressed) { for (int i = 0; i < vennCalculators.size(); i++) { delete vennCalculators[i]; } - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } delete venn; delete input; return 0; } @@ -506,7 +506,7 @@ int VennCommand::execute(){ if (m->control_pressed) { delete venn; delete input; for (int i = 0; i < vennCalculators.size(); i++) { delete vennCalculators[i]; } - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } } diff --git a/weighted.cpp b/weighted.cpp index d0defc3..70f6ae3 100644 --- a/weighted.cpp +++ b/weighted.cpp @@ -139,7 +139,7 @@ EstOutput Weighted::createProcesses(Tree* t, vector< vector > namesOfGro m->gobble(in); } in.close(); - remove(s.c_str()); + m->mothurRemove(s); } m->mothurOut("DONE."); m->mothurOutEndLine(); m->mothurOutEndLine();