]> git.donarmstrong.com Git - mothur.git/commitdiff
rewrote metastats command in c++, added mothurRemove function to handle ~ error....
authorwestcott <westcott>
Fri, 15 Jul 2011 19:50:30 +0000 (19:50 +0000)
committerwestcott <westcott>
Fri, 15 Jul 2011 19:50:30 +0000 (19:50 +0000)
123 files changed:
Mothur.xcodeproj/project.pbxproj
aligncommand.cpp
bayesian.cpp
bellerophon.cpp
binsequencecommand.cpp
blastalign.cpp
blastdb.cpp
bootstrapsharedcommand.cpp
catchallcommand.cpp
chimerabellerophoncommand.cpp
chimeraccodecommand.cpp
chimeracheckcommand.cpp
chimerapintailcommand.cpp
chimeraslayercommand.cpp
chimerauchimecommand.cpp
chopseqscommand.cpp
classifyotucommand.cpp
classifyotucommand.h
classifyseqscommand.cpp
clustercommand.cpp
clusterdoturcommand.cpp
clusterfragmentscommand.cpp
clustersplitcommand.cpp
collectcommand.cpp
collectsharedcommand.cpp
consensusseqscommand.cpp
countseqscommand.cpp
deconvolutecommand.cpp
degapseqscommand.cpp
deuniqueseqscommand.cpp
deuniquetreecommand.cpp
distancecommand.cpp
fileoutput.cpp
filterseqscommand.cpp
fisher2.c
formatcolumn.cpp
formatphylip.cpp
getcommandinfocommand.cpp
getgroupcommand.cpp
getgroupscommand.cpp
getlineagecommand.cpp
getlistcountcommand.cpp
getoturepcommand.cpp
getotuscommand.cpp
getrabundcommand.cpp
getrelabundcommand.cpp
getsabundcommand.cpp
getseqscommand.cpp
getsharedotucommand.cpp
hcluster.cpp
hclustercommand.cpp
heatmapcommand.cpp
heatmapsimcommand.cpp
indicatorcommand.cpp
libshuffcommand.cpp
listseqscommand.cpp
makefastqcommand.cpp
makegroupcommand.cpp
matrixoutputcommand.cpp
mergefilecommand.cpp
mergegroupscommand.cpp
metastats2.c
metastatscommand.cpp
mgclustercommand.cpp
mothur.cpp
mothurfisher.cpp [new file with mode: 0644]
mothurfisher.h [new file with mode: 0644]
mothurmetastats.cpp [new file with mode: 0644]
mothurmetastats.h [new file with mode: 0644]
mothurout.cpp
mothurout.h
nmdscommand.cpp
normalizesharedcommand.cpp
otuhierarchycommand.cpp
pairwiseseqscommand.cpp
parsefastaqcommand.cpp
parselistscommand.cpp
parsimony.cpp
parsimonycommand.cpp
pcacommand.cpp
pcoacommand.cpp
phylodiversitycommand.cpp
phylosummary.cpp
phylotypecommand.cpp
pintail.cpp
preclustercommand.cpp
qualityscores.cpp
rarefact.cpp
rarefactcommand.cpp
rarefactsharedcommand.cpp
readblast.cpp
readcluster.cpp
readdistcommand.cpp
removegroupscommand.cpp
removelineagecommand.cpp
removeotuscommand.cpp
removerarecommand.cpp
removeseqscommand.cpp
reversecommand.cpp
screenseqscommand.cpp
secondarystructurecommand.cpp
seqerrorcommand.cpp
seqsummarycommand.cpp
setdircommand.cpp
sffinfocommand.cpp
sharedcommand.cpp
shhhercommand.cpp
splitabundcommand.cpp
splitgroupscommand.cpp
splitmatrix.cpp
subsamplecommand.cpp
summarycommand.cpp
summarysharedcommand.cpp
systemcommand.cpp
taxonomyequalizer.cpp
treegroupscommand.cpp
trimflowscommand.cpp
trimseqscommand.cpp
unifracunweightedcommand.cpp
unifracweightedcommand.cpp
unweighted.cpp
venncommand.cpp
weighted.cpp

index c693c0746414d813cbd59824db42f972e96d5d31..00bcf9abb0d7eb68be32387532647584da236157 100644 (file)
@@ -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 */; };
                A727864312E9E28C00F86ABA /* removerarecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = removerarecommand.cpp; sourceTree = "<group>"; };
                A73DDBB813C4A0D1006AAE38 /* clearmemorycommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = clearmemorycommand.h; sourceTree = "<group>"; };
                A73DDBB913C4A0D1006AAE38 /* clearmemorycommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = clearmemorycommand.cpp; sourceTree = "<group>"; };
+               A73DDC3613C4BF64006AAE38 /* mothurmetastats.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mothurmetastats.h; sourceTree = "<group>"; };
+               A73DDC3713C4BF64006AAE38 /* mothurmetastats.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mothurmetastats.cpp; sourceTree = "<group>"; };
                A74D3655137DAB8300332B0C /* addtargets2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = addtargets2.cpp; sourceTree = "<group>"; };
                A74D3656137DAB8300332B0C /* alignchime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = alignchime.cpp; sourceTree = "<group>"; };
                A74D3657137DAB8300332B0C /* alignchimel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = alignchimel.cpp; sourceTree = "<group>"; };
                A778FE6A134CA6CA00C0BA33 /* getcommandinfocommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = getcommandinfocommand.cpp; sourceTree = "<group>"; };
                A77A221D139001B600B0BE70 /* deuniquetreecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = deuniquetreecommand.h; sourceTree = "<group>"; };
                A77A221E139001B600B0BE70 /* deuniquetreecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = deuniquetreecommand.cpp; sourceTree = "<group>"; };
+               A79234D513C74BF6002B08E2 /* mothurfisher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mothurfisher.h; sourceTree = "<group>"; };
+               A79234D613C74BF6002B08E2 /* mothurfisher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mothurfisher.cpp; sourceTree = "<group>"; };
                A799F5B71309A3E000AEEFA0 /* makefastqcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = makefastqcommand.h; sourceTree = "<group>"; };
                A799F5B81309A3E000AEEFA0 /* makefastqcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = makefastqcommand.cpp; sourceTree = "<group>"; };
                A7A61F1A130035C800E05B6B /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
                                A7E9B6E612D37EC400DA6239 /* fisher2.h */,
                                A7E9B75512D37EC400DA6239 /* metastats.h */,
                                A7E9B75612D37EC400DA6239 /* metastats2.c */,
+                               A79234D513C74BF6002B08E2 /* mothurfisher.h */,
+                               A79234D613C74BF6002B08E2 /* mothurfisher.cpp */,
+                               A73DDC3613C4BF64006AAE38 /* mothurmetastats.h */,
+                               A73DDC3713C4BF64006AAE38 /* mothurmetastats.cpp */,
                        );
                        name = metastats;
                        sourceTree = "<group>";
                                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;
                };
