]> git.donarmstrong.com Git - mothur.git/blobdiff - parsesffcommand.cpp
added pipeline commands which involved change to command factory and command class...
[mothur.git] / parsesffcommand.cpp
index 03d8e96d44308c6a07eaba10344d8fce860e3943..c636ec99221d874ec6b497e2ae3965fd353c8dc0 100644 (file)
 #include "parsesffcommand.h"
 #include "sequence.hpp"
 
+//**********************************************************************************************************************
+vector<string> ParseSFFCommand::getValidParameters(){  
+       try {
+               string Array[] =  {"sff", "oligos", "minlength", "outputdir", "inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ParseSFFCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+ParseSFFCommand::ParseSFFCommand(){    
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["flow"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ParseSFFCommand", "ParseSFFCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ParseSFFCommand::getRequiredParameters(){       
+       try {
+               string Array[] =  {"sff"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ParseSFFCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ParseSFFCommand::getRequiredFiles(){    
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ParseSFFCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 
 ParseSFFCommand::ParseSFFCommand(string option){
@@ -36,6 +83,10 @@ ParseSFFCommand::ParseSFFCommand(string option){
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["flow"] = tempOutNames;
+                       
                        //if the user changes the input directory command factory will send this info to us in the output parameter 
                        string inputDir = validParameter.validFile(parameters, "inputdir", false);              
                        if (inputDir == "not found"){   inputDir = "";          }
@@ -115,7 +166,7 @@ int ParseSFFCommand::execute(){
                }
                else{
                        flowFileNames.push_back(new ofstream((outputDir + m->getRootName(m->getSimpleName(sffFile)) + "flow").c_str(), ios::ate));
-                       outputNames.push_back((outputDir + m->getRootName(m->getSimpleName(sffFile)) + "flow"));
+                       outputNames.push_back((outputDir + m->getRootName(m->getSimpleName(sffFile)) + "flow")); outputTypes["flow"].push_back((outputDir + m->getRootName(m->getSimpleName(sffFile)) + "flow"));
                }
                
                for(int i=0;i<flowFileNames.size();i++){
@@ -124,7 +175,7 @@ int ParseSFFCommand::execute(){
                        *flowFileNames[i] << setprecision(2);
                }                       
                
-               if (m->control_pressed) { for(int i=0;i<flowFileNames.size();i++){      flowFileNames[i]->close();  } return 0; }
+               if (m->control_pressed) { outputTypes.clear(); for(int i=0;i<flowFileNames.size();i++){ flowFileNames[i]->close();  } return 0; }
                
 //             ofstream fastaFile;
 //             m->openOutputFile(m->getRootName(sffFile) + "fasta", fastaFile);
@@ -151,7 +202,7 @@ int ParseSFFCommand::execute(){
                
                for(int i=0;i<numReads;i++){
                        
-                       if (m->control_pressed) { for(int i=0;i<flowFileNames.size();i++){      flowFileNames[i]->close();  } return 0; }
+                       if (m->control_pressed) { outputTypes.clear(); for(int i=0;i<flowFileNames.size();i++){ flowFileNames[i]->close();  } return 0; }
                        
                        inSFF >> seqName;
                        seqName = seqName.substr(1);
@@ -282,6 +333,7 @@ void ParseSFFCommand::getOligos(vector<ofstream*>& outSFFFlowVec){
                                        
                                        outSFFFlowVec.push_back(new ofstream((outputDir + m->getRootName(m->getSimpleName(sffFile)) + group + ".flow").c_str(), ios::ate));
                                        outputNames.push_back((outputDir + m->getRootName(m->getSimpleName(sffFile)) + group + "flow"));
+                                       outputTypes["flow"].push_back((outputDir + m->getRootName(m->getSimpleName(sffFile)) + group + "flow"));
                                }
                        }
                        m->gobble(inOligos);