]> git.donarmstrong.com Git - mothur.git/blobdiff - trimflowscommand.cpp
paralellized seq.error and dist.shared added some error checks to libshuff and dist...
[mothur.git] / trimflowscommand.cpp
index c4b5f43cc112861097b44829d6f4d300f9335d30..6ee865516bee6851fadf28f81e70bb249c35562d 100644 (file)
@@ -81,6 +81,7 @@ TrimFlowsCommand::TrimFlowsCommand(string option)  {
                
                //allow user to run help
                if(option == "help") { help(); abort = true; calledHelp = true; }
+               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
                
                else {
                                                
@@ -123,21 +124,19 @@ TrimFlowsCommand::TrimFlowsCommand(string option)  {
                                        if (path == "") {       parameters["oligos"] = inputDir + it->second;           }
                                }
                                
-                               
-//                             it = parameters.find("group");
-//                             //user has given a template file
-//                             if(it != parameters.end()){ 
-//                                     path = m->hasPath(it->second);
-//                                     //if the user has not given a path then, add inputdir. else leave path alone.
-//                                     if (path == "") {       parameters["group"] = inputDir + it->second;            }
-//                             }
                        }
                        
                        
                        //check for required parameters
                        flowFileName = validParameter.validFile(parameters, "flow", true);
-                       if (flowFileName == "not found") { m->mothurOut("flow is a required parameter for the trim.flows command."); m->mothurOutEndLine(); abort = true; }
-                       else if (flowFileName == "not open") { abort = true; }  
+                       if (flowFileName == "not found") { 
+                               flowFileName = m->getFlowFile(); 
+                               if (flowFileName != "") {  m->mothurOut("Using " + flowFileName + " as input file for the flow parameter."); m->mothurOutEndLine(); }
+                               else { 
+                                       m->mothurOut("No valid current flow file. You must provide a flow file."); m->mothurOutEndLine(); 
+                                       abort = true;
+                               } 
+                       }else if (flowFileName == "not open") { flowFileName = ""; abort = true; }      
                        
                        //if the user changes the output directory command factory will send this info to us in the output parameter 
                        outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  
@@ -150,10 +149,10 @@ TrimFlowsCommand::TrimFlowsCommand(string option)  {
                        // ...at some point should added some additional type checking...
                        
                        string temp;
-                       temp = validParameter.validFile(parameters, "minflows", false); if (temp == "not found") { temp = "360"; }
+                       temp = validParameter.validFile(parameters, "minflows", false); if (temp == "not found") { temp = "450"; }
                        convert(temp, minFlows);  
 
-                       temp = validParameter.validFile(parameters, "maxflows", false); if (temp == "not found") { temp = "720"; }
+                       temp = validParameter.validFile(parameters, "maxflows", false); if (temp == "not found") { temp = "450"; }
                        convert(temp, maxFlows);  
                        
                        
@@ -276,7 +275,7 @@ int TrimFlowsCommand::execute(){
                                        if (pFile==NULL) perror ("Error opening file");
                                        else{
                                                fseek (pFile, 0, SEEK_END);
-                                               size=ftell (pFile);
+                                               size=ftell(pFile);
                                                fclose (pFile);
                                        }
 
@@ -285,6 +284,8 @@ int TrimFlowsCommand::execute(){
                                        }
                                        else{
                                                output << barcodePrimerComboFileNames[i][j] << endl;
+                                               outputNames.push_back(barcodePrimerComboFileNames[i][j]);
+                                               outputTypes["flow"].push_back(barcodePrimerComboFileNames[i][j]);
                                        }
                                }
                        }
@@ -299,14 +300,14 @@ int TrimFlowsCommand::execute(){
                        output.close();
                }
                outputTypes["flow.files"].push_back(flowFilesFileName);
-               outputNames.push_back(flowFileName);
+               outputNames.push_back(flowFilesFileName);
                
-               //set fasta file as new current fastafile
-               string current = "";
-               itTypes = outputTypes.find("fasta");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
-               }
+//             set fasta file as new current fastafile
+//             string current = "";
+//             itTypes = outputTypes.find("fasta");
+//             if (itTypes != outputTypes.end()) {
+//                     if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
+//             }
                
                m->mothurOutEndLine();
                m->mothurOut("Output File Names: "); m->mothurOutEndLine();
@@ -574,8 +575,6 @@ void TrimFlowsCommand::getOligos(vector<vector<string> >& outFlowFileNames){
                                                fileName = outputDir + m->getRootName(m->getSimpleName(flowFileName)) + comboGroupName + ".flow";
                                        }
                                        
-                                       outputNames.push_back(fileName);
-                                       outputTypes["flow"].push_back(fileName);
                                        outFlowFileNames[itBar->second][itPrimer->second] = fileName;
                                        
                                        ofstream temp;