]> git.donarmstrong.com Git - mothur.git/blobdiff - classifyseqscommand.cpp
added checks for ^C to quit command instead of program
[mothur.git] / classifyseqscommand.cpp
index 7a9a5e9b6f7b54d1218064cc03f7d5c94cb4d31d..ba854e98b40403c8d963fb65c9c4bd6178950947 100644 (file)
@@ -246,7 +246,9 @@ int ClassifySeqsCommand::execute(){
                        m->mothurOutEndLine();
                        classify = new Bayesian(taxonomyFileName, templateFileName, search, kmerSize, cutoff, iters);   
                }
-
+               
+               if (m->control_pressed) { delete classify; return 0; }
+               
                vector<string> outputNames;
                                
                for (int s = 0; s < fastaFileNames.size(); s++) {
@@ -343,7 +345,9 @@ int ClassifySeqsCommand::execute(){
 #endif 
                        //make taxonomy tree from new taxonomy file 
                        PhyloTree taxaBrowser;
-               
+                       
+                       if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       remove(outputNames[i].c_str()); } delete classify; return 0; }
+                       
                        ifstream in;
                        openInputFile(tempTaxonomyFile, in);
                
@@ -352,6 +356,8 @@ int ClassifySeqsCommand::execute(){
                        while(!in.eof()){
                                in >> name >> taxon; gobble(in);
                                
+                               if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       remove(outputNames[i].c_str()); } remove(tempTaxonomyFile.c_str()); delete classify; return 0; }
+                               
                                if (namefile != "") {
                                        itNames = nameMap.find(name);
                
@@ -367,11 +373,16 @@ int ClassifySeqsCommand::execute(){
                        in.close();
        
                        taxaBrowser.assignHeirarchyIDs(0);
+                       
+                       if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       remove(outputNames[i].c_str()); } remove(tempTaxonomyFile.c_str()); delete classify; return 0; }
 
                        taxaBrowser.binUnclassified();
                        
                        remove(tempTaxonomyFile.c_str());
                        
+                       if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       remove(outputNames[i].c_str()); } delete classify; return 0; }
+
+                       
                        //print summary file
                        ofstream outTaxTree;
                        openOutputFile(taxSummary, outTaxTree);
@@ -389,8 +400,10 @@ int ClassifySeqsCommand::execute(){
                        //get maxLevel from phylotree so you know how many 'unclassified's to add
                        int maxLevel = taxaBrowser.getMaxLevel();
                        
-                       //read taxfile - this reading and rewriting is done to preserve the confidence sscores.
+                       //read taxfile - this reading and rewriting is done to preserve the confidence scores.
                        while (!inTax.eof()) {
+                               if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       remove(outputNames[i].c_str()); } remove(unclass.c_str()); delete classify; return 0; }
+
                                inTax >> name >> taxon; gobble(inTax);
                                
                                string newTax = addUnclassifieds(taxon, maxLevel);
@@ -526,11 +539,14 @@ int ClassifySeqsCommand::driver(linePair* line, string taxFName, string tempTFNa
                string taxonomy;
 
                for(int i=0;i<line->numSeqs;i++){
+                       if (m->control_pressed) { return 0; }
                        
                        Sequence* candidateSeq = new Sequence(inFASTA);
                        
                        if (candidateSeq->getName() != "") {
                                taxonomy = classify->getTaxonomy(candidateSeq);
+                               
+                               if (m->control_pressed) { delete candidateSeq; return 0; }
 
                                if (taxonomy != "bad seq") {
                                        //output confidence scores or not