index e3db3dda8db657d23e671cc704e90f78833cfca2..a32ec4df279b2fa1158ec5e818ce03545de4ed0c 100644 (file)
@@ -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<string> 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;
index 0b55efd3258fe036ec0d12955786f6d61b798c5c..1d5c46bba9ebf132a1dd46ff120973ed087122b3 100644 (file)
@@ -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();
index f4d04ea074b1d2d95cb9bcff4fcc3084e7f234c6..207fa51583b0835810ffaf1e52db88e95252346b 100644 (file)
@@ -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;
        }
index 8e8ec2bc51362d8b8876d6e3cbb10ef9ff5e167e..4977cad1f769690e300013e89c936eefb4228e84 100644 (file)
@@ -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<string>::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();
index 9af31dfa3e65e130d0bc347600aa28405f94b7f4..bb7192ad498c405fc476ae722db2478fa1b407ab 100644 (file)
@@ -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);
 }
 
 //**************************************************************************************************/
index d64f374c4146fb802079f8fda5cb23074f9561f8..96770dcd5334afc6ed3d067ea6c7230b7c3edc73 100644 (file)
@@ -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<int> 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<int> 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;
        }
index 478821ec861e7b537e6f15b8c44bdab86a8d2c9f..783016ac0738b1f31fa0aee05fbd0fb5a0be8228 100644 (file)
@@ -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<string>::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();  
index fd51664a21ffa6373ebf9fd46d0fe5f586eb288c..39cc44f86e2cbe70efba4cb2700ad3154eb91945 100644 (file)
@@ -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<string>& outputNames) {
                        numLines = thisFilesLines.size();
                        
                        temp.close();
-                       remove(outputNames[i].c_str());
+                       m->mothurRemove(outputNames[i]);
                }
                
                //for each label
