]> git.donarmstrong.com Git - mothur.git/blobdiff - ccode.cpp
added checks for ^C to quit command instead of program
[mothur.git] / ccode.cpp
index 00a30e5b6c0db1f58cb90b3c564703b7d3d77f6d..3aad3f6b48780505cb5f88c733b28027e28968b1 100644 (file)
--- a/ccode.cpp
+++ b/ccode.cpp
@@ -35,7 +35,7 @@ void Ccode::printHeader(ostream& out) {
        out << "For full window mapping info refer to " << mapInfo << endl << endl;
 }
 //***************************************************************************************************************
-void Ccode::print(ostream& out, ostream& outAcc) {
+int Ccode::print(ostream& out, ostream& outAcc) {
        try {
                
                ofstream out2;
@@ -116,7 +116,7 @@ void Ccode::print(ostream& out, ostream& outAcc) {
                //free memory
                for (int i = 0; i < closest.size(); i++) {  delete closest[i].seq;  }
 
-               
+               return 0;
        }
        catch(exception& e) {
                m->errorOut(e, "Ccode", "print");
@@ -154,6 +154,8 @@ int Ccode::getChimeras(Sequence* query) {
                //find closest matches to query
                closest = findClosest(query, numWanted);
                
+               if (m->control_pressed) {  return 0;  }
+               
                //initialize spotMap
                for (int i = 0; i < query->getAligned().length(); i++) {        spotMap[i] = i;         }
        
@@ -176,7 +178,10 @@ int Ccode::getChimeras(Sequence* query) {
                        
                        createFilter(temp, 0.5);
                
-                       for (int i = 0; i < temp.size(); i++) { runFilter(temp[i]);  }
+                       for (int i = 0; i < temp.size(); i++) { 
+                               if (m->control_pressed) {  return 0;  }
+                               runFilter(temp[i]);  
+                       }
                        
                        //update spotMap
                        map<int, int> newMap;
@@ -194,30 +199,32 @@ int Ccode::getChimeras(Sequence* query) {
 
                //trim sequences - this follows ccodes remove_extra_gaps 
                trimSequences(query);
-               
+               if (m->control_pressed) {  return 0;  }
                
                //windows are equivalent to words - ccode paper recommends windows are between 5% and 20% on alignment length().  
                //Our default will be 10% and we will warn if user tries to use a window above or below these recommendations
                windows = findWindows();  
-               
+               if (m->control_pressed) {  return 0;  }
 
                //remove sequences that are more than 20% different and less than 0.5% different - may want to allow user to specify this later 
                removeBadReferenceSeqs(closest);
-               
+               if (m->control_pressed) {  return 0;  }
                
                //find the averages for each querys references
                getAverageRef(closest);  //fills sumRef, averageRef, sumSquaredRef and refCombo.
                getAverageQuery(closest, query);  //fills sumQuery, averageQuery, sumSquaredQuery.
-                                       
+               if (m->control_pressed) {  return 0;  }                 
                
                //find the averages for each querys references 
                findVarianceRef();  //fills varRef and sdRef also sets minimum error rate to 0.001 to avoid divide by 0.
-                       
+               if (m->control_pressed) {  return 0;  } 
                        
                //find the averages for the query 
                findVarianceQuery();  //fills varQuery and sdQuery also sets minimum error rate to 0.001 to avoid divide by 0.
+               if (m->control_pressed) {  return 0;  }
                                        
                determineChimeras();  //fills anova, isChimericConfidence, isChimericTStudent and isChimericANOVA. 
+               if (m->control_pressed) {  return 0;  }
                
                return 0;
        }