]> git.donarmstrong.com Git - mothur.git/blobdiff - getrabundcommand.cpp
changes to read.otu(list/shared) - took out substr calls
[mothur.git] / getrabundcommand.cpp
index 5a192c5066d6f23921e356ed7a2785abbd967631..b7dd7153609ada80c297d5d51cab70d3cae5ebc4 100644 (file)
@@ -39,7 +39,7 @@ GetRAbundCommand::GetRAbundCommand(string option)  {
                        //if the user changes the output directory command factory will send this info to us in the output parameter 
                        string outputDir = validParameter.validFile(parameters, "outputdir", false);            if (outputDir == "not found"){  
                                outputDir = ""; 
-                               outputDir += hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it  
+                               outputDir += m->hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it       
                        }
                        
                        //make sure the user has already run the read.otu command
@@ -50,12 +50,12 @@ GetRAbundCommand::GetRAbundCommand(string option)  {
                        
                        string temp;
                        temp = validParameter.validFile(parameters, "sorted", false);                   if (temp == "not found") { temp = "T"; }
-                       sorted = isTrue(temp);
+                       sorted = m->isTrue(temp);
                        
                        label = validParameter.validFile(parameters, "label", false);                   
                        if (label == "not found") { label = ""; }
                        else { 
-                               if(label != "all") {  splitAtDash(label, labels);  allLines = 0;  }
+                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
                                else { allLines = 1;  }
                        }
                        
@@ -66,8 +66,8 @@ GetRAbundCommand::GetRAbundCommand(string option)  {
                        }
                                
                        if (abort == false) {
-                               filename = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + "rabund";
-                               openOutputFile(filename, out);
+                               filename = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + "rabund";
+                               m->openOutputFile(filename, out);
                        }
                }
 
@@ -99,9 +99,7 @@ void GetRAbundCommand::help(){
 
 //**********************************************************************************************************************
 
-GetRAbundCommand::~GetRAbundCommand(){
-       if (abort == false) {  globaldata->gListVector = NULL; }
-}
+GetRAbundCommand::~GetRAbundCommand(){}
 
 //**********************************************************************************************************************
 
@@ -122,6 +120,8 @@ int GetRAbundCommand::execute(){
                set<string> processedLabels;
                set<string> userLabels = labels;
                
+               if (m->control_pressed) {  out.close(); remove(filename.c_str());  delete list; globaldata->gListVector = NULL;  return 0; }
+               
                while((list != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
                        
                        if(allLines == 1 || labels.count(list->getLabel()) == 1){
@@ -129,6 +129,9 @@ int GetRAbundCommand::execute(){
                                        rabund = new RAbundVector();                            
                                        *rabund = (list->getRAbundVector());
                                        
+                                       if (m->control_pressed) {  out.close(); remove(filename.c_str());  delete list; delete rabund; globaldata->gListVector = NULL;  return 0; }
+
+                                       
                                        if(sorted)      {   rabund->print(out);                         }
                                        else            {       rabund->nonSortedPrint(out);    }
                                        
@@ -138,7 +141,7 @@ int GetRAbundCommand::execute(){
                                        userLabels.erase(list->getLabel());
                        }
                        
-                       if ((anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                       if ((m->anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
                                        string saveLabel = list->getLabel();
                                        
                                        delete list;
@@ -148,6 +151,8 @@ int GetRAbundCommand::execute(){
                                        rabund = new RAbundVector();
                                        *rabund = (list->getRAbundVector());
                                        
+                                       if (m->control_pressed) {  out.close(); remove(filename.c_str());  delete list; delete rabund; globaldata->gListVector = NULL;  return 0; }
+                                       
                                        if(sorted)      {   rabund->print(out);                         }
                                        else            {       rabund->nonSortedPrint(out);    }
 
@@ -188,6 +193,8 @@ int GetRAbundCommand::execute(){
                        rabund = new RAbundVector();
                        *rabund = (list->getRAbundVector());
                        
+                       if (m->control_pressed) {  out.close(); remove(filename.c_str());  delete list; delete rabund; globaldata->gListVector = NULL;  return 0; }
+                       
                        if(sorted)      {   rabund->print(out);                         }
                        else            {       rabund->nonSortedPrint(out);    }
 
@@ -199,9 +206,11 @@ int GetRAbundCommand::execute(){
                m->mothurOut("Output File Name: "); m->mothurOutEndLine();
                m->mothurOut(filename); m->mothurOutEndLine();  
                m->mothurOutEndLine();
-
                
                out.close(); 
+               
+               globaldata->gListVector = NULL;
+               
                return 0;               
        }