]> git.donarmstrong.com Git - mothur.git/commitdiff
added code to format fast files for uchime. started work on sff.multiple command
authorSarah Westcott <mothur.westcott@gmail.com>
Tue, 14 Aug 2012 18:33:21 +0000 (14:33 -0400)
committerSarah Westcott <mothur.westcott@gmail.com>
Tue, 14 Aug 2012 18:33:21 +0000 (14:33 -0400)
Mothur.xcodeproj/project.pbxproj
chimerauchimecommand.cpp
chimerauchimecommand.h
groupmap.cpp
sffmultiplecommand.cpp [new file with mode: 0644]
sffmultiplecommand.h [new file with mode: 0644]

index 104c6d5c12c6e4185823e2d5e833760134f8c16a..4c2e330a280e84434f269e5ee08d133a8fd8c2a4 100644 (file)
@@ -51,6 +51,7 @@
                A7BF2232145879B2000AD524 /* chimeraperseuscommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7BF2231145879B2000AD524 /* chimeraperseuscommand.cpp */; };
                A7C3DC0B14FE457500FE1924 /* cooccurrencecommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7C3DC0914FE457500FE1924 /* cooccurrencecommand.cpp */; };
                A7C3DC0F14FE469500FE1924 /* trialSwap2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7C3DC0D14FE469500FE1924 /* trialSwap2.cpp */; };
+               A7C7DAB915DA758B0059B0CF /* sffmultiplecommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7C7DAB815DA758B0059B0CF /* sffmultiplecommand.cpp */; };
                A7D755DA1535F679009BF21A /* treereader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7D755D91535F679009BF21A /* treereader.cpp */; };
                A7E0243D15B4520A00A5F046 /* sparsedistancematrix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7E0243C15B4520A00A5F046 /* sparsedistancematrix.cpp */; };
                A7E9B88112D37EC400DA6239 /* ace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7E9B64F12D37EC300DA6239 /* ace.cpp */; };
                A7C3DC0A14FE457500FE1924 /* cooccurrencecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cooccurrencecommand.h; sourceTree = "<group>"; };
                A7C3DC0D14FE469500FE1924 /* trialSwap2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = trialSwap2.cpp; sourceTree = "<group>"; };
                A7C3DC0E14FE469500FE1924 /* trialswap2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = trialswap2.h; sourceTree = "<group>"; };
+               A7C7DAB615DA75760059B0CF /* sffmultiplecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sffmultiplecommand.h; sourceTree = "<group>"; };
+               A7C7DAB815DA758B0059B0CF /* sffmultiplecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sffmultiplecommand.cpp; sourceTree = "<group>"; };
                A7D755D71535F665009BF21A /* treereader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = treereader.h; sourceTree = "<group>"; };
                A7D755D91535F679009BF21A /* treereader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = treereader.cpp; sourceTree = "<group>"; };
                A7DAAFA3133A254E003956EB /* commandparameter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = commandparameter.h; sourceTree = "<group>"; };
                                A7E9B7E112D37EC400DA6239 /* setlogfilecommand.cpp */,
                                A7E9B7E412D37EC400DA6239 /* sffinfocommand.h */,
                                A7E9B7E312D37EC400DA6239 /* sffinfocommand.cpp */,
+                               A7C7DAB615DA75760059B0CF /* sffmultiplecommand.h */,
+                               A7C7DAB815DA758B0059B0CF /* sffmultiplecommand.cpp */,
                                A7E9B7F312D37EC400DA6239 /* sharedcommand.h */,
                                A7E9B7F212D37EC400DA6239 /* sharedcommand.cpp */,
                                A7E9B82812D37EC400DA6239 /* shhhercommand.h */,
                                A74D59A4159A1E2000043046 /* counttable.cpp in Sources */,
                                A7E0243D15B4520A00A5F046 /* sparsedistancematrix.cpp in Sources */,
                                A741FAD215D1688E0067BCC5 /* sequencecountparser.cpp in Sources */,
