]> git.donarmstrong.com Git - mothur.git/blobdiff - unifracunweightedcommand.cpp
rewrote metastats command in c++, added mothurRemove function to handle ~ error....
[mothur.git] / unifracunweightedcommand.cpp
index 8ec2d06e75d3980b42cb9980ca1631a978418429..501e6123f3566d001e48ea266d5a64d42d14dd49 100644 (file)
@@ -146,16 +146,18 @@ UnifracUnweightedCommand::UnifracUnweightedCommand(string option)  {
                                treefile = m->getTreeFile(); 
                                if (treefile != "") { m->mothurOut("Using " + treefile + " as input file for the tree parameter."); m->mothurOutEndLine(); }
                                else {  m->mothurOut("You have no current tree file and the tree parameter is required."); m->mothurOutEndLine(); abort = true; }                                                               
-                       }       
+                       }else { m->setTreeFile(treefile); }     
                        
                        //check for required parameters
                        groupfile = validParameter.validFile(parameters, "group", true);
                        if (groupfile == "not open") { abort = true; }
                        else if (groupfile == "not found") { groupfile = ""; }
+                       else { m->setGroupFile(groupfile); }
                        
                        namefile = validParameter.validFile(parameters, "name", true);
                        if (namefile == "not open") { abort = true; }
                        else if (namefile == "not found") { namefile = ""; }
+                       else { m->setNameFile(namefile); }
                        
                        outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = ""; }
                        
@@ -256,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;
                                }
@@ -305,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; 
                        }
                        
@@ -327,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++) {
@@ -345,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
@@ -383,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);
@@ -403,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();