@@ -579,7 +579,7 @@ vector<string> CatchAllCommand::parseSharedFile(string filename) {
                
                //clears file before we start to write to it below
                for (int i=0; i<lookup.size(); i++) {
-                       remove((sharedFileRoot + lookup[i]->getGroup() + ".sabund").c_str());
+                       m->mothurRemove((sharedFileRoot + lookup[i]->getGroup() + ".sabund"));
                        filenames.push_back((sharedFileRoot + lookup[i]->getGroup() + ".sabund"));
                        groups.push_back(lookup[i]->getGroup());
                }
index 0031acb15b750823bb8cb3afed79d79f9a07d399..ac1645dd4e1f4f271cad18240c80814cf87c2b03 100644 (file)
@@ -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();
                        
index fd80ec965b4040f78dce01579e1974760fbb2a89..7c8485adfedc0a0c39dc928e50b45fc6bfef2a11 100644 (file)
@@ -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;i<processors;i++){
                                                m->appendFiles((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;i<processors;i++){
                                                m->appendFiles((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;
index 584e9874fd4cea4136d45c184a4c0662973c3b25..2b88eb5736bfd37364461facb043b0db76aa3cfc 100644 (file)
@@ -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;j<processors;j++){
                                                m->appendFiles((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;
index 66fe65d2318642610d77e1325c96c1fb2135ac1f..01a905f40d4c69514230ad033367cc02982cd3db 100644 (file)
@@ -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;i<processors;i++){
                                                m->appendFiles((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;i<processors;i++){
                                                m->appendFiles((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;
index c846a83155b75443d68803443ca9db904467bcc6..4c37a854fe317a29c90be7dc45e31144fe68a6c5 100644 (file)
@@ -464,7 +464,7 @@ int ChimeraSlayerCommand::execute(){
                                map<string, int> 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;i<processors;i++){
                                                m->appendFiles((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;i<processors;i++){
                                                m->appendFiles((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;i<processors;i++){
                                                        m->appendFiles((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(); }
index b42a491fb4f8af800cb193eb71af2fa6692afe17..4c1db20ac23105ad29652a3f1feedfc38237c3a6 100644 (file)
@@ -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<seqPriorityNode> 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;i<processIDS[i];i++){
                        m->appendFiles((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;     
        }
index fc4327f210d04241b5c1e7a6056759525998c738..e2b0fa46fc28bb6fd6be1af8a085e409a9a8b4df 100644 (file)
@@ -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();
                
index d065b3a37c5ac41f9c6c3b59eb9ca3832f8697a9..7b1a04f3658bcb0a3e919fefe34a30dedcfaa882 100644 (file)
@@ -244,7 +244,7 @@ int ClassifyOtuCommand::execute(){
                set<string> processedLabels;
                set<string> 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<string> 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<string> ClassifyOtuCommand::findConsensusTaxonomy(int bin, ListVector* th
                                }else{
                                        conTax += bestChild.name + ";";
                                }
+                               myLevel++;
                        }else{ //if no, quit
                                break;
                        }
@@ -488,7 +489,12 @@ vector<string> 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 {
index b3ca6530e3e5e577f8608349bb809739d749c2b1..d1c173490ac3778e485bcb58334047f4757d6a1e 100644 (file)
@@ -48,6 +48,7 @@ private:
        int readTaxonomyFile();
        void removeConfidences(string&);
        int process(ListVector*);
+       string addUnclassifieds(string, int);
        vector<string> findConsensusTaxonomy(int, ListVector*, int&, string&);  // returns the name of the "representative" taxonomy of given bin
        
                                                                                                
index f1b3a0e60186261bff404cfa4e5a1605e1c38f08..d9bd698232196c4c3597f8425a8e3f6e8b6b0694 100644 (file)
@@ -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;i<processIDS.size();i++){
                        appendTaxFiles((taxFileName + toString(processIDS[i]) + ".temp"), taxFileName);
                        appendTaxFiles((tempTaxFile + toString(processIDS[i]) + ".temp"), tempTaxFile);
-                       remove((taxFileName + toString(processIDS[i]) + ".temp").c_str());
-                       remove((tempTaxFile + toString(processIDS[i]) + ".temp").c_str());
+                       m->mothurRemove((m->getFullPathName(taxFileName) + toString(processIDS[i]) + ".temp"));
+                       m->mothurRemove((m->getFullPathName(tempTaxFile) + toString(processIDS[i]) + ".temp"));
                }
                
                return num;
index fd1f841dacab7ea017f15400766f384f10789cf3..059f277db6856e2b8c360dbb03b1929d7fa39de5 100644 (file)
@@ -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;
                        }
                
index 3f629dc09af39d7c9785a18687d9aecb8bee5f58..0d57e68a8a0b656798e107dd7f69eea6d7b9205c 100644 (file)
@@ -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);
        
index 71ce5eed4e6e21c63210be0e34eb9a6f72dac59b..5c8d12b1d9bbb2a32798bacdb7c762110b8cf343 100644 (file)
@@ -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();
index 9999eb0fb81e461e9f168c2c81b7531a3774607a..1f99efc14f9f4b703ad962f5f97bb0f480eca9c3 100644 (file)
@@ -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<float, int> 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<float, int> ClusterSplitCommand::completeListFile(vector<string> 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<float, int> ClusterSplitCommand::completeListFile(vector<string> 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<float, int> ClusterSplitCommand::completeListFile(vector<string> 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<string> listNames, map<float, int> 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<string> listNames, map<float, int> 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<string> ClusterSplitCommand::cluster(vector< map<string, string> > 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<string> ClusterSplitCommand::cluster(vector< map<string, string> > 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, string> >
                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++) {
index 5bd9fd75c474aeafdf632d8800b9c184916ccc83..89ab0a49a7592a86638d801aaaf0257f63a34379 100644 (file)
@@ -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;i<cDisplays.size();i++){    delete cDisplays[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(); 
                                delete input;  
                                delete order; 
                                m->Groups.clear();
@@ -425,7 +425,7 @@ int CollectCommand::execute(){
                        
                                if (m->control_pressed) { 
                                        for(int i=0;i<cDisplays.size();i++){    delete cDisplays[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(); 
                                        delete input;  
                                        delete order; 
                                        m->Groups.clear();
@@ -474,7 +474,7 @@ int CollectCommand::execute(){
                        
                        if (m->control_pressed) { 
                                        for(int i=0;i<cDisplays.size();i++){    delete cDisplays[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(); 
                                        delete input;  
                                        m->Groups.clear();
                                        return 0;
@@ -506,7 +506,7 @@ int CollectCommand::execute(){
                                
                                if (m->control_pressed) { 
                                        for(int i=0;i<cDisplays.size();i++){    delete cDisplays[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(); 
                                        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<string> CollectCommand::parseSharedFile(string filename) {
                
                //clears file before we start to write to it below
                for (int i=0; i<lookup.size(); i++) {
-                       remove((sharedFileRoot + lookup[i]->getGroup() + ".rabund").c_str());
+                       m->mothurRemove((sharedFileRoot + lookup[i]->getGroup() + ".rabund"));
                        filenames.push_back((sharedFileRoot + lookup[i]->getGroup() + ".rabund"));
                }
                
index 202883e201561f8851d77c5e6569df33280143c3..3b43a40f4cd33c4f006776ba764c04fa3866d96b 100644 (file)
@@ -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;i<cDisplays.size();i++){    delete cDisplays[i];    }
                                        delete order; delete input;
                                        m->Groups.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;i<cDisplays.size();i++){    delete cDisplays[i];    }
                                        m->Groups.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<cDisplays.size();i++){    delete cDisplays[i];    }
                                delete order; 
                                delete input;
index 9172819bd78f39dfee97b94c4c4b24c79bd080ae..e32867f3737b27bc3b9e929a73f142fe564d48c4 100644 (file)
@@ -206,7 +206,7 @@ int ConsensusSeqsCommand::execute(){
                        int seqLength = 0;
                        for (map<string, string>::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<int> 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<string>::iterator it;
index a7890b878a7f1210137e683e4a1311a02439eb49..0d8ddf5440c324b3d7fa12cc4cff92aef4996b3b 100644 (file)
@@ -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();
index 5888feedcf5f6d6c01438d5acecc5e65ba897c54..bc2dd481e5589ea5ba8b319aa707ecf3a3eea463 100644 (file)
@@ -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();
index f590d8b3baaf67091f59a741a87a23e09c8873b0..1d83f3bef00d08574a66d7e5ecf21efa148452a4 100644 (file)
@@ -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
index 2ba6f3d2363d86cc49108e2cb3db71fddd1ae879..7481416f649ddad983877ab02cac08e5668316d1 100644 (file)
@@ -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();
index f39a182ed863893c66f9b22a25c4c6765c04d165..dca81e5ebb6359752731b7a003173b2da0306b0e 100644 (file)
@@ -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;
                                }
index 4bdeaaeb5d9b388ac56fc2553f57dc10c0d598d9..b69b93d85c44c1fa89d08d49c0fb478b2f0cb242 100644 (file)
@@ -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;i<processIDS.size();i++) { 
                        m->appendFiles((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;
index c2432acaaf039b9ef9ac59b287cd55649f606105..a4a68a8ef25a66ca52052faf8a1e8e6221bec4af 100644 (file)
@@ -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);
index 1204663a52c73a3a98af34c42c4a93ec044e7200..173227f372f4d4cbf7445e5f3fea440220e70b4a 100644 (file)
@@ -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;i<processors;i++){
                                                m->appendFiles((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;
index 35f0b4d9cbcf5ed74568e5271a72f3eb4aae4a21..c86183459dcacebb606125fa12bea3ea08d41918 100644 (file)
--- 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);
 }
index 4ce73b33186425cc9cb62add6258fe9663328513..d43f85d16907d92583ba95069002661253569a6c 100644 (file)
@@ -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;
 
index 0390a806f97c5397d046c1384c1b4356280e78d9..de49daa32a31c6aa2a4bfbac97257ca993656a03 100644 (file)
@@ -75,7 +75,7 @@ int FormatPhylipMatrix::read(NameAssignment* nameMap){
                                        
                                        for(int j=0;j<i;j++){
                                        
-                                               if (m->control_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;j<nseqs;j++){
-                                               if (m->control_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");
                        
index ad706ef6bedeacf414ac9bbe3ad7119735b514d2..03c6b17a8a9be441c52070f2af24705eb8f3a168 100644 (file)
@@ -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();
index 1190f49d41036c3d3034d8555544725014ee49f0..194e8e16b1e388bdb8d01ac372fbc884cbc92e43 100644 (file)
@@ -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();
index 1ba8aa7bd6d2e8df8fbc513272c7784cafd3bc67..0065ec1fc152b24a0bf4d78b2bd5f06a12f859be 100644 (file)
@@ -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
index 0d836130d31124298a13c3a388267144cf5538ff..195c8229d4126846801c90d052c783bc2a49f9e6 100644 (file)
@@ -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
index 57afd85943e956b6bf4364d0b7c0b8bf27657cc3..980c886cc0cb79f51f892ee13fe4dc2c3061b812 100644 (file)
@@ -149,7 +149,7 @@ int GetListCountCommand::execute(){
                set<string> processedLabels;
                set<string> 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;  
                }
index 3e31691e6c8340d3ff7f02c0f316085f246f1b6b..9ed887a72ff7354c9396ba2d2c63f3b4a460afd3 100644 (file)
@@ -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<string> 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;
index d29773ca340cf1119f04c312f897a0e5f2d7d4e8..b94b42a8a37038d188bf19a430a7ee8951f2f86c 100644 (file)
@@ -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<string>::iterator it;
index 9c89f7f82f1f93cbaadfa1277d2b1002a7fa3f0b..5a33253ff1ec2b67a9e995b940f09349241494f5 100644 (file)
@@ -184,14 +184,14 @@ int GetRAbundCommand::execute(){
                set<string> processedLabels;
                set<string> 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);    }
index 693e36d000891339b843115fa11bd338dbc7a103..26d795808e826e9f13279bc8dcbbcfe9fc7ba14a 100644 (file)
@@ -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<string>::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();
index 799d8dced192019f65a633e946262db92c1e615f..4ae2eaa004f9df9cc75c12b63626ffa7fad71ea7 100644 (file)
@@ -178,7 +178,7 @@ int GetSAbundCommand::execute(){
                set<string> processedLabels;
                set<string> 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; }
                        
                }
                
index 71a2db9723c32a39ea8e158074fbfac8a29de1ca..5eba5ccc67b02436fbe39e09cc8fca52a2ea89cc 100644 (file)
@@ -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;
                
        }
index 046460d0f1d11f345c14ddd99b687fddbafa8ec9..02461365b505bdea22cc977594fc1341ca7bac46 100644 (file)
@@ -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 = "";
index e6e97fa9144f4ab4b79c35480e1c57b0235d733f..f0514655a35212215a49fbdb7b1c14c5a3415352 100644 (file)
@@ -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;
index ec4d35ceef2d37172d21d4d40a2ca6cfb9737404..b2af0349c9b341a635ad9eb341a3a5e35198f90e 100644 (file)
@@ -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;  
                }
                
index 0d8c5b03df532dc83e23f030e93d906c727842e3..9051a5d94ffd07d1ba5444f5d777556faf7fab77 100644 (file)
@@ -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();
index 38e344dfea67fdcfe89ce80a0476300d8ff50e3a..e791f0c65c88e55b8eaf7a022c3d6be454633f69 100644 (file)
@@ -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();
index e8863f75fbdf330b338a28bc5a19aa9f45ce5dc2..6fccaba1381a22a618686b6f0bbd4c447026ca3e 100644 (file)
@@ -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<float> IndicatorCommand::getPValues(vector< vector<SharedRAbundFloatVecto
                                        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; } 
                }
@@ -1296,7 +1296,7 @@ vector<float> IndicatorCommand::getPValues(vector< vector<SharedRAbundVector*> >
                                        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; } 
                }
index c993a06282d4abec617318d87ec9ec18bb64c5e2..96abbbe995918d779e4cd9086e650b7aa63a8a7b 100644 (file)
@@ -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();
index 3fe8360e3241477b869c26f5b1892541e28d84a4..ef1515863dbca8b0f930d1b26f3c9f2936c7eec4 100644 (file)
@@ -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);
                
index 82f730159c000888e544308ddfb58289a3363fc2..8e1a7f52882fe1cf8e3b12a60538915306dacb46 100644 (file)
@@ -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();
index 2cab212cf94a0a9908b764facdd55669ff222cc9..e32af2152e1bd3d420a0a94dac738a97c19c24af 100644 (file)
@@ -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;         }
                        }
index 780091027a66340b5ac94ff9480c792cba18281b..35a45532dc64d8d11ab415e777b3afe67ae94057 100644 (file)
@@ -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<string>::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<SharedRAbundVector*> thisLookup){
                                        }
                                }
                                intemp.close();
-                               remove(tempdistFileName.c_str());
+                               m->mothurRemove(tempdistFileName);
                        }
                        
                }
index c944e3bc8774aaa9ccffb712cdda823741c7d2e3..04c92fae9a0d2189cb8f1ed69c9c53572fcfee2e 100644 (file)
@@ -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();
index a01441ed7ad6db77aa26b1a147755cd7eaa354bc..8df6b62c5a1ccd997b6147e0018063193436649e 100644 (file)
@@ -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<string>::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
index 6601b09a365774b59ca8752f504fbfb5ab0cd4d3..70edc3d63cda154b51bca2dcb8ee36b9413a97a9 100644 (file)
@@ -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<col;i++){
@@ -187,11 +187,16 @@ int metastat_main (char* outputFileName, int numRows, int numCols, double thresh
                        prt=&prt1;
                        pre=&pre1;
                        
+                       //MothurFisher fishtere;
+                       //double mothurFex = fishtere.fexact(f11, f12, f21, f22);
+                       
                        fexact(nr,nc,data, ldtabl,expect,prc,emin,prt,pre,work);
                        
                        if (*pre>.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;
                }
index 0704f55896e835f331eda28446012e62c790904e..2a55ff08178cb0a7da3d99aff4b157017bb3d27e 100644 (file)
@@ -10,6 +10,7 @@
 #include "metastatscommand.h"
 #include "metastats.h"
 #include "sharedutilities.h"
+#include "mothurmetastats.h"
 
 //**********************************************************************************************************************
 vector<string> 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<string>::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<SharedRAbundVector*>& th
                        double** data;
                        data = new double*[thisLookUp[0]->getNumBins()];
                        
+                       vector< vector<double> > data2; data2.resize(thisLookUp[0]->getNumBins());
+                       
                        vector<SharedRAbundVector*> subset;
                        int setACount = 0;
                        int setBCount = 0;
@@ -428,14 +431,21 @@ int MetaStatsCommand::driver(int start, int num, vector<SharedRAbundVector*>& 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(); 
                        }
                        
index b982b8d1deb3cbc51716cf74339b8dcaea5d136d..f0886c8c133c12a84c627304cafbe8173ef45519 100644 (file)
@@ -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) {
index 5838811ac62648bfbf0b6da18ef715d2010b73c6..c9914229c9d41c72da266a46d5f26516e0f60fe4 100644 (file)
@@ -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 (file)
index 0000000..8cf332b
--- /dev/null
@@ -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_1<max) max=n_1;
+               double min = n1_+n_1-n;
+               if(min<0) min=0;
+               if(min==max)
+               {
+                       sless = 1;
+                       sright= 1;
+                       sleft = 1;
+                       slarg = 1;
+                       return 1;
+               }
+               prob=hyper0(n11,n1_,n_1,n);
+               sleft=0;
+               p=hyper(min);
+               for(i=min+1; p<0.99999999*prob; i++)
+               {
+                       sleft += p;
+                       p=hyper(i);
+               }
+               i--;
+               if(p<1.00000001*prob) sleft += p;
+               else i--;
+               sright=0;
+               p=hyper(max);
+               for(j=max-1; p<0.99999999*prob; j--)
+               {
+                       sright += p;
+                       p=hyper(j);
+               }
+               j++;
+               if(p<1.00000001*prob) sright += p;
+               else j++;
+               if(abs(i-n11)<abs(j-n11)) 
+               {
+                       sless = sleft;
+                       slarg = 1 - sleft + prob;
+               } 
+               else 
+               {
+                       sless = 1 - sright + prob;
+                       slarg = sright;
+               }
+               return prob;
+               
+       }catch(exception& e) {
+               m->errorOut(e, "MothurFisher", "hyper0");
+               exit(1);
+       }
+}
+/***********************************************************/
+
+
+
diff --git a/mothurfisher.h b/mothurfisher.h
new file mode 100644 (file)
index 0000000..88557d4
--- /dev/null
@@ -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 (file)
index 0000000..ed0aaef
--- /dev/null
@@ -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<double> >& 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<double> pmatrix; pmatrix.resize(size, 0.0);
+               vector<double> permuted; permuted.resize(size, 0.0);
+               vector< vector<double> > 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<double> total; total.resize(column, 0.0);
+               vector<double> 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<double> permuted_ttests; permuted_ttests.resize(row, 0.0);
+               vector<double> pvalues;                 pvalues.resize(row, 0.0);
+               vector<double> 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<double> fish;    fish.resize(row, 0.0);
+                       vector<double> 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<double> 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<double> sparse;          sparse.resize(row, 0.0);
+                       vector<double> 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<double> > 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<double>& Imatrix, int secondGroupingStart, vector<double>& initial, vector< vector<double> >& storage) {
+       try {
+               
+               int a = row; a*=4;
+               
+               double xbardiff = 0.0; double denom = 0.0;
+               vector<double> store;   store.resize(a, 0.0);
+               vector<double> tool;    tool.resize(a, 0.0);
+               vector< vector<double> > C1; C1.resize(row);
+               for (int i = 0; i < C1.size(); i++) { C1[i].resize(3, 0.0); }
+               vector< vector<double> > 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<double>& pmatrix, int secondGroupingStart, vector<double>& store) {
+       try {
+               vector<double> temp;    temp.resize(row, 0.0);
+               vector<double> temp2;   temp2.resize(row, 0.0);
+               vector<double> var;             var.resize(row, 0.0);
+               vector<double> 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<double>& permuted_ttests, vector<double>& permuted, vector<double>& Imatrix, int secondGroupingStart, vector<double>& Tinitial, vector<double>& ps) {
+       try {
+               
+               vector<double> Tvalues;         Tvalues.resize(row, 0.0);
+               vector<double> 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<double>& Imatrix, vector<double>& permuted, int secondGroupingStart, vector<double>& trial_ts, vector<double>& Tinitial, vector<double>& counter1){
+       try {
+       
+               vector<int> 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<int>& 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<double>& Pmatrix, int secondGroupingStart, vector<double>& Ts, vector<double>& Tinitial, vector<double>& counter) {
+       try {
+               int a = row * 4;
+               
+               vector< vector<double> > C1; C1.resize(row);
+               for (int i = 0; i < C1.size(); i++) { C1[i].resize(3, 0.0); }
+               vector< vector<double> > C2; C2.resize(row);
+               for (int i = 0; i < C2.size(); i++) { C2[i].resize(3, 0.0); }
+               vector<double> storage; storage.resize(row, 0.0);
+               vector<double> 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 (file)
index 0000000..37d6166
--- /dev/null
@@ -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<double> >&, int); //outputFileName, data, secondGroupingStart
+       
+       private:
+               MothurOut* m;
+               int row, column, numPermutations;
+               double threshold;
+       
+               int start(vector<double>&, int, vector<double>&, vector< vector<double> >&); //Find the initial values for the matrix
+               int meanvar(vector<double>&, int, vector<double>&);
+               int testp(vector<double>&, vector<double>&, vector<double>&, int, vector<double>&, vector<double>&);
+               int permute_matrix(vector<double>&, vector<double>&, int, vector<double>&, vector<double>&, vector<double>&);
+               int permute_array(vector<int>&);
+               int calc_twosample_ts(vector<double>&, int, vector<double>&, vector<double>&, vector<double>&);
+
+
+
+       
+};
+       
+       //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
+
index 9896157d0fa8a968446e4e5f345398b59c6ef711..367f5d12fc0555833061fb3d3dcabb4581006e64 100644 (file)
@@ -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<vector<double> > MothurOut::binomial(int maxOrder){
index f68e45324d0939182be7eb1b4b373b2c502d5c80..6cdf4933266362c0cbaa3333d05045385668ab6b 100644 (file)
@@ -70,6 +70,7 @@ class MothurOut {
                map<string, int> readNames(string);
                int readNames(string, map<string, string>&);
                int readNames(string, vector<seqPriorityNode>&, map<string, string>&);
+               void mothurRemove(string);
                
                //searchs and checks
                bool checkReleaseVersion(ifstream&, string);
index 946aa68ab24ed5a10800d6d5c9e2ca32f4fd2ade..da82784f56124d5a360294fb9cc7c4b6b1114307 100644 (file)
@@ -217,21 +217,21 @@ int NMDSCommand::execute(){
                                vector< vector<double> > 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<double> > 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<double> > 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();
index a4bdd47099c350e77cfe238bcf34e254d1db9341..10c7a3068da7bf4ce015e221b6ca042cbd7ffb7d 100644 (file)
@@ -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<string>::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<string>::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<SharedRAbundVector*>& thisLookUp, o
                if (pickedGroups) { eliminateZeroOTUS(thisLookUp); }
                                
                if (method == "totalgroup") { 
+                       
+                       //save numSeqs since they will change as the data is normalized
+                       vector<int> 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<SharedRAbundVector*>& 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<SharedRAbundFloatVector*>& thisLook
                
                if (method == "totalgroup") { 
                        
+                       //save numSeqs since they will change as the data is normalized
+                       vector<float> 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<SharedRAbundFloatVector*>& 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());
index b1f05398963ec330aa4a9409299715a02e25600e..2f99aa6091452933f6796f21aa043449bfce1dd4 100644 (file)
@@ -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();
index 75a1388694284e7dedb1caee31c577cb7ce29d04..ebbf686e20ce080f2889cb91d9e5063c63592579 100644 (file)
@@ -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;i<processIDS.size();i++) { 
                        m->appendFiles((filename + toString(processIDS[i]) + ".temp"), filename);
-                       remove((filename + toString(processIDS[i]) + ".temp").c_str());
+                       m->mothurRemove((filename + toString(processIDS[i]) + ".temp"));
                }
 #endif
        }
index 1033ba5d5dd3a64b001e2e8bc120b792df02e824..9cba70b9d2772edba281cd5f03459d1fdc32a966 100644 (file)
@@ -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 = "";
index e2c3e011c028a71bf79585519a7bbd9e25439c74..9459294fa49945a00b270c1d98529de0a93c008d 100644 (file)
@@ -195,7 +195,7 @@ int ParseListCommand::execute(){
                if (m->control_pressed) { 
                        delete input; delete list; delete groupMap;
                        for (i=0; i<groupMap->namesOfGroups.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; i<groupMap->namesOfGroups.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; i<groupMap->namesOfGroups.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; i<groupMap->namesOfGroups.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;
                }
                
index 54a3ffd93180376ff8a1efe67b121af3d36b9bc2..6ec6c57823a9055b6b70a97b9b9b06b6bb00074b 100644 (file)
@@ -155,7 +155,7 @@ EstOutput Parsimony::createProcesses(Tree* t, vector< vector<string> > namesOfGr
                                m->gobble(in);
                        }
                        in.close();
-                       remove(s.c_str());
+                       m->mothurRemove(s);
                }
                
                return results;
index 6e69cad4f8dbde50541a8daad71dbcce712b8953..ff1209287b4e17b2fcc58678703123aae2cadbc1 100644 (file)
@@ -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();
index 8dee743e07bd4fb546d907e41fd7ab97f6f71664..3a92fa002559fcc7d7f19e1f5f91fe2574f4a3c1 100644 (file)
@@ -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<string>::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<SharedRAbundFloatVector*>& lookupFloat){
                                
                                vector< vector<double> > 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; }
                        }
                }
                
index 20e8e1be712765513c1f581b4e94536207f4f773..02e165e978dc071ba19808139060866d7e41388c 100644 (file)
@@ -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<double> > 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; }
                        }
                }
                
index abb12435b0a414cf3bcea5f69505ba263fe733de..d273e1dd3f4aab843190aceb4888e547a8bd81f5 100644 (file)
@@ -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<int>& procIters, Tree* t, map<
                        }
                                
                        in.close();
-                       remove(inTemp.c_str());
+                       m->mothurRemove(inTemp);
                }
                
 #endif
index 26ae3a83df25e18c8d2d59344b12f0d9c471e401..873e5d1788162611db706617d9cf17f73df6a48b 100644 (file)
@@ -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);
index ef23375df9425f11816acbf8594f46e613e9e148..e6dace8b796103804c16a4de86104cff0b05da4f 100644 (file)
@@ -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; 
                }
                
index f793535bc3fb916c403f35288c19d6bbc1957b52..f6e7aa5b8db516d29dd7a3366d8ea32a603633ca 100644 (file)
@@ -612,7 +612,7 @@ void Pintail::createProcessesQuan() {
                        }
                                        
                        in.close();
-                       remove(s.c_str());
+                       m->mothurRemove(s);
                }
 
 #else
index f13b29cc7307595460876dc482e510d2996c8d2d..3f6e0c975750d7e6bd69845a32e11e7e20b2b68a 100644 (file)
@@ -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();
index b23ee1924d1a69ef8783a2d4f343f8b2cec74499..5b64b133a0c3df43cfb018c03d9867136661f100 100644 (file)
@@ -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) {
index d8a6b5cc2be05f8022da2c9234a358bb6fa98e8c..ca105b7f82fad6be8cc45e7b9e7953da3f4471e4 100644 (file)
@@ -157,7 +157,7 @@ int Rarefact::createProcesses(vector<int>& procIters, RarefactionCurveData* rcd,
                        for(int j=0;j<displays.size();j++){
                                string s = toString(processIDS[i]) + toString(j) + ".rarefact.temp";
                                displays[j]->inputTempFiles(s);
-                               remove(s.c_str());
+                               m->mothurRemove(s);
                        }
                }
                
index b9007f4c430de320ba2a63d32c98cd30a08fcb83..82211144eda568cf86f3ca0684a67c2fe64e0bb3 100644 (file)
@@ -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<string> processedLabels;
                        set<string> userLabels = labels;
                        
-                       if (m->control_pressed) { for(int i=0;i<rDisplays.size();i++){  delete rDisplays[i];    }  delete input;  delete order;  for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; }
+                       if (m->control_pressed) { for(int i=0;i<rDisplays.size();i++){  delete rDisplays[i];    }  delete input;  delete order;  for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(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;i<rDisplays.size();i++){  delete rDisplays[i];    }  delete input;  delete order;  for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; }
+                               if (m->control_pressed) { for(int i=0;i<rDisplays.size();i++){  delete rDisplays[i];    }  delete input;  delete order;  for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(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;i<rDisplays.size();i++){  delete rDisplays[i];    }  delete input;   for (int i = 0; i < outputNames.size(); i++) {       remove(outputNames[i].c_str()); } return 0; }
+                       if (m->control_pressed) { for(int i=0;i<rDisplays.size();i++){  delete rDisplays[i];    }  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<string>::iterator it;
@@ -418,7 +418,7 @@ int RareFactCommand::execute(){
                                }
                        }
                        
-                       if (m->control_pressed) { for(int i=0;i<rDisplays.size();i++){  delete rDisplays[i];    }  delete input;   for (int i = 0; i < outputNames.size(); i++) {       remove(outputNames[i].c_str()); } return 0; }
+                       if (m->control_pressed) { for(int i=0;i<rDisplays.size();i++){  delete rDisplays[i];    }  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)  {
@@ -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<string> RareFactCommand::parseSharedFile(string filename) {
                
                //clears file before we start to write to it below
                for (int i=0; i<lookup.size(); i++) {
-                       remove((sharedFileRoot + lookup[i]->getGroup() + ".rabund").c_str());
+                       m->mothurRemove((sharedFileRoot + lookup[i]->getGroup() + ".rabund"));
                        filenames.push_back((sharedFileRoot + lookup[i]->getGroup() + ".rabund"));
                }
                
index 717fec2fea1fc1ba23564fc683149e38d177496e..02f434ae79f2d74c814aef0a6c4f7ecfa67f1ab4 100644 (file)
@@ -214,7 +214,7 @@ int RareFactSharedCommand::execute(){
                        m->Groups.clear(); 
                        delete input;
                        for(int i=0;i<rDisplays.size();i++){    delete rDisplays[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]);        }
                        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;i<rDisplays.size();i++){    delete rDisplays[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]);        }
                                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;i<rDisplays.size();i++){    delete rDisplays[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;
                }
                
@@ -302,7 +302,7 @@ int RareFactSharedCommand::execute(){
                        m->Groups.clear(); 
                        delete input; 
                        for(int i=0;i<rDisplays.size();i++){    delete rDisplays[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;
                }
                
@@ -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();
index 66f1db23d633eb83b3706bd15f6deb48e8c7cb5b..2d4947745be0a52fafba4c33f38fb6504ede2288 100644 (file)
@@ -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;
                }
index d8227101b2c339b3904e95144d11f5cccb068dd3..b6cb71de5fdbb888f4a7c1614987f74cd0bf8b1a 100644 (file)
@@ -109,7 +109,7 @@ int ReadCluster::convertPhylip2Column(NameAssignment*& nameMap){
                                        
                                        for(int j=0;j<i;j++){
                                        
-                                               if (m->control_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;j<i;j++){
                                                
-                                               if (m->control_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;j<nseqs;j++){
-                                               if (m->control_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;j<nseqs;j++){
-                                               if (m->control_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;
        }
index 8dadc7e705c8fe78a9f4b47a3ed1479607745390..788bdcbfef41f0afeb080782e1bae651f8666258 100644 (file)
@@ -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;
                        }
index 9b537281b4abef7ecb9f270e1438993fca198e22..c9908fbc715f33eb33f75ff2005d51c9347678ff 100644 (file)
@@ -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
index d1db13f685f0c965b89b60d78ea26deb9616b81e..b72f4b669d43b4b44fa1c20df4812155aaff82fc 100644 (file)
@@ -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
                        
index 0fbed18b8be943fc4134cc18555c5a25cbd25b74..3390c201809f1ddf48ba0db779e50bb34b341933 100644 (file)
@@ -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<string>::iterator it;
index c320fa4d8854f003486bc71c8e6b0806ec7ae0e3..f82c4b03ead17a723b7d61e2643e5054907d9fd4 100644 (file)
@@ -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);
index b8bb46433cab982d8f29ef79adbd34dd5fa243b0..abd3c23eaadb0001b518ac226e34148a9bcb2f07 100644 (file)
@@ -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;
                
        }
index ea2ddeb8e718b44363409f0b332827feec41d6a9..c664ad7548b52f8966c799749f382d31169f564d 100644 (file)
@@ -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 = "";
index 9f7aa40b3cc6786388a4e9eb8e47326661460e2d..f751525b6b1fa6211ab6017063ba6c7090f6e484 100644 (file)
@@ -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;i<processors;i++){
                                        m->appendFiles((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<string> 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<string> 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<int>& 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<string> 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<string> 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<string> 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<string> 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<string> 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<string> 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<string> 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<string> 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;
index cc53ee0f02741cbe0fc6358a3a08cd56e891cd09..fe80b7810e716264152835060f25d1f2e45c1fed 100644 (file)
@@ -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();
index fc027b9261822880ac0afa1cc99929791a309df4..5c80047681c15640c5926d771536a42ea60a8c9d 100644 (file)
@@ -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         
index 8c7b9b69525abe705d432069043b4288c9830e23..2fbf6d1ca616033f4fd52993412f0e720f8187af 100644 (file)
@@ -297,7 +297,7 @@ int SeqSummaryCommand::execute(){
                                        //append files
                                        for(int i=1;i<processors;i++){
                                                m->appendFiles((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<int>& 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;
index ff1e2fe0709cf7e4d6549cc11a227ff9dc355e3f..0b3379cf230967f48e41c234e26c8c98b593c540 100644 (file)
@@ -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); 
                        }
index 207328203a24088c111054de2b157fae9235876c..341dd18fd442923df7751b85801714b00cf7a0d0 100644 (file)
@@ -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 = "";
index 38bc480836ba114e3ed55d0c1aa65f4e33d4218a..040fad846245c4c275a016391cf179eb64b763e1 100644 (file)
@@ -219,7 +219,7 @@ int SharedCommand::execute(){
                
                //clears file before we start to write to it below
                for (int i=0; i<Groups.size(); i++) {
-                       remove((fileroot + Groups[i] + ".rabund").c_str());
+                       m->mothurRemove((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; i<Groups.size(); i++) {  remove((fileroot + Groups[i] + ".rabund").c_str());              }
+                       out.close(); m->mothurRemove(filename); 
+                       for (int i=0; i<Groups.size(); i++) {  m->mothurRemove((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; i<Groups.size(); i++) {  remove((fileroot + Groups[i] + ".rabund").c_str());              }
+                               out.close(); m->mothurRemove(filename); 
+                               for (int i=0; i<Groups.size(); i++) {  m->mothurRemove((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; i<Groups.size(); i++) {  remove((fileroot + Groups[i] + ".rabund").c_str());              }
+                                               out.close(); m->mothurRemove(filename); 
+                                               for (int i=0; i<Groups.size(); i++) {  m->mothurRemove((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; i<Groups.size(); i++) {  remove((fileroot + Groups[i] + ".rabund").c_str());              }
+                                               out.close(); m->mothurRemove(filename); 
+                                               for (int i=0; i<Groups.size(); i++) {  m->mothurRemove((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; i<Groups.size(); i++) {  remove((fileroot + Groups[i] + ".rabund").c_str());              }
+                                       out.close(); m->mothurRemove(filename); 
+                                       for (int i=0; i<Groups.size(); i++) {  m->mothurRemove((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; i<Groups.size(); i++) {  remove((fileroot + Groups[i] + ".rabund").c_str());              }
+                               m->mothurRemove(filename); 
+                               for (int i=0; i<Groups.size(); i++) {  m->mothurRemove((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]);
                                
index a6fee2a3201bde30698cb145d9d92729c2cbdd74..5017f88bdfef592fd3996302ac0fbe9058088a49 100644 (file)
@@ -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;i<processIDs.size();i++) { 
                                m->appendFiles((fDistFileName + toString(processIDs[i]) + ".temp"), fDistFileName);
-                               remove((fDistFileName + toString(processIDs[i]) + ".temp").c_str());
+                               m->mothurRemove((fDistFileName + toString(processIDs[i]) + ".temp"));
                        }
                        
                }
index aa47940a030f968e02686b915d26e84c29584b8d..29ffdb44c16862994993566583393c0de9f6644a 100644 (file)
@@ -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<string>::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); }
index 6dd6206084fbe7ea81b9ad254ac2aedf28031407..00d9a9dc17b710467559bf598c988426ef5f3099 100644 (file)
@@ -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;
index 8ccb867e250aed20816be57d779d6105316109f9..dabcd0469461f25a79ac707cf0e785c19974cc1e 100644 (file)
@@ -146,7 +146,7 @@ int SplitMatrix::createDistanceFilesFromTax(map<string, int>& seqGroup, int numG
                set<string> 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<string, int>& 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<string, int>& 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<string, int>& 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<string, int>& 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<string, int>& 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<string, int>& 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<string, int>& 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<numGroups;i++){       if(groups[i].size() > 0){  remove((distFile + "." + toString(i) + ".temp").c_str()); }  } return 0; }
+                       if (m->control_pressed) {   dFile.close();  for(int i=0;i<numGroups;i++){       if(groups[i].size() > 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<set<string> >& 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<numGroups;i++){       if(groups[i].size() > 0){  remove((distFile + "." + toString(i) + ".temp").c_str()); }  } return 0; }
+                       if (m->control_pressed) {   dFile.close();  for(int i=0;i<numGroups;i++){       if(groups[i].size() > 0){  m->mothurRemove((distFile + "." + toString(i) + ".temp")); }  } return 0; }
                                        
                        if(dist < cutoff){
                                //cout << "in cutoff: " << dist << endl;
index 95a0442d6c970bd74a383c1e13765af305eeac57..d5388896793adbd55c925480ec708e460cb14b71 100644 (file)
@@ -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 = "";
index 2bb88770ec37651df7ff9da2954926abf3bf5153..629750bbccb5ed027edf5ef53dbba3686ddb4bba 100644 (file)
@@ -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<string> processedLabels;
                        set<string> 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;i<sumCalculators.size();i++){  delete sumCalculators[i]; }  delete sabund;  delete input;  return 0;  }
+                       if (m->control_pressed) {  outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) {     m->mothurRemove(outputNames[i]);  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }  delete sabund;  delete input;  return 0;  }
                        
                        while((sabund != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
                                
-                               if (m->control_pressed) { outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) {      remove(outputNames[i].c_str());  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }  delete sabund;  delete input;  return 0;  }
+                               if (m->control_pressed) { outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) {      m->mothurRemove(outputNames[i]);  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }  delete sabund;  delete input;  return 0;  }
                                
                                if(allLines == 1 || labels.count(sabund->getLabel()) == 1){                     
                                        
@@ -379,7 +379,7 @@ int SummaryCommand::execute(){
                                        for(int i=0;i<sumCalculators.size();i++){
                                                vector<double> 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;i<sumCalculators.size();i++){  delete sumCalculators[i]; }  delete sabund;  delete input;  return 0;  }
+                                               if (m->control_pressed) { outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) {      m->mothurRemove(outputNames[i]);  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }  delete sabund;  delete input;  return 0;  }
 
                                                outputFileHandle << '\t';
                                                sumCalculators[i]->print(outputFileHandle);
@@ -402,7 +402,7 @@ int SummaryCommand::execute(){
                                        for(int i=0;i<sumCalculators.size();i++){
                                                vector<double> 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;i<sumCalculators.size();i++){  delete sumCalculators[i]; } delete sabund;  delete input;  return 0;  }
+                                               if (m->control_pressed) {  outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) {      m->mothurRemove(outputNames[i]);  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; } delete sabund;  delete input;  return 0;  }
                                                
                                                outputFileHandle << '\t';
                                                sumCalculators[i]->print(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;i<sumCalculators.size();i++){  delete sumCalculators[i]; }   delete input;  return 0;  }
+                       if (m->control_pressed) {  outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) {     m->mothurRemove(outputNames[i]);  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }   delete input;  return 0;  }
 
                        //output error messages about any remaining user labels
                        set<string>::iterator it;
@@ -445,7 +445,7 @@ int SummaryCommand::execute(){
                                for(int i=0;i<sumCalculators.size();i++){
                                        vector<double> 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;i<sumCalculators.size();i++){  delete sumCalculators[i]; }  delete sabund;  delete input; return 0;  }
+                                       if (m->control_pressed) {  outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) {     m->mothurRemove(outputNames[i]);  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }  delete sabund;  delete input; return 0;  }
 
                                        outputFileHandle << '\t';
                                        sumCalculators[i]->print(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;i<sumCalculators.size();i++){  delete sumCalculators[i]; }   delete input;  return 0;  }
+                       if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]);  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }   delete input;  return 0;  }
 
                        
                        delete input;  
                        for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[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;  }
                
                //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<string> SummaryCommand::parseSharedFile(string filename) {
                
                //clears file before we start to write to it below
                for (int i=0; i<lookup.size(); i++) {
-                       remove((sharedFileRoot + lookup[i]->getGroup() + ".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
index b3b4b1869f4368c3c7555d5a711e95acb54c9283..77db937c6bfb325bdcb133848103d14b639155fe 100644 (file)
@@ -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;i<sumCalculators.size();i++){  delete sumCalculators[i]; }
@@ -403,8 +403,8 @@ int SummarySharedCommand::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) {
-                               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;i<sumCalculators.size();i++){  delete sumCalculators[i]; }
@@ -446,8 +446,8 @@ int SummarySharedCommand::execute(){
                }
                
                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<sumCalculators.size();i++){  delete sumCalculators[i]; }
                        m->Groups.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<SharedRAbundVector*> 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<SharedRAbundVector*> 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<SharedRAbundVector*> 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<SharedRAbundVector*> thisLookup, string
                                                                }
                                                        }
                                                        intemp.close();
-                                                       remove(tempdistFileName.c_str());
+                                                       m->mothurRemove(tempdistFileName);
                                                }
                                        }
 
@@ -604,10 +604,10 @@ int SummarySharedCommand::process(vector<SharedRAbundVector*> 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
                        
index ab9674f6836cafb373af0b89e43f4f7519476ae4..d0057e8b4e8c199f9113f54af6a46836ab6f58b4 100644 (file)
@@ -106,7 +106,7 @@ int SystemCommand::execute(){
                in.close();
                
                m->mothurOut(output); m->mothurOutEndLine();
-               remove(filename.c_str());
+               m->mothurRemove(filename);
                                
                return 0;               
        }
index d3b24d1297f280f0b4f11a30724a3c9d61d8427f..2f6fc77c7c29f689c6283c68c76ae14d8eea2b79 100644 (file)
@@ -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(); }
                
        }
index 902b9a253b0aa7e5515b74adf464b7fe17a65e2c..f1be7cbfbf3ef3d51c60234f2705a706d8697a06 100644 (file)
@@ -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;
        
index ec043360ad1cd553d782d1d67ab531c9a4610778..d17e000e9ce3a2d36f6a432f8647e99b7f58549f 100644 (file)
@@ -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"));
                                        }
                                }
                        }
index a2c8021a57f6f3f076c8d1c9be7353eb8cffff93..21de6ac1f01e7ed4719443ecb578c0b4b9dac7b8 100644 (file)
@@ -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;k<fastaFileNames[j].size();k++){
                                                if (fastaFileNames[j][k] != "") {
                                                        m->appendFiles((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);
                        }
                        
                }
index 058555eeb26ef7608cd4a337e492cca135c3c55c..501e6123f3566d001e48ea266d5a64d42d14dd49 100644 (file)
@@ -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();
                
index 00bb5d6c39eb0894389be1e5fecaba838d4303bd..d6431a051b56f3144dcfc80d430e7d61351da30a 100644 (file)
@@ -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; s<numComp; s++) {
@@ -364,7 +364,7 @@ int UnifracWeightedCommand::execute() {
                                        #endif
                                        
                                        if (m->control_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<string> > 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;
index 90b6476543d67ee92d7c59624e2af8da2a7b2345..98bfa45542bc7e17bb7b95dde67d40bd1e282e52 100644 (file)
@@ -151,7 +151,7 @@ EstOutput Unweighted::createProcesses(Tree* t, vector< vector<string> > 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<string> > namesOfG
                                m->gobble(in);
                        }
                        in.close();
-                       remove(s.c_str());
+                       m->mothurRemove(s);
                }
                
                return results;
index 6d4c2a0616880aee92f5fec430f63df51606e929..7ee0489d8780341587f684aaac1555c97560152b 100644 (file)
@@ -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;
                        }
                }
index d0defc3394b8aa3dc7010837c12ad4a8d0cfc472..70f6ae3eb1d621722ebd11221e88c92cc83b78eb 100644 (file)
@@ -139,7 +139,7 @@ EstOutput Weighted::createProcesses(Tree* t, vector< vector<string> > namesOfGro
                                m->gobble(in);
                        }
                        in.close();
-                       remove(s.c_str());
+                       m->mothurRemove(s);
                }
                
                m->mothurOut("DONE."); m->mothurOutEndLine(); m->mothurOutEndLine();