]> git.donarmstrong.com Git - mothur.git/blobdiff - summaryqualcommand.h
fixes while testing 1.33.0
[mothur.git] / summaryqualcommand.h
index 1ec3cf1891893227d07d256cecd15f742ee9d127..b9edc5148ca5f7a834433815204b40f9ea317db4 100644 (file)
@@ -25,7 +25,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "summary.qual";                        }
        string getCommandCategory()             { return "Sequence Processing";         }
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Summary.qual"; }
        string getDescription()         { return "summarize the quality of a set of sequences"; }
        
@@ -34,7 +36,7 @@ public:
        
 private:
        bool abort;
-       string qualfile, outputDir, namefile;
+       string qualfile, outputDir, namefile, countfile;
        vector<string> outputNames;
        map<string, int> nameMap;
        int processors;
@@ -58,33 +60,31 @@ private:
 // This is passed by void pointer so it can be any data type
 // that can be passed using a single void pointer (LPVOID).
 struct seqSumQualData {
-       vector<int>* position;
-       vector<int>* averageQ;
-       vector< vector<int> >* scores; 
-       string filename, namefile
+       vector<int> position;
+       vector<int> averageQ;
+       vector< vector<int> > scores; 
+       string filename; 
        unsigned long long start;
        unsigned long long end;
-       int count;
+       int count, numSeqs;
        MothurOut* m;
+    bool hasNameMap;
        map<string, int> nameMap;
        
        ~seqSumQualData(){}
-       seqSumQualData(vector<int>* p, vector<int>* a, vector< vector<int> >* s, string f, MothurOut* mout, unsigned long long st, unsigned long long en, string n, map<string, int> nam) {
-               position = p;
-               averageQ = a;
-               scores = s;
+       seqSumQualData(string f, MothurOut* mout, unsigned long long st, unsigned long long en, bool n, map<string, int> nam) {
                filename = f;
                m = mout;
                start = st;
                end = en;
-               namefile = n;
+               hasNameMap = n;
                nameMap = nam;
                count = 0;
        }
 };
 
 /**************************************************************************************************/
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
 #else
 static DWORD WINAPI MySeqSumQualThreadFunction(LPVOID lpParam){ 
        seqSumQualData* pDataArray;
@@ -101,7 +101,8 @@ static DWORD WINAPI MySeqSumQualThreadFunction(LPVOID lpParam){
                        in.seekg(pDataArray->start-1); pDataArray->m->gobble(in); 
                }
                
-               int count = 0;
+               pDataArray->count = 0;
+        pDataArray->numSeqs = 0;
                for(int i = 0; i < pDataArray->end; i++){ //end is the number of sequences to process
                                
                        if (pDataArray->m->control_pressed) { in.close(); pDataArray->count = 1; return 1; }
@@ -111,7 +112,7 @@ static DWORD WINAPI MySeqSumQualThreadFunction(LPVOID lpParam){
                        if (current.getName() != "") {
                        
                                int num = 1;
-                               if (pDataArray->namefile != "") {
+                               if (pDataArray->hasNameMap) {
                                        //make sure this sequence is in the namefile, else error 
                                        map<string, int>::iterator it = pDataArray->nameMap.find(current.getName());
                                        
@@ -122,27 +123,27 @@ static DWORD WINAPI MySeqSumQualThreadFunction(LPVOID lpParam){
                                vector<int> thisScores = current.getQualityScores();
                                
                                //resize to num of positions setting number of seqs with that size to 1
-                               if (pDataArray->position->size() < thisScores.size()) { pDataArray->position->resize(thisScores.size(), 0); }
-                               if (pDataArray->averageQ->size() < thisScores.size()) { pDataArray->averageQ->resize(thisScores.size(), 0); }
-                               if (pDataArray->scores->size() < thisScores.size()) { 
-                                       pDataArray->scores->resize(thisScores.size()); 
-                                       for (int i = 0; i < pDataArray->scores->size(); i++) { pDataArray->scores->at(i).resize(41, 0); }
+                               if (pDataArray->position.size() < thisScores.size()) { pDataArray->position.resize(thisScores.size(), 0); }
+                               if (pDataArray->averageQ.size() < thisScores.size()) { pDataArray->averageQ.resize(thisScores.size(), 0); }
+                               if (pDataArray->scores.size() < thisScores.size()) { 
+                                       pDataArray->scores.resize(thisScores.size()); 
+                                       for (int i = 0; i < pDataArray->scores.size(); i++) { pDataArray->scores.at(i).resize(41, 0); }
                                }
                                
                                //increase counts of number of seqs with this position
                                //average is really the total, we will average in execute
                                for (int i = 0; i < thisScores.size(); i++) { 
-                                       pDataArray->position->at(i) += num; 
-                                       pDataArray->averageQ->at(i) += (thisScores[i] * num); //weighting for namesfile
+                                       pDataArray->position.at(i) += num; 
+                                       pDataArray->averageQ.at(i) += (thisScores[i] * num); //weighting for namesfile
                                        if (thisScores[i] > 40) { pDataArray->m->mothurOut("[ERROR]: " + current.getName() + " has a quality scores of " + toString(thisScores[i]) + ", expecting values to be less than 40."); pDataArray->m->mothurOutEndLine(); pDataArray->m->control_pressed = true; }
-                                       else { pDataArray->scores->at(i)[thisScores[i]] += num; }  
+                                       else { pDataArray->scores.at(i)[thisScores[i]] += num; }  
                                }
                                
-                               count += num;
+                               pDataArray->numSeqs += num;
+                pDataArray->count++;
                        }
                }
                
-               pDataArray->count = count;
                in.close();
                
                return 0;