+                               A7C7DAB915DA758B0059B0CF /* sffmultiplecommand.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index bad4c96b8c74d645208be1158ad11cd2ef924faf..461c3b693c2c79315d1d98263ce55340541496bb 100644 (file)
@@ -1173,24 +1173,18 @@ int ChimeraUchimeCommand::driver(string outputFName, string filename, string acc
 #else
                uchimeCommand = "\"" + uchimeCommand + "\"";
 #endif
-               
-               char* tempUchime;
+        char* tempUchime;
                tempUchime= new char[uchimeCommand.length()+1]; 
                *tempUchime = '\0';
                strncat(tempUchime, uchimeCommand.c_str(), uchimeCommand.length());
                cPara.push_back(tempUchime);
                
-               char* tempIn = new char[8]; 
-               *tempIn = '\0'; strncat(tempIn, "--input", 7);
-               //strcpy(tempIn, "--input"); 
-               cPara.push_back(tempIn);
-               char* temp = new char[filename.length()+1];
-               *temp = '\0'; strncat(temp, filename.c_str(), filename.length());
-               //strcpy(temp, filename.c_str());
-               cPara.push_back(temp);
-               
-               //are you using a reference file
+        //are you using a reference file
                if (templatefile != "self") {
+            string outputFileName = filename.substr(1, filename.length()-2) + ".uchime_formatted";
+            prepFile(filename.substr(1, filename.length()-2), outputFileName);
+            filename = outputFileName;
+            filename = "\"" + filename + "\"";
                        //add reference file
                        char* tempRef = new char[5]; 
                        //strcpy(tempRef, "--db"); 
@@ -1202,6 +1196,15 @@ int ChimeraUchimeCommand::driver(string outputFName, string filename, string acc
                        cPara.push_back(tempR);
                }
                
+               char* tempIn = new char[8]; 
+               *tempIn = '\0'; strncat(tempIn, "--input", 7);
+               //strcpy(tempIn, "--input"); 
+               cPara.push_back(tempIn);
+               char* temp = new char[filename.length()+1];
+               *temp = '\0'; strncat(temp, filename.c_str(), filename.length());
+               //strcpy(temp, filename.c_str());
+               cPara.push_back(temp);
+               
                char* tempO = new char[12]; 
                *tempO = '\0'; strncat(tempO, "--uchimeout", 11);
                //strcpy(tempO, "--uchimeout"); 
@@ -1455,6 +1458,8 @@ int ChimeraUchimeCommand::driver(string outputFName, string filename, string acc
                in.close();
                out.close();
                
+        //if (templatefile != "self") {  m->mothurRemove(filename); }
+        
                return num;
        }
        catch(exception& e) {
@@ -1463,6 +1468,34 @@ int ChimeraUchimeCommand::driver(string outputFName, string filename, string acc
        }
 }
 /**************************************************************************************************/
