]> git.donarmstrong.com Git - mothur.git/blobdiff - seqsummarycommand.cpp
sffinfo bug with flow grams right index when clipQualRight=0
[mothur.git] / seqsummarycommand.cpp
index a9bb5737eac832a203969460f7f4e2759849a975..fdf95ee6fc5f87ed7629de936f4b0543dc89906a 100644 (file)
 //**********************************************************************************************************************
 vector<string> SeqSummaryCommand::setParameters(){     
        try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "namecount", "none", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "namecount", "none", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","summary",false,true,true); parameters.push_back(pfasta);
+               CommandParameter pname("name", "InputTypes", "", "", "namecount", "none", "none","",false,false,true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "namecount", "none", "none","",false,false,true); parameters.push_back(pcount);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -48,24 +48,19 @@ string SeqSummaryCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string SeqSummaryCommand::getOutputFileNameTag(string type, string inputName=""){      
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string SeqSummaryCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "summary")            {   outputFileName =  "summary";   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SeqSummaryCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "summary") {  pattern = "[filename],summary"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "SeqSummaryCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 
 //**********************************************************************************************************************
@@ -193,7 +188,9 @@ int SeqSummaryCommand::execute(){
                //set current fasta to fastafile
                m->setFastaFile(fastafile);
                
-               string summaryFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("summary");
+        map<string, string> variables; 
+               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(fastafile));
+               string summaryFile = getOutputFileName("summary",variables);
                                
                int numSeqs = 0;
                
@@ -410,7 +407,7 @@ int SeqSummaryCommand::execute(){
                if (m->control_pressed) {  m->mothurRemove(summaryFile); return 0; }
                
                m->mothurOutEndLine();
-               m->mothurOut("Output File Name: "); m->mothurOutEndLine();
+               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
                m->mothurOut(summaryFile); m->mothurOutEndLine();       outputNames.push_back(summaryFile); outputTypes["summary"].push_back(summaryFile);
                m->mothurOutEndLine();
                
@@ -450,7 +447,7 @@ int SeqSummaryCommand::driverCreateSummary(vector<int>& startPosition, vector<in
                        if (m->control_pressed) { in.close(); outSummary.close(); return 1; }
                                        
                        Sequence current(in); m->gobble(in);
-       
+           
                        if (current.getName() != "") {
                                
                                int num = 1;
@@ -678,6 +675,9 @@ int SeqSummaryCommand::createProcessesCreateSummary(vector<int>& startPosition,
                //Close all thread handles and free memory allocations.
                for(int i=0; i < pDataArray.size(); i++){
                        num += pDataArray[i]->count;
+            if (pDataArray[i]->count != pDataArray[i]->end) {
+                m->mothurOut("[ERROR]: process " + toString(i) + " only processed " + toString(pDataArray[i]->count) + " of " + toString(pDataArray[i]->end) + " sequences assigned to it, quitting. \n"); m->control_pressed = true; 
+            }
             for (int k = 0; k < pDataArray[i]->startPosition.size(); k++) {    startPosition.push_back(pDataArray[i]->startPosition[k]);       }
                        for (int k = 0; k < pDataArray[i]->endPosition.size(); k++) {   endPosition.push_back(pDataArray[i]->endPosition[k]);       }
             for (int k = 0; k < pDataArray[i]->seqLength.size(); k++) {        seqLength.push_back(pDataArray[i]->seqLength[k]);       }