]> git.donarmstrong.com Git - mothur.git/blobdiff - binsequencecommand.cpp
fixed project
[mothur.git] / binsequencecommand.cpp
index 274a8901db3c8f17ad7e70519916c009e5613193..033cd52e9e323e1707f603f8c20aaf22f50d4ecc 100644 (file)
@@ -181,6 +181,7 @@ int BinSeqCommand::execute(){
                        readNamesFile();
                }
                
+               
                //read list file
                read = new ReadOTUFile(globaldata->getListFile());      
                read->read(&*globaldata); 
@@ -189,6 +190,8 @@ int BinSeqCommand::execute(){
                list = globaldata->gListVector;
                string lastLabel = list->getLabel();
                
+               if (m->control_pressed) {  return 0; }
+               
                //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
                set<string> processedLabels;
                set<string> userLabels = labels;
@@ -196,10 +199,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());         } return 0; }   
+                       
                        if(allLines == 1 || labels.count(list->getLabel()) == 1){
                                
                                error = process(list);  
-                               if (error == 1) { return 0; }   
+                               if (error == 1) { for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str());         } return 0; }   
                                                        
                                processedLabels.insert(list->getLabel());
                                userLabels.erase(list->getLabel());
@@ -212,7 +217,7 @@ int BinSeqCommand::execute(){
                                list = input->getListVector(lastLabel);
                                
                                error = process(list);  
-                               if (error == 1) { return 0; }
+                               if (error == 1) { for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str());         } return 0; }
                                                                                                        
                                processedLabels.insert(list->getLabel());
                                userLabels.erase(list->getLabel());
@@ -227,7 +232,8 @@ int BinSeqCommand::execute(){
                        list = input->getListVector();
                }
                
-               
+               if(m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str());         } return 0; }   
+
                //output error messages about any remaining user labels
                set<string>::iterator it;
                bool needToRun = false;
@@ -247,11 +253,13 @@ int BinSeqCommand::execute(){
                        list = input->getListVector(lastLabel);
                                
                        error = process(list);  
-                       if (error == 1) { return 0; }
+                       if (error == 1) { for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str());         } return 0; }
                        
                        delete list;  
                }
                
+               if(m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str());         } return 0; }   
+
                m->mothurOutEndLine();
                m->mothurOut("Output File Names: "); m->mothurOutEndLine();
                for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
@@ -315,7 +323,9 @@ int BinSeqCommand::process(ListVector* list) {
                                
                                //for each bin in the list vector
                                for (int i = 0; i < list->size(); i++) {
-
+                                       
+                                       if (m->control_pressed) {  return 1; }
+                                       
                                        binnames = list->get(i);
                                        while (binnames.find_first_of(',') != -1) { 
                                                name = binnames.substr(0,binnames.find_first_of(','));
@@ -333,7 +343,6 @@ int BinSeqCommand::process(ListVector* list) {
                                                                string group = groupMap->getGroup(name);
                                                                if (group == "not found") {  
                                                                        m->mothurOut(name + " is missing from your group file. Please correct. ");  m->mothurOutEndLine();
-                                                                       remove(outputFileName.c_str());
                                                                        return 1;
                                                                }else{
                                                                        name = name + "|" + group + "|" + toString(i+1);
@@ -343,7 +352,6 @@ int BinSeqCommand::process(ListVector* list) {
                                                        }
                                                }else { 
                                                        m->mothurOut(name + " is missing from your fasta or name file. Please correct. "); m->mothurOutEndLine();
-                                                       remove(outputFileName.c_str());
                                                        return 1;
                                                }
                                                
@@ -361,7 +369,6 @@ int BinSeqCommand::process(ListVector* list) {
                                                        string group = groupMap->getGroup(binnames);
                                                        if (group == "not found") {  
                                                                m->mothurOut(binnames + " is missing from your group file. Please correct. "); m->mothurOutEndLine();
-                                                               remove(outputFileName.c_str());
                                                                return 1;
                                                        }else{
                                                                binnames = binnames + "|" + group + "|" + toString(i+1);
@@ -371,7 +378,6 @@ int BinSeqCommand::process(ListVector* list) {
                                                }
                                        }else { 
                                                m->mothurOut(binnames + " is missing from your fasta or name file. Please correct. "); m->mothurOutEndLine();
-                                               remove(outputFileName.c_str());
                                                return 1;
                                        }
                                }