+//uchime can't handle some of the things allowed in mothurs fasta files. This functions "cleans up" the file.
+int ChimeraUchimeCommand::prepFile(string filename, string output) {
+       try {
+        
+        ifstream in;
+        m->openInputFile(filename, in);
+        
+        ofstream out;
+        m->openOutputFile(output, out);
+        
+        while (!in.eof()) {
+            if (m->control_pressed) { break;  }
+            
+            Sequence seq(in); m->gobble(in);
+            
+            if (seq.getName() != "") { seq.printSequence(out); }
+        }
+        in.close();
+        out.close();
+        
+        return 0;
+    }
+       catch(exception& e) {
+               m->errorOut(e, "ChimeraUchimeCommand", "prepFile");
+               exit(1);
+       }
+}
+/**************************************************************************************************/
 
 int ChimeraUchimeCommand::createProcesses(string outputFileName, string filename, string accnos, string alns, int& numChimeras) {
        try {
index 659d1ea39963f05a245cda03acf56f3b6e3d10e9..67c77f24f4597838f959224ceaf6bab4467ce5df 100644 (file)
@@ -64,6 +64,7 @@ private:
        int deconvoluteResults(map<string, string>&, string, string, string);
        int driverGroups(string, string, string, string, int, int, vector<string>);
        int createProcessesGroups(string, string, string, string, vector<string>, string, string, string);
+    int prepFile(string filename, string);
 
 
 };
@@ -524,16 +525,31 @@ static DWORD WINAPI MyUchimeSeqsThreadFunction(LPVOID lpParam){
         strncat(tempUchime, uchimeCommand.c_str(), uchimeCommand.length());
         cPara.push_back(tempUchime);
                
-               char* tempIn = new char[8]; 
-               *tempIn = '\0'; strncat(tempIn, "--input", 7);
-               //strcpy(tempIn, "--input"); 
-               cPara.push_back(tempIn);
-               char* temp = new char[filename.length()+1];
-               *temp = '\0'; strncat(temp, filename.c_str(), filename.length());
-               //strcpy(temp, filename.c_str());
-               cPara.push_back(temp);
-       
-               //add reference file
+        string outputFileName = filename.substr(1, filename.length()-2) + ".uchime_formatted";
+        //prepFile(filename.substr(1, filename.length()-2), outputFileName);
+        //prepFile(filename, outputFileName);
+        /******************************************/
+        ifstream in23;
+        m->openInputFile((filename.substr(1, filename.length()-2)), in23);
+        
+        ofstream out23;
+        m->openOutputFile(outputFileName, out23);
+        
+        while (!in23.eof()) {
+            if (m->control_pressed) { break;  }
+            
+            Sequence seq(in23); m->gobble(in23);
+            
+            if (seq.getName() != "") { seq.printSequence(out23); }
+        }
+        in23.close();
+        out23.close();
+        /******************************************/
+        
+        filename = outputFileName;
+        filename = "\"" + filename + "\"";
+        
+        //add reference file
                char* tempRef = new char[5]; 
                //strcpy(tempRef, "--db"); 
                *tempRef = '\0'; strncat(tempRef, "--db", 4);
@@ -542,6 +558,15 @@ static DWORD WINAPI MyUchimeSeqsThreadFunction(LPVOID lpParam){
                //strcpy(tempR, templatefile.c_str());
                *tempR = '\0'; strncat(tempR, templatefile.c_str(), templatefile.length());
                cPara.push_back(tempR);
+        
+               char* tempIn = new char[8]; 
+               *tempIn = '\0'; strncat(tempIn, "--input", 7);
+               //strcpy(tempIn, "--input"); 
+               cPara.push_back(tempIn);
+               char* temp = new char[filename.length()+1];
+               *temp = '\0'; strncat(temp, filename.c_str(), filename.length());
+               //strcpy(temp, filename.c_str());
+               cPara.push_back(temp);
                
                char* tempO = new char[12]; 
                *tempO = '\0'; strncat(tempO, "--uchimeout", 11);
index 5b81210e89365a9d98048d10c92e9c518fe01938..7ce90733b72b02d6f05175d14b61f73599b58d2c 100644 (file)
@@ -44,6 +44,7 @@ int GroupMap::readMap() {
                 if (pairDone) { 
                     setNamesOfGroups(seqGroup);
                     
+                    if (m->debug) { m->mothurOut("[DEBUG]: name = '" + seqName + "', group = '" + seqGroup + "'\n"); }
                     it = groupmap.find(seqName);
                     
                     if (it != groupmap.end()) { error = 1; m->mothurOut("Your groupfile contains more than 1 sequence named " + seqName + ", sequence names must be unique. Please correct."); m->mothurOutEndLine();  }
@@ -67,6 +68,8 @@ int GroupMap::readMap() {
                 if (pairDone) { 
                     setNamesOfGroups(seqGroup);
                     
+                    if (m->debug) { m->mothurOut("[DEBUG]: name = '" + seqName + "', group = '" + seqGroup + "'\n"); }
+                    
                     it = groupmap.find(seqName);
                     
                     if (it != groupmap.end()) { error = 1; m->mothurOut("Your groupfile contains more than 1 sequence named " + seqName + ", sequence names must be unique. Please correct."); m->mothurOutEndLine();  }
@@ -110,6 +113,8 @@ int GroupMap::readDesignMap() {
                 if (pairDone) { 
                     setNamesOfGroups(seqGroup);
                     
+                    if (m->debug) { m->mothurOut("[DEBUG]: name = '" + seqName + "', group = '" + seqGroup + "'\n"); }
+                    
                     it = groupmap.find(seqName);
                     
                     if (it != groupmap.end()) { error = 1; m->mothurOut("Your designfile contains more than 1 sequence named " + seqName + ", sequence names must be unique. Please correct."); m->mothurOutEndLine();  }
@@ -133,6 +138,8 @@ int GroupMap::readDesignMap() {
                 if (pairDone) { 
                     setNamesOfGroups(seqGroup);
                     
+                    if (m->debug) { m->mothurOut("[DEBUG]: name = '" + seqName + "', group = '" + seqGroup + "'\n"); }
+                    
                     it = groupmap.find(seqName);
                     
                     if (it != groupmap.end()) { error = 1; m->mothurOut("Your designfile contains more than 1 sequence named " + seqName + ", sequence names must be unique. Please correct."); m->mothurOutEndLine();  }
@@ -180,6 +187,8 @@ int GroupMap::readDesignMap(string filename) {
                 if (pairDone) { 
                     setNamesOfGroups(seqGroup);
                     
+                    if (m->debug) { m->mothurOut("[DEBUG]: name = '" + seqName + "', group = '" + seqGroup + "'\n"); }
+                    
                     it = groupmap.find(seqName);
                     
                     if (it != groupmap.end()) { error = 1; m->mothurOut("Your designfile contains more than 1 sequence named " + seqName + ", sequence names must be unique. Please correct."); m->mothurOutEndLine();  }
@@ -203,6 +212,8 @@ int GroupMap::readDesignMap(string filename) {
                 if (pairDone) { 
                     setNamesOfGroups(seqGroup);
                     
+                    if (m->debug) { m->mothurOut("[DEBUG]: name = '" + seqName + "', group = '" + seqGroup + "'\n"); }
+                    
                     it = groupmap.find(seqName);
                     
                     if (it != groupmap.end()) { error = 1; m->mothurOut("Your designfile contains more than 1 sequence named " + seqName + ", sequence names must be unique. Please correct."); m->mothurOutEndLine();  }
diff --git a/sffmultiplecommand.cpp b/sffmultiplecommand.cpp
new file mode 100644 (file)
index 0000000..1675d24
--- /dev/null
@@ -0,0 +1,256 @@
+//
+//  sffmultiplecommand.cpp
+//  Mothur
+//
+//  Created by Sarah Westcott on 8/14/12.
+//  Copyright (c) 2012 Schloss Lab. All rights reserved.
+//
+
+#include "sffmultiplecommand.h"
+
+
+//**********************************************************************************************************************
+vector<string> SffMultipleCommand::setParameters(){    
+       try {           
+               CommandParameter pfile("file", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfile);
+        
+        //sffinfo
+               CommandParameter ptrim("trim", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(ptrim);
+        
+        //trim.flows
+               CommandParameter pmaxhomop("maxhomop", "Number", "", "9", "", "", "",false,false); parameters.push_back(pmaxhomop);
+               CommandParameter pmaxflows("maxflows", "Number", "", "450", "", "", "",false,false); parameters.push_back(pmaxflows);
+               CommandParameter pminflows("minflows", "Number", "", "450", "", "", "",false,false); parameters.push_back(pminflows);
+               CommandParameter ppdiffs("pdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(ppdiffs);
+               CommandParameter pbdiffs("bdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(pbdiffs);
+        CommandParameter pldiffs("ldiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(pldiffs);
+               CommandParameter psdiffs("sdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(psdiffs);
+        CommandParameter ptdiffs("tdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(ptdiffs);
+               CommandParameter psignal("signal", "Number", "", "0.50", "", "", "",false,false); parameters.push_back(psignal);
+               CommandParameter pnoise("noise", "Number", "", "0.70", "", "", "",false,false); parameters.push_back(pnoise);
+               CommandParameter pallfiles("allfiles", "Boolean", "", "t", "", "", "",false,false); parameters.push_back(pallfiles);
+               CommandParameter porder("order", "String", "", "", "", "", "",false,false); parameters.push_back(porder);
+
+        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);
+               
+               vector<string> myArray;
+               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SffMultipleCommand", "setParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+string SffMultipleCommand::getHelpString(){    
+       try {
+               string helpString = "";
+               helpString += "The sff.multiple command reads a file containing sff filenames and optional oligos filenames. It runs the files through sffinfo, trim.flows, shhh.flows and trim.seqs combining the results.\n";
+               helpString += "The sff.multiple command parameters are file, trim, maxhomop, maxflows, minflows, pdiffs, bdiffs, ldiffs, sdiffs, tdiffs, signal, noise, allfiles, order. file is required. \n";
+               helpString += "The file parameter allows you to enter the a file containing the list of sff files and optional oligos files.\n";
+        helpString += "The trim parameter allows you to indicate if you would like a sequences and quality scores generated by sffinfo trimmed to the clipQualLeft and clipQualRight values.  Default=True. \n";
+               helpString += "Example sff.multiple(file=mySffOligosFile.txt, trim=F).\n";
+               helpString += "Note: No spaces between parameter labels (i.e. file), '=' and parameters (i.e.mySffOligosFile.txt).\n";
+               return helpString;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SffMultipleCommand", "getHelpString");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+string SffMultipleCommand::getOutputFileNameTag(string type, string inputName=""){     
+       try {
+        string outputFileName = "";
+               map<string, vector<string> >::iterator it;
+        
+        //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 == "fasta")            {   outputFileName =  "fasta";   }
+            //else if (type == "flow")    {   outputFileName =  "flow";   }
+           // else if (type == "sfftxt")        {   outputFileName =  "sff.txt";   }
+            //else if (type == "qfile")       {   outputFileName =  "qual";   }
+            //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, "SffMultipleCommand", "getOutputFileNameTag");
+               exit(1);
+       }
+}
+
+
+//**********************************************************************************************************************
+SffMultipleCommand::SffMultipleCommand(){      
+       try {
+               abort = true; calledHelp = true; 
+               setParameters();
+               vector<string> tempOutNames;
+               outputTypes["fasta"] = tempOutNames;
+               outputTypes["flow"] = tempOutNames;
+               outputTypes["qfile"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SffMultipleCommand", "SffMultipleCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+
+SffMultipleCommand::SffMultipleCommand(string option)  {
+       try {
+               abort = false; calledHelp = false;   
+               
+               //allow user to run help
+               if(option == "help") { help(); abort = true; calledHelp = true; }
+               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
+               
+               else {
+                       //valid paramters for this command
+                       vector<string> myArray = setParameters();
+                       
+                       OptionParser parser(option);
+                       map<string, string> parameters = parser.getParameters();
+                       
+                       ValidParameters validParameter;
+            map<string,string>::iterator it;
+            
+                       //check to make sure all parameters are valid for command
+                       for (it = parameters.begin(); it != parameters.end(); it++) { 
+                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
+                       }
+                       
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["fasta"] = tempOutNames;
+                       outputTypes["flow"] = tempOutNames;
+                       outputTypes["qfile"] = tempOutNames;
+                       
+                       //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"){  outputDir = "";         }
+                       
+                       //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 = "";          }
+                       else {
+                               string path;
+                it = parameters.find("file");
+                               //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["file"] = inputDir + it->second;             }
+                               }
+                       }
+            
+                       filename = validParameter.validFile(parameters, "file", true);
+            if (filename == "not open") { filename = ""; abort = true; }
+            else if (filename == "not found") { filename = "";  }
+                       
+                       string temp;
+                       temp = validParameter.validFile(parameters, "trim", false);                                     if (temp == "not found"){       temp = "T";                             }
+                       trim = m->isTrue(temp); 
+               }
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SffMultipleCommand", "SffMultipleCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+int SffMultipleCommand::execute(){
+       try {
+               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
+               
+               vector<string> sffFiles, oligosFiles;
+        readFile(sffFiles, oligosFiles);
+        
+        if (m->control_pressed) { return 0; }
+        
+               
+               if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]);        } return 0; }
+               
+               //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); }
+               }
+               
+               itTypes = outputTypes.find("qfile");
+               if (itTypes != outputTypes.end()) {
+                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setQualFile(current); }
+               }
+               
+               itTypes = outputTypes.find("flow");
+               if (itTypes != outputTypes.end()) {
+                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFlowFile(current); }
+               }
+               
+               //report output filenames
+               m->mothurOutEndLine();
+               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
+               m->mothurOutEndLine();
+        
+               return 0;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SffMultipleCommand", "execute");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+int SffMultipleCommand::readFile(vector<string>& sffFiles, vector<string>& oligosFiles){
+       try {
+        
+        ifstream in;
+        m->openInputFile(filename, in);
+        
+        string oligos, sff;
+        while (!in.eof()) {
+            
+            if (m->control_pressed) { break; }
+            
+            in >> sff;
+            
+            //ignore file pairing
+            if(sff[0] == '#'){ while (!in.eof())       {       char c = in.get();  if (c == 10 || c == 13){    break;  }       } m->gobble(in); }
+            else { //check for oligos file
+                oligos = "";
+            
+                // get rest of line in case there is a oligos filename
+                while (!in.eof())      {       
+                    char c = in.get(); 
+                    if (c == 10 || c == 13){   break;  }
+                    else if (c == 32 || c == 9){;} //space or tab
+                    else {     oligos += c;  }
+                } 
+            }
+            m->gobble(in);
+            
+            sffFiles.push_back(sff);
+            oligosFiles.push_back(oligos); //will push a blank if there is not an oligos for this sff file
+        }
+        in.close();
+        
+        return 0;
+    }
+       catch(exception& e) {
+               m->errorOut(e, "SffMultipleCommand", "readFile");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+
+
+
+
diff --git a/sffmultiplecommand.h b/sffmultiplecommand.h
new file mode 100644 (file)
index 0000000..ae881aa
--- /dev/null
@@ -0,0 +1,45 @@
+#ifndef Mothur_sffmultiplecommand_h
+#define Mothur_sffmultiplecommand_h
+
+//
+//  sffmultiplecommand.h
+//  Mothur
+//
+//  Created by Sarah Westcott on 8/14/12.
+//  Copyright (c) 2012 Schloss Lab. All rights reserved.
+//
+
+#include "command.hpp"
+
+class SffMultipleCommand : public Command {
+       
+public:
+       SffMultipleCommand(string);
+       SffMultipleCommand();
+       ~SffMultipleCommand(){}
+       
+       vector<string> setParameters();
+       string getCommandName()                 { return "sff.multiple";                        }
+       string getCommandCategory()             { return "Sequence Processing";         }
+       string getOutputFileNameTag(string, string);
+       string getHelpString(); 
+       string getCitation() { return "http://www.mothur.org/wiki/Sff.multiple"; }
+       string getDescription()         { return "run multiple sff files through, sffinfo, trim.flow, shhh.flows and trim.seqs combining the results"; }
+    
+       int execute(); 
+       void help() { m->mothurOut(getHelpString()); }  
+       
+private:
+       string filename, outputDir, flowOrder;
+       vector<string> outputNames;
+       bool abort, trim;
+       int maxFlows, minFlows, minLength, maxLength, maxHomoP, tdiffs, bdiffs, pdiffs, sdiffs, ldiffs, numLinkers, numSpacers;
+       int numFlows, numFPrimers, numRPrimers, processors;
+       float signal, noise;
+    
+    int readFile(vector<string>& sffFiles, vector<string>& oligosFiles);
+    
+};
+
+
+#endif