]> git.donarmstrong.com Git - mothur.git/blobdiff - seqsummarycommand.h
sffinfo bug with flow grams right index when clipQualRight=0
[mothur.git] / seqsummarycommand.h
index a7ccb573490135c10c6fdb7258bb46228047d98b..552f4a08bee284bf914e6a50cd51176864b8b1d8 100644 (file)
@@ -25,7 +25,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "summary.seqs";                        }
        string getCommandCategory()             { return "Sequence Processing";         }
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Summary.seqs"; }
        string getDescription()         { return "summarize the quality of sequences in an unaligned or aligned fasta file"; }
        
@@ -33,15 +35,15 @@ public:
        void help() { m->mothurOut(getHelpString()); }          
 private:
        bool abort;
-       string fastafile, outputDir, namefile;
+       string fastafile, outputDir, namefile, countfile;
        int processors;
        vector<string> outputNames;
        map<string, int> nameMap;
        
        struct linePair {
-               unsigned long int start;
-               unsigned long int end;
-               linePair(unsigned long int i, unsigned long int j) : start(i), end(j) {}
+               unsigned long long start;
+               unsigned long long end;
+               linePair(unsigned long long i, unsigned long long j) : start(i), end(j) {}
        };
 
        vector<linePair*> lines;
@@ -51,7 +53,7 @@ private:
        int driverCreateSummary(vector<int>&, vector<int>&, vector<int>&, vector<int>&, vector<int>&, string, string, linePair*);       
 
        #ifdef USE_MPI
-       int MPICreateSummary(int, int, vector<int>&, vector<int>&, vector<int>&, vector<int>&, vector<int>&, MPI_File&, MPI_File&, vector<unsigned long int>&); 
+       int MPICreateSummary(int, int, vector<int>&, vector<int>&, vector<int>&, vector<int>&, vector<int>&, MPI_File&, MPI_File&, vector<unsigned long long>&);        
        #endif
 
 
@@ -61,42 +63,37 @@ private:
 //custom data structure for threads to use.
 // This is passed by void pointer so it can be any data type
 // that can be passed using a single void pointer (LPVOID).
-typedef struct seqSumData {
-       vector<int>* startPosition;
-       vector<int>* endPosition;
-       vector<int>* seqLength; 
-       vector<int>* ambigBases; 
-       vector<int>* longHomoPolymer; 
+struct seqSumData {
+       vector<int> startPosition;
+       vector<int> endPosition;
+       vector<int> seqLength; 
+       vector<int> ambigBases; 
+       vector<int> longHomoPolymer; 
        string filename; 
        string sumFile; 
-       unsigned long int start;
-       unsigned long int end;
+       unsigned long long start;
+       unsigned long long end;
        int count;
        MothurOut* m;
-       string namefile;
+       bool hasNameMap;
        map<string, int> nameMap;
        
        
        seqSumData(){}
-       seqSumData(vector<int>* s, vector<int>* e, vector<int>* l, vector<int>* a, vector<int>* h, string f, string sf, MothurOut* mout, unsigned long int st, unsigned long int en, string na, map<string, int> nam) {
-               startPosition = s;
-               endPosition = e;
-               seqLength = l;
-               ambigBases = a;
-               longHomoPolymer = h;
+       seqSumData(string f, string sf, MothurOut* mout, unsigned long long st, unsigned long long en, bool na, map<string, int> nam) {
                filename = f;
                sumFile = sf;
                m = mout;
                start = st;
                end = en;
-               namefile = na;
+               hasNameMap = na;
                nameMap = nam;
                count = 0;
        }
 };
 
 /**************************************************************************************************/
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
 #else
 static DWORD WINAPI MySeqSumThreadFunction(LPVOID lpParam){ 
        seqSumData* pDataArray;
@@ -117,9 +114,10 @@ static DWORD WINAPI MySeqSumThreadFunction(LPVOID lpParam){
                        in.seekg(pDataArray->start-1); pDataArray->m->gobble(in); 
                }
                
-               pDataArray->count = pDataArray->end;
                for(int i = 0; i < pDataArray->end; i++){ //end is the number of sequences to process
                        
+            pDataArray->count++;
+            
                        if (pDataArray->m->control_pressed) { in.close(); outSummary.close(); pDataArray->count = 1; return 1; }
                        
                        Sequence current(in); pDataArray->m->gobble(in); 
@@ -127,21 +125,21 @@ static DWORD WINAPI MySeqSumThreadFunction(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());
                                        
-                                       if (it == pDataArray->nameMap.end()) { pDataArray->m->mothurOut("[ERROR]: " + current.getName() + " is not in your namefile, please correct."); pDataArray->m->mothurOutEndLine(); pDataArray->m->control_pressed = true; }
+                                       if (it == pDataArray->nameMap.end()) { pDataArray->m->mothurOut("[ERROR]: " + current.getName() + " is not in your name or count file, please correct."); pDataArray->m->mothurOutEndLine(); pDataArray->m->control_pressed = true; }
                                        else { num = it->second; }
                                }
                                
                                //for each sequence this sequence represents
                                for (int i = 0; i < num; i++) {
-                                       pDataArray->startPosition->push_back(current.getStartPos());
-                                       pDataArray->endPosition->push_back(current.getEndPos());
-                                       pDataArray->seqLength->push_back(current.getNumBases());
-                                       pDataArray->ambigBases->push_back(current.getAmbigBases());
-                                       pDataArray->longHomoPolymer->push_back(current.getLongHomoPolymer());
+                                       pDataArray->startPosition.push_back(current.getStartPos());
+                                       pDataArray->endPosition.push_back(current.getEndPos());
+                                       pDataArray->seqLength.push_back(current.getNumBases());
+                                       pDataArray->ambigBases.push_back(current.getAmbigBases());
+                                       pDataArray->longHomoPolymer.push_back(current.getLongHomoPolymer());
                                }
                                
                                outSummary << current.getName() << '\t';