]> git.donarmstrong.com Git - mothur.git/commitdiff
added fastq to list.seqs, get.seqs and remove.seqs. fixed bug where venn command...
authorSarah Westcott <mothur.westcott@gmail.com>
Thu, 17 Oct 2013 17:45:05 +0000 (13:45 -0400)
committerSarah Westcott <mothur.westcott@gmail.com>
Thu, 17 Oct 2013 17:45:05 +0000 (13:45 -0400)
12 files changed:
commandoptionparser.cpp
getseqscommand.cpp
getseqscommand.h
listseqscommand.cpp
listseqscommand.h
mothurout.cpp
mothurout.h
removeseqscommand.cpp
removeseqscommand.h
sffmultiplecommand.cpp
sffmultiplecommand.h
venn.cpp

index dfad533c8898ff3d79067d5f16c6869803e21e12..0038a714f4ae356e11d7dea57b4840a81eb946f4 100644 (file)
@@ -31,7 +31,7 @@ CommandOptionParser::CommandOptionParser(string input){
                        optionString = input.substr((openParen+1), (closeParen-openParen-1)); //optionString contains everything between "(" and ")".
                }
                else if (openParen == -1) { m->mothurOut("[ERROR]: You are missing ("); m->mothurOutEndLine(); }
                        optionString = input.substr((openParen+1), (closeParen-openParen-1)); //optionString contains everything between "(" and ")".
                }
                else if (openParen == -1) { m->mothurOut("[ERROR]: You are missing ("); m->mothurOutEndLine(); }
-               else if (closeParen == -1) { m->mothurOut("[ERROR]:You are missing )"); m->mothurOutEndLine(); }
+               else if (closeParen == -1) { m->mothurOut("[ERROR]: You are missing )"); m->mothurOutEndLine(); }
     }
        catch(exception& e) {
                m->errorOut(e, "CommandOptionParser", "CommandOptionParser");
     }
        catch(exception& e) {
                m->errorOut(e, "CommandOptionParser", "CommandOptionParser");
index 82f9710e6e40cb84b8fee9f285fca71b3fe0099c..b97bd587b6bc018fcf14ad6eee8abba054ee28ba 100644 (file)
@@ -16,6 +16,7 @@
 vector<string> GetSeqsCommand::setParameters(){        
        try {
                CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "FNGLT", "none","fasta",false,false,true); parameters.push_back(pfasta);
 vector<string> GetSeqsCommand::setParameters(){        
        try {
                CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "FNGLT", "none","fasta",false,false,true); parameters.push_back(pfasta);
+        CommandParameter pfastq("fastq", "InputTypes", "", "", "none", "FNGLT", "none","fastq",false,false,true); parameters.push_back(pfastq);
         CommandParameter pname("name", "InputTypes", "", "", "NameCount", "FNGLT", "none","name",false,false,true); parameters.push_back(pname);
         CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "FNGLT", "none","count",false,false,true); parameters.push_back(pcount);
                CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "FNGLT", "none","group",false,false,true); parameters.push_back(pgroup);
         CommandParameter pname("name", "InputTypes", "", "", "NameCount", "FNGLT", "none","name",false,false,true); parameters.push_back(pname);
         CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "FNGLT", "none","count",false,false,true); parameters.push_back(pcount);
                CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "FNGLT", "none","group",false,false,true); parameters.push_back(pgroup);
@@ -42,9 +43,9 @@ vector<string> GetSeqsCommand::setParameters(){
 string GetSeqsCommand::getHelpString(){        
        try {
                string helpString = "";
 string GetSeqsCommand::getHelpString(){        
        try {
                string helpString = "";
-               helpString += "The get.seqs command reads an .accnos file and any of the following file types: fasta, name, group, count, list, taxonomy, quality or alignreport file.\n";
+               helpString += "The get.seqs command reads an .accnos file and any of the following file types: fasta, name, group, count, list, taxonomy, quality, fastq or alignreport file.\n";
                helpString += "It outputs a file containing only the sequences in the .accnos file.\n";
                helpString += "It outputs a file containing only the sequences in the .accnos file.\n";
-               helpString += "The get.seqs command parameters are accnos, fasta, name, group, list, taxonomy, qfile, alignreport and dups.  You must provide accnos unless you have a valid current accnos file, and at least one of the other parameters.\n";
+               helpString += "The get.seqs command parameters are accnos, fasta, name, group, list, taxonomy, qfile, alignreport, fastq and dups.  You must provide accnos unless you have a valid current accnos file, and at least one of the other parameters.\n";
                helpString += "The dups parameter allows you to add the entire line from a name file if you add any name from the line. default=true. \n";
                helpString += "The get.seqs command should be in the following format: get.seqs(accnos=yourAccnos, fasta=yourFasta).\n";
                helpString += "Example get.seqs(accnos=amazon.accnos, fasta=amazon.fasta).\n";
                helpString += "The dups parameter allows you to add the entire line from a name file if you add any name from the line. default=true. \n";
                helpString += "The get.seqs command should be in the following format: get.seqs(accnos=yourAccnos, fasta=yourFasta).\n";
                helpString += "Example get.seqs(accnos=amazon.accnos, fasta=amazon.fasta).\n";
@@ -64,6 +65,7 @@ GetSeqsCommand::GetSeqsCommand(){
                setParameters();
                vector<string> tempOutNames;
                outputTypes["fasta"] = tempOutNames;
                setParameters();
                vector<string> tempOutNames;
                outputTypes["fasta"] = tempOutNames;
+        outputTypes["fastq"] = tempOutNames;
                outputTypes["taxonomy"] = tempOutNames;
                outputTypes["name"] = tempOutNames;
                outputTypes["group"] = tempOutNames;
                outputTypes["taxonomy"] = tempOutNames;
                outputTypes["name"] = tempOutNames;
                outputTypes["group"] = tempOutNames;
@@ -84,6 +86,7 @@ string GetSeqsCommand::getOutputPattern(string type) {
         string pattern = "";
         
         if (type == "fasta")            {   pattern = "[filename],pick,[extension]";    }
         string pattern = "";
         
         if (type == "fasta")            {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "fastq")       {   pattern = "[filename],pick,[extension]";    }
         else if (type == "taxonomy")    {   pattern = "[filename],pick,[extension]";    }
         else if (type == "name")        {   pattern = "[filename],pick,[extension]";    }
         else if (type == "group")       {   pattern = "[filename],pick,[extension]";    }
         else if (type == "taxonomy")    {   pattern = "[filename],pick,[extension]";    }
         else if (type == "name")        {   pattern = "[filename],pick,[extension]";    }
         else if (type == "group")       {   pattern = "[filename],pick,[extension]";    }
@@ -127,6 +130,7 @@ GetSeqsCommand::GetSeqsCommand(string option)  {
                        //initialize outputTypes
                        vector<string> tempOutNames;
                        outputTypes["fasta"] = tempOutNames;
                        //initialize outputTypes
                        vector<string> tempOutNames;
                        outputTypes["fasta"] = tempOutNames;
+            outputTypes["fastq"] = tempOutNames;
                        outputTypes["taxonomy"] = tempOutNames;
                        outputTypes["name"] = tempOutNames;
                        outputTypes["group"] = tempOutNames;
                        outputTypes["taxonomy"] = tempOutNames;
                        outputTypes["name"] = tempOutNames;
                        outputTypes["group"] = tempOutNames;
@@ -223,6 +227,14 @@ GetSeqsCommand::GetSeqsCommand(string option)  {
                                        //if the user has not given a path then, add inputdir. else leave path alone.
                                        if (path == "") {       parameters["count"] = inputDir + it->second;            }
                                }
                                        //if the user has not given a path then, add inputdir. else leave path alone.
                                        if (path == "") {       parameters["count"] = inputDir + it->second;            }
                                }
+                
+                it = parameters.find("fastq");
+                               //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["fastq"] = inputDir + it->second;            }
+                               }
                        }
 
                        
                        }
 
                        
@@ -273,6 +285,10 @@ GetSeqsCommand::GetSeqsCommand(string option)  {
                        if (qualfile == "not open") { abort = true; }
                        else if (qualfile == "not found") {  qualfile = "";  }
                        else { m->setQualFile(qualfile); }
                        if (qualfile == "not open") { abort = true; }
                        else if (qualfile == "not found") {  qualfile = "";  }
                        else { m->setQualFile(qualfile); }
+            
+            fastqfile = validParameter.validFile(parameters, "fastq", true);
+                       if (fastqfile == "not open") { abort = true; }
+                       else if (fastqfile == "not found") {  fastqfile = "";  }
                        
                        accnosfile2 = validParameter.validFile(parameters, "accnos2", true);
                        if (accnosfile2 == "not open") { abort = true; }
                        
                        accnosfile2 = validParameter.validFile(parameters, "accnos2", true);
                        if (accnosfile2 == "not open") { abort = true; }
@@ -296,7 +312,7 @@ GetSeqsCommand::GetSeqsCommand(string option)  {
                        string temp = validParameter.validFile(parameters, "dups", false);      if (temp == "not found") { temp = "true"; usedDups = ""; }
                        dups = m->isTrue(temp);
                        
                        string temp = validParameter.validFile(parameters, "dups", false);      if (temp == "not found") { temp = "true"; usedDups = ""; }
                        dups = m->isTrue(temp);
                        
-                       if ((fastafile == "") && (namefile == "") && (groupfile == "") && (alignfile == "") && (listfile == "") && (taxfile == "") && (qualfile == "") && (accnosfile2 == "") && (countfile == ""))  { m->mothurOut("You must provide one of the following: fasta, name, group, count, alignreport, taxonomy, quality or listfile."); m->mothurOutEndLine(); abort = true; }
+                       if ((fastqfile == "") && (fastafile == "") && (namefile == "") && (groupfile == "") && (alignfile == "") && (listfile == "") && (taxfile == "") && (qualfile == "") && (accnosfile2 == "") && (countfile == ""))  { m->mothurOut("You must provide one of the following: fasta, name, group, count, alignreport, taxonomy, quality, fastq or listfile."); m->mothurOutEndLine(); abort = true; }
             
             if (countfile == "") {
                 if ((namefile == "") && ((fastafile != "") || (taxfile != ""))){
             
             if (countfile == "") {
                 if ((namefile == "") && ((fastafile != "") || (taxfile != ""))){
@@ -333,6 +349,7 @@ int GetSeqsCommand::execute(){
                //read through the correct file and output lines you want to keep
                if (namefile != "")                     {               readName();                     }
                if (fastafile != "")            {               readFasta();            }
                //read through the correct file and output lines you want to keep
                if (namefile != "")                     {               readName();                     }
                if (fastafile != "")            {               readFasta();            }
+        if (fastqfile != "")           {               readFastq();            }
                if (groupfile != "")            {               readGroup();            }
         if (countfile != "")           {               readCount();            }
                if (alignfile != "")            {               readAlign();            }
                if (groupfile != "")            {               readGroup();            }
         if (countfile != "")           {               readCount();            }
                if (alignfile != "")            {               readAlign();            }
@@ -398,6 +415,71 @@ int GetSeqsCommand::execute(){
                exit(1);
        }
 }
                exit(1);
        }
 }
+//**********************************************************************************************************************
+int GetSeqsCommand::readFastq(){
+       try {
+               bool wroteSomething = false;
+               int selectedCount = 0;
+        
+               ifstream in;
+               m->openInputFile(fastqfile, in);
+               
+               string thisOutputDir = outputDir;
+               if (outputDir == "") {  thisOutputDir += m->hasPath(fastqfile);  }
+               map<string, string> variables;
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(fastqfile));
+        variables["[extension]"] = m->getExtension(fastqfile);
+               string outputFileName = getOutputFileName("fastq", variables);
+               ofstream out;
+               m->openOutputFile(outputFileName, out);
+
+               
+               while(!in.eof()){
+                       
+                       if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; }
+                       
+                       //read sequence name
+                       string input = m->getline(in); m->gobble(in);
+                       
+            string outputString = input + "\n";
+            
+                       if (input[0] == '@') {
+                //get rest of lines
+                outputString += m->getline(in) + "\n"; m->gobble(in);
+                outputString += m->getline(in) + "\n"; m->gobble(in);
+                outputString += m->getline(in) + "\n"; m->gobble(in);
+                
+                vector<string> splits = m->splitWhiteSpace(input);
+                string name = splits[0];
+                name = name.substr(1);
+                m->checkName(name);
+                
+                if (names.count(name) != 0) {
+                                       wroteSomething = true;
+                    selectedCount++;
+                    out << outputString;
+                }
+            }
+            
+                       m->gobble(in);
+               }
+               in.close();
+               out.close();
+               
+               
+               if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();  }
+               outputNames.push_back(outputFileName);  outputTypes["fastq"].push_back(outputFileName);
+               
+               m->mothurOut("Selected " + toString(selectedCount) + " sequences from your fastq file."); m->mothurOutEndLine();
+               
+               return 0;
+        
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetSeqsCommand", "readFastq");
+               exit(1);
+       }
+}
 
 //**********************************************************************************************************************
 int GetSeqsCommand::readFasta(){
 
 //**********************************************************************************************************************
 int GetSeqsCommand::readFasta(){
index c5b6ca4141afc00c12b646ea34604b898b1c4131..9895432b7c25d6016bbf6b38ced773487aeb0201 100644 (file)
@@ -36,13 +36,14 @@ class GetSeqsCommand : public Command {
        private:
                set<string> names;
                vector<string> outputNames;
        private:
                set<string> names;
                vector<string> outputNames;
-               string accnosfile, accnosfile2, fastafile, namefile, countfile, groupfile, alignfile, listfile, taxfile, qualfile, outputDir;
+               string accnosfile, accnosfile2, fastafile, fastqfile, namefile, countfile, groupfile, alignfile, listfile, taxfile, qualfile, outputDir;
                bool abort, dups;
         map<string, string> uniqueMap;
         //for debug
         map<string, set<string> > sanity; //maps file type to names chosen for file. something like "fasta" -> vector<string>. If running in debug mode this is filled and we check to make sure all the files have the same names. If they don't we output the differences for the user.
                
                int readFasta();
                bool abort, dups;
         map<string, string> uniqueMap;
         //for debug
         map<string, set<string> > sanity; //maps file type to names chosen for file. something like "fasta" -> vector<string>. If running in debug mode this is filled and we check to make sure all the files have the same names. If they don't we output the differences for the user.
                
                int readFasta();
+        int readFastq();
                int readName();
                int readGroup();
         int readCount();
                int readName();
                int readGroup();
         int readCount();
index 343d4fdc6399f8ca9a91c6cac9b31313d7b76bbb..0ead54a90cf2ef44205947baddecb39b21e6b8f7 100644 (file)
@@ -16,6 +16,7 @@
 //**********************************************************************************************************************
 vector<string> ListSeqsCommand::setParameters(){       
        try {
 //**********************************************************************************************************************
 vector<string> ListSeqsCommand::setParameters(){       
        try {
+        CommandParameter pfastq("fastq", "InputTypes", "", "", "FNGLT", "FNGLT", "none","accnos",false,false,true); parameters.push_back(pfastq);
                CommandParameter pfasta("fasta", "InputTypes", "", "", "FNGLT", "FNGLT", "none","accnos",false,false,true); parameters.push_back(pfasta);
                CommandParameter pname("name", "InputTypes", "", "", "FNGLT", "FNGLT", "none","accnos",false,false,true); parameters.push_back(pname);
         CommandParameter pcount("count", "InputTypes", "", "", "FNGLT", "FNGLT", "none","accnos",false,false,true); parameters.push_back(pcount);
                CommandParameter pfasta("fasta", "InputTypes", "", "", "FNGLT", "FNGLT", "none","accnos",false,false,true); parameters.push_back(pfasta);
                CommandParameter pname("name", "InputTypes", "", "", "FNGLT", "FNGLT", "none","accnos",false,false,true); parameters.push_back(pname);
         CommandParameter pcount("count", "InputTypes", "", "", "FNGLT", "FNGLT", "none","accnos",false,false,true); parameters.push_back(pcount);
@@ -39,8 +40,8 @@ vector<string> ListSeqsCommand::setParameters(){
 string ListSeqsCommand::getHelpString(){       
        try {
                string helpString = "";
 string ListSeqsCommand::getHelpString(){       
        try {
                string helpString = "";
-               helpString += "The list.seqs command reads a fasta, name, group, count, list, taxonomy or alignreport file and outputs a .accnos file containing sequence names.\n";
-               helpString += "The list.seqs command parameters are fasta, name, group, count, list, taxonomy and alignreport.  You must provide one of these parameters.\n";
+               helpString += "The list.seqs command reads a fasta, name, group, count, list, taxonomy, fastq or alignreport file and outputs a .accnos file containing sequence names.\n";
+               helpString += "The list.seqs command parameters are fasta, name, group, count, list, taxonomy, fastq and alignreport.  You must provide one of these parameters.\n";
                helpString += "The list.seqs command should be in the following format: list.seqs(fasta=yourFasta).\n";
                helpString += "Example list.seqs(fasta=amazon.fasta).\n";
                helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n";
                helpString += "The list.seqs command should be in the following format: list.seqs(fasta=yourFasta).\n";
                helpString += "Example list.seqs(fasta=amazon.fasta).\n";
                helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n";
@@ -169,6 +170,14 @@ ListSeqsCommand::ListSeqsCommand(string option)  {
                                        //if the user has not given a path then, add inputdir. else leave path alone.
                                        if (path == "") {       parameters["count"] = inputDir + it->second;            }
                                }
                                        //if the user has not given a path then, add inputdir. else leave path alone.
                                        if (path == "") {       parameters["count"] = inputDir + it->second;            }
                                }
+                
+                it = parameters.find("fastq");
+                               //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["fastq"] = inputDir + it->second;            }
+                               }
                        }
 
                        //check for required parameters
                        }
 
                        //check for required parameters
@@ -205,8 +214,12 @@ ListSeqsCommand::ListSeqsCommand(string option)  {
                        if (countfile == "not open") { abort = true; }
                        else if (countfile == "not found") {  countfile = "";  }
                        else { m->setCountTableFile(countfile); }
                        if (countfile == "not open") { abort = true; }
                        else if (countfile == "not found") {  countfile = "";  }
                        else { m->setCountTableFile(countfile); }
+            
+            fastqfile = validParameter.validFile(parameters, "fastq", true);
+                       if (fastqfile == "not open") { abort = true; }
+                       else if (fastqfile == "not found") {  fastqfile = "";  }
                        
                        
-                       if ((countfile == "") && (fastafile == "") && (namefile == "") && (listfile == "") && (groupfile == "") && (alignfile == "") && (taxfile == ""))  { m->mothurOut("You must provide a file."); m->mothurOutEndLine(); abort = true; }
+                       if ((fastqfile == "") && (countfile == "") && (fastafile == "") && (namefile == "") && (listfile == "") && (groupfile == "") && (alignfile == "") && (taxfile == ""))  { m->mothurOut("You must provide a file."); m->mothurOutEndLine(); abort = true; }
                        
                        int okay = 1;
                        if (outputDir != "") { okay++; }
                        
                        int okay = 1;
                        if (outputDir != "") { okay++; }
@@ -230,6 +243,7 @@ int ListSeqsCommand::execute(){
                
                //read functions fill names vector
                if (fastafile != "")            {       inputFileName = fastafile;      readFasta();    }
                
                //read functions fill names vector
                if (fastafile != "")            {       inputFileName = fastafile;      readFasta();    }
+        else if (fastqfile != "")      {       inputFileName = fastqfile;      readFastq();    }
                else if (namefile != "")        {       inputFileName = namefile;       readName();             }
                else if (groupfile != "")       {       inputFileName = groupfile;      readGroup();    }
                else if (alignfile != "")       {       inputFileName = alignfile;      readAlign();    }
                else if (namefile != "")        {       inputFileName = namefile;       readName();             }
                else if (groupfile != "")       {       inputFileName = groupfile;      readGroup();    }
                else if (alignfile != "")       {       inputFileName = alignfile;      readAlign();    }
@@ -285,6 +299,53 @@ int ListSeqsCommand::execute(){
                exit(1);
        }
 }
                exit(1);
        }
 }
+//**********************************************************************************************************************
+int ListSeqsCommand::readFastq(){
+       try {
+               
+               ifstream in;
+               m->openInputFile(fastqfile, in);
+               string name;
+               
+               //ofstream out;
+               //string newFastaName = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "numsAdded.fasta";
+               //m->openOutputFile(newFastaName, out);
+               int count = 1;
+               //string lastName = "";
+               
+               while(!in.eof()){
+                       
+                       if (m->control_pressed) { in.close(); return 0; }
+                       
+                       //read sequence name
+                       string name = m->getline(in); m->gobble(in);
+                       
+                       if (name[0] == '@') {
+                vector<string> splits = m->splitWhiteSpace(name);
+                name = splits[0];
+                name = name.substr(1);
+                m->checkName(name);
+                names.push_back(name);
+                //get rest of lines
+                name = m->getline(in); m->gobble(in);
+                name = m->getline(in); m->gobble(in);
+                name = m->getline(in); m->gobble(in);
+            }
+                       
+                       m->gobble(in);
+                       if (m->debug) { count++; cout << "[DEBUG]: count = " + toString(count) + ", name = " + name + "\n"; }
+               }
+               in.close();
+               //out.close();
+               
+               return 0;
+        
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ListSeqsCommand", "readFastq");
+               exit(1);
+       }
+}
 
 //**********************************************************************************************************************
 int ListSeqsCommand::readFasta(){
 
 //**********************************************************************************************************************
 int ListSeqsCommand::readFasta(){
index b8a79c06035825fd92050a1e0c610ac6b77bd122..9d320d9e9a94ad031826bc547d42a03b30e8ec30 100644 (file)
@@ -35,7 +35,7 @@ class ListSeqsCommand : public Command {
        
        private:
                vector<string> names, outputNames;
        
        private:
                vector<string> names, outputNames;
-               string fastafile, namefile, groupfile, countfile, alignfile, inputFileName, outputDir, listfile, taxfile;
+               string fastafile, namefile, groupfile, countfile, alignfile, inputFileName, outputDir, listfile, taxfile, fastqfile;
                bool abort;
                
                int readFasta();
                bool abort;
                
                int readFasta();
@@ -45,7 +45,7 @@ class ListSeqsCommand : public Command {
                int readList();
                int readTax();
         int readCount();
                int readList();
                int readTax();
         int readCount();
-               
+        int readFastq();
 };
 
 #endif
 };
 
 #endif
index 3d4504daf761d625ffedd1e11749aa567ca9327b..66ee704dd59d0221d1a0a7a40de65ecf42d762b2 100644 (file)
@@ -3013,6 +3013,64 @@ void MothurOut::getNumSeqs(ifstream& file, int& numSeqs){
        }       
 }
 /***********************************************************************/
        }       
 }
 /***********************************************************************/
+bool MothurOut::checkLocations(string& filename, string inputDir){
+       try {
+               filename = getFullPathName(filename);
+        
+        int ableToOpen;
+        ifstream in;
+        ableToOpen = openInputFile(filename, in, "noerror");
+        in.close();
+        
+        //if you can't open it, try input location
+        if (ableToOpen == 1) {
+            if (inputDir != "") { //default path is set
+                string tryPath = inputDir + getSimpleName(filename);
+                mothurOut("Unable to open " + filename + ". Trying input directory " + tryPath); mothurOutEndLine();
+                ifstream in2;
+                ableToOpen = openInputFile(tryPath, in2, "noerror");
+                in2.close();
+                filename = tryPath;
+            }
+        }
+        
+        //if you can't open it, try default location
+        if (ableToOpen == 1) {
+            if (getDefaultPath() != "") { //default path is set
+                string tryPath = getDefaultPath() + getSimpleName(filename);
+                mothurOut("Unable to open " + filename + ". Trying default " + tryPath); mothurOutEndLine();
+                ifstream in2;
+                ableToOpen = openInputFile(tryPath, in2, "noerror");
+                in2.close();
+                filename = tryPath;
+            }
+        }
+        
+        //if you can't open it its not in current working directory or inputDir, try mothur excutable location
+        if (ableToOpen == 1) {
+            string exepath = argv;
+            string tempPath = exepath;
+            for (int i = 0; i < exepath.length(); i++) { tempPath[i] = tolower(exepath[i]); }
+            exepath = exepath.substr(0, (tempPath.find_last_of('m')));
+            
+            string tryPath = getFullPathName(exepath) + getSimpleName(filename);
+            mothurOut("Unable to open " + filename + ". Trying mothur's executable location " + tryPath); mothurOutEndLine();
+            ifstream in2;
+            ableToOpen = openInputFile(tryPath, in2, "noerror");
+            in2.close();
+            filename = tryPath;
+        }
+        
+        if (ableToOpen == 1) { mothurOut("Unable to open " + filename + "."); mothurOutEndLine(); return false;  }
+        
+        return true;
+       }
+       catch(exception& e) {
+               errorOut(e, "MothurOut", "checkLocations");
+               exit(1);
+       }
+}
+/***********************************************************************/
 
 //This function parses the estimator options and puts them in a vector
 void MothurOut::splitAtChar(string& estim, vector<string>& container, char symbol) {
 
 //This function parses the estimator options and puts them in a vector
 void MothurOut::splitAtChar(string& estim, vector<string>& container, char symbol) {
index f58f4e874a7f72961489d7e2651bda651e3d2bb4..db931b5a5e380169c3147ee8b0c9acb4d72f1a00 100644 (file)
@@ -97,7 +97,9 @@ class MothurOut {
                int openOutputFileAppend(string, ofstream&);
         int openOutputFileBinaryAppend(string, ofstream&);
                int openInputFile(string, ifstream&);
                int openOutputFileAppend(string, ofstream&);
         int openOutputFileBinaryAppend(string, ofstream&);
                int openInputFile(string, ifstream&);
-               int openInputFile(string, ifstream&, string); //no error given 
+               int openInputFile(string, ifstream&, string); //no error given
+    
+        bool checkLocations(string&, string);  //filename, inputDir. checks for file in ./, inputdir, default and mothur's exe location.  Returns false if cant be found. If found completes name with location
                string getline(ifstream&);
                string getline(istringstream&);
                void gobble(istream&);
                string getline(ifstream&);
                string getline(istringstream&);
                void gobble(istream&);
index fa7e6dda2a853d6a0234c1dc92be3bad258118d1..019a659f44f446be2d3c87e5c195ab93663f1773 100644 (file)
@@ -15,6 +15,7 @@
 //**********************************************************************************************************************
 vector<string> RemoveSeqsCommand::setParameters(){     
        try {
 //**********************************************************************************************************************
 vector<string> RemoveSeqsCommand::setParameters(){     
        try {
+        CommandParameter pfastq("fastq", "InputTypes", "", "", "none", "FNGLT", "none","fastq",false,false,true); parameters.push_back(pfastq);
                CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "FNGLT", "none","fasta",false,false,true); parameters.push_back(pfasta);
         CommandParameter pname("name", "InputTypes", "", "", "NameCount", "FNGLT", "none","name",false,false,true); parameters.push_back(pname);
         CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "FNGLT", "none","count",false,false,true); parameters.push_back(pcount);
                CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "FNGLT", "none","fasta",false,false,true); parameters.push_back(pfasta);
         CommandParameter pname("name", "InputTypes", "", "", "NameCount", "FNGLT", "none","name",false,false,true); parameters.push_back(pname);
         CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "FNGLT", "none","count",false,false,true); parameters.push_back(pcount);
@@ -41,9 +42,9 @@ vector<string> RemoveSeqsCommand::setParameters(){
 string RemoveSeqsCommand::getHelpString(){     
        try {
                string helpString = "";
 string RemoveSeqsCommand::getHelpString(){     
        try {
                string helpString = "";
-               helpString += "The remove.seqs command reads an .accnos file and at least one of the following file types: fasta, name, group, count, list, taxonomy, quality or alignreport file.\n";
+               helpString += "The remove.seqs command reads an .accnos file and at least one of the following file types: fasta, name, group, count, list, taxonomy, quality, fastq or alignreport file.\n";
                helpString += "It outputs a file containing the sequences NOT in the .accnos file.\n";
                helpString += "It outputs a file containing the sequences NOT in the .accnos file.\n";
-               helpString += "The remove.seqs command parameters are accnos, fasta, name, group, count, list, taxonomy, qfile, alignreport and dups.  You must provide accnos and at least one of the file parameters.\n";
+               helpString += "The remove.seqs command parameters are accnos, fasta, name, group, count, list, taxonomy, qfile, alignreport, fastq and dups.  You must provide accnos and at least one of the file parameters.\n";
                helpString += "The dups parameter allows you to remove the entire line from a name file if you remove any name from the line. default=true. \n";
                helpString += "The remove.seqs command should be in the following format: remove.seqs(accnos=yourAccnos, fasta=yourFasta).\n";
                helpString += "Example remove.seqs(accnos=amazon.accnos, fasta=amazon.fasta).\n";
                helpString += "The dups parameter allows you to remove the entire line from a name file if you remove any name from the line. default=true. \n";
                helpString += "The remove.seqs command should be in the following format: remove.seqs(accnos=yourAccnos, fasta=yourFasta).\n";
                helpString += "Example remove.seqs(accnos=amazon.accnos, fasta=amazon.fasta).\n";
@@ -61,6 +62,7 @@ string RemoveSeqsCommand::getOutputPattern(string type) {
         string pattern = "";
         
         if (type == "fasta")            {   pattern = "[filename],pick,[extension]";    }
         string pattern = "";
         
         if (type == "fasta")            {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "fastq")       {   pattern = "[filename],pick,[extension]";    }
         else if (type == "taxonomy")    {   pattern = "[filename],pick,[extension]";    }
         else if (type == "name")        {   pattern = "[filename],pick,[extension]";    }
         else if (type == "group")       {   pattern = "[filename],pick,[extension]";    }
         else if (type == "taxonomy")    {   pattern = "[filename],pick,[extension]";    }
         else if (type == "name")        {   pattern = "[filename],pick,[extension]";    }
         else if (type == "group")       {   pattern = "[filename],pick,[extension]";    }
@@ -84,6 +86,7 @@ RemoveSeqsCommand::RemoveSeqsCommand(){
                setParameters();
                vector<string> tempOutNames;
                outputTypes["fasta"] = tempOutNames;
                setParameters();
                vector<string> tempOutNames;
                outputTypes["fasta"] = tempOutNames;
+        outputTypes["fastq"] = tempOutNames;
                outputTypes["taxonomy"] = tempOutNames;
                outputTypes["name"] = tempOutNames;
                outputTypes["group"] = tempOutNames;
                outputTypes["taxonomy"] = tempOutNames;
                outputTypes["name"] = tempOutNames;
                outputTypes["group"] = tempOutNames;
@@ -123,6 +126,7 @@ RemoveSeqsCommand::RemoveSeqsCommand(string option)  {
                        //initialize outputTypes
                        vector<string> tempOutNames;
                        outputTypes["fasta"] = tempOutNames;
                        //initialize outputTypes
                        vector<string> tempOutNames;
                        outputTypes["fasta"] = tempOutNames;
+            outputTypes["fastq"] = tempOutNames;
                        outputTypes["taxonomy"] = tempOutNames;
                        outputTypes["name"] = tempOutNames;
                        outputTypes["group"] = tempOutNames;
                        outputTypes["taxonomy"] = tempOutNames;
                        outputTypes["name"] = tempOutNames;
                        outputTypes["group"] = tempOutNames;
@@ -210,6 +214,14 @@ RemoveSeqsCommand::RemoveSeqsCommand(string option)  {
                                        //if the user has not given a path then, add inputdir. else leave path alone.
                                        if (path == "") {       parameters["count"] = inputDir + it->second;            }
                                }
                                        //if the user has not given a path then, add inputdir. else leave path alone.
                                        if (path == "") {       parameters["count"] = inputDir + it->second;            }
                                }
+                
+                it = parameters.find("fastq");
+                               //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["fastq"] = inputDir + it->second;            }
+                               }
                        }
 
                        
                        }
 
                        
@@ -258,6 +270,10 @@ RemoveSeqsCommand::RemoveSeqsCommand(string option)  {
                        if (qualfile == "not open") { abort = true; }
                        else if (qualfile == "not found") {  qualfile = "";  }                  
                        else { m->setQualFile(qualfile); }
                        if (qualfile == "not open") { abort = true; }
                        else if (qualfile == "not found") {  qualfile = "";  }                  
                        else { m->setQualFile(qualfile); }
+            
+            fastqfile = validParameter.validFile(parameters, "fastq", true);
+                       if (fastqfile == "not open") { abort = true; }
+                       else if (fastqfile == "not found") {  fastqfile = "";  }
                        
                        string usedDups = "true";
                        string temp = validParameter.validFile(parameters, "dups", false);      
                        
                        string usedDups = "true";
                        string temp = validParameter.validFile(parameters, "dups", false);      
@@ -280,7 +296,7 @@ RemoveSeqsCommand::RemoveSeqsCommand(string option)  {
                 m->mothurOut("[ERROR]: you may only use one of the following: group or count."); m->mothurOutEndLine(); abort=true;
             }
                        
                 m->mothurOut("[ERROR]: you may only use one of the following: group or count."); m->mothurOutEndLine(); abort=true;
             }
                        
-                       if ((countfile == "") && (fastafile == "") && (namefile == "") && (groupfile == "") && (alignfile == "") && (listfile == "") && (taxfile == "") && (qualfile == ""))  { m->mothurOut("You must provide at least one of the following: fasta, name, group, taxonomy, quality, alignreport or list."); m->mothurOutEndLine(); abort = true; }
+                       if ((fastqfile == "") && (countfile == "") && (fastafile == "") && (namefile == "") && (groupfile == "") && (alignfile == "") && (listfile == "") && (taxfile == "") && (qualfile == ""))  { m->mothurOut("You must provide at least one of the following: fasta, name, group, taxonomy, quality, alignreport, fastq or list."); m->mothurOutEndLine(); abort = true; }
                        
             if (countfile == "") {
                 if ((fastafile != "") && (namefile == "")) {
                        
             if (countfile == "") {
                 if ((fastafile != "") && (namefile == "")) {
@@ -317,6 +333,7 @@ int RemoveSeqsCommand::execute(){
                //read through the correct file and output lines you want to keep
                if (namefile != "")                     {               readName();             }
                if (fastafile != "")            {               readFasta();    }
                //read through the correct file and output lines you want to keep
                if (namefile != "")                     {               readName();             }
                if (fastafile != "")            {               readFasta();    }
+        if (fastqfile != "")           {               readFastq();            }
                if (groupfile != "")            {               readGroup();    }
                if (alignfile != "")            {               readAlign();    }
                if (listfile != "")                     {               readList();             }
                if (groupfile != "")            {               readGroup();    }
                if (alignfile != "")            {               readAlign();    }
                if (listfile != "")                     {               readList();             }
@@ -438,6 +455,71 @@ int RemoveSeqsCommand::readFasta(){
        }
 }
 //**********************************************************************************************************************
        }
 }
 //**********************************************************************************************************************
+int RemoveSeqsCommand::readFastq(){
+       try {
+               bool wroteSomething = false;
+               int removedCount = 0;
+        
+               ifstream in;
+               m->openInputFile(fastqfile, in);
+               
+               string thisOutputDir = outputDir;
+               if (outputDir == "") {  thisOutputDir += m->hasPath(fastqfile);  }
+               map<string, string> variables;
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(fastqfile));
+        variables["[extension]"] = m->getExtension(fastqfile);
+               string outputFileName = getOutputFileName("fastq", variables);
+               ofstream out;
+               m->openOutputFile(outputFileName, out);
+        
+               
+               while(!in.eof()){
+                       
+                       if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; }
+                       
+                       //read sequence name
+                       string input = m->getline(in); m->gobble(in);
+                       
+            string outputString = input + "\n";
+            
+                       if (input[0] == '@') {
+                //get rest of lines
+                outputString += m->getline(in) + "\n"; m->gobble(in);
+                outputString += m->getline(in) + "\n"; m->gobble(in);
+                outputString += m->getline(in) + "\n"; m->gobble(in);
+                
+                vector<string> splits = m->splitWhiteSpace(input);
+                string name = splits[0];
+                name = name.substr(1);
+                m->checkName(name);
+                
+                if (names.count(name) == 0) {
+                                       wroteSomething = true;
+                    out << outputString;
+                }else { removedCount++; }
+            }
+            
+                       m->gobble(in);
+               }
+               in.close();
+               out.close();
+               
+               
+               if (wroteSomething == false) {  m->mothurOut("Your file contains only sequences from the .accnos file."); m->mothurOutEndLine();  }
+               outputTypes["fasta"].push_back(outputFileName);  outputNames.push_back(outputFileName);
+               
+               m->mothurOut("Removed " + toString(removedCount) + " sequences from your fastq file."); m->mothurOutEndLine();
+
+               
+               return 0;
+        
+       }
+       catch(exception& e) {
+               m->errorOut(e, "RemoveSeqsCommand", "readFastq");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
 int RemoveSeqsCommand::readQual(){
        try {
                string thisOutputDir = outputDir;
 int RemoveSeqsCommand::readQual(){
        try {
                string thisOutputDir = outputDir;
index 1a6365dac35b9e18669f8827c4054268b9123d9e..7aaff172800c43b160fe62b2b49c2035e08502f8 100644 (file)
@@ -35,12 +35,13 @@ class RemoveSeqsCommand : public Command {
        
        private:
                set<string> names;
        
        private:
                set<string> names;
-               string accnosfile, fastafile, namefile, groupfile, countfile, alignfile, listfile, taxfile, qualfile, outputDir;
+               string accnosfile, fastafile, fastqfile, namefile, groupfile, countfile, alignfile, listfile, taxfile, qualfile, outputDir;
                bool abort, dups;
                vector<string> outputNames;
         map<string, string> uniqueMap;
                
                int readFasta();
                bool abort, dups;
                vector<string> outputNames;
         map<string, string> uniqueMap;
                
                int readFasta();
+        int readFastq();
                int readName();
                int readGroup();
         int readCount();
                int readName();
                int readGroup();
         int readCount();
index d8a4b96ec155d155c0ca6dae946b821cb1a238e5..f75662b30f258ecf30b3e20e79a76362f633c069 100644 (file)
@@ -166,7 +166,7 @@ SffMultipleCommand::SffMultipleCommand(string option)  {
                        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 
                        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);              
+                       inputDir = validParameter.validFile(parameters, "inputdir", false);             
                        if (inputDir == "not found"){   inputDir = "";          }
                        else {
                                string path;
                        if (inputDir == "not found"){   inputDir = "";          }
                        else {
                                string path;
@@ -303,54 +303,9 @@ SffMultipleCommand::SffMultipleCommand(string option)  {
                 path += "lookupFiles\\";
 #endif
                                lookupFileName = m->getFullPathName(path) + "LookUp_Titanium.pat";
                 path += "lookupFiles\\";
 #endif
                                lookupFileName = m->getFullPathName(path) + "LookUp_Titanium.pat";
-                               
-                               int ableToOpen;
-                               ifstream in;
-                               ableToOpen = m->openInputFile(lookupFileName, in, "noerror");
-                               in.close();     
-                               
-                               //if you can't open it, try input location
-                               if (ableToOpen == 1) {
-                                       if (inputDir != "") { //default path is set
-                                               string tryPath = inputDir + m->getSimpleName(lookupFileName);
-                                               m->mothurOut("Unable to open " + lookupFileName + ". Trying input directory " + tryPath); m->mothurOutEndLine();
-                                               ifstream in2;
-                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                               in2.close();
-                                               lookupFileName = tryPath;
-                                       }
-                               }
-                               
-                               //if you can't open it, try default location
-                               if (ableToOpen == 1) {
-                                       if (m->getDefaultPath() != "") { //default path is set
-                                               string tryPath = m->getDefaultPath() + m->getSimpleName(lookupFileName);
-                                               m->mothurOut("Unable to open " + lookupFileName + ". Trying default " + tryPath); m->mothurOutEndLine();
-                                               ifstream in2;
-                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                               in2.close();
-                                               lookupFileName = tryPath;
-                                       }
-                               }
-                               
-                               //if you can't open it its not in current working directory or inputDir, try mothur excutable location
-                               if (ableToOpen == 1) {
-                                       string exepath = m->argv;
-                                       string tempPath = exepath;
-                                       for (int i = 0; i < exepath.length(); i++) { tempPath[i] = tolower(exepath[i]); }
-                                       exepath = exepath.substr(0, (tempPath.find_last_of('m')));
-                                       
-                                       string tryPath = m->getFullPathName(exepath) + m->getSimpleName(lookupFileName);
-                                       m->mothurOut("Unable to open " + lookupFileName + ". Trying mothur's executable location " + tryPath); m->mothurOutEndLine();
-                                       ifstream in2;
-                                       ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                       in2.close();
-                                       lookupFileName = tryPath;
-                               }
-                               
-                               if (ableToOpen == 1) {  m->mothurOut("Unable to open " + lookupFileName + "."); m->mothurOutEndLine(); abort=true;  }
-                       }
-                       else if(temp == "not open")     {       
+                               bool ableToOpen = m->checkLocations(lookupFileName, inputDir);
+                if (!ableToOpen) { abort=true; }
+                       }else if(temp == "not open")    {       
                                
                                lookupFileName = validParameter.validFile(parameters, "lookup", false);
                                
                                
                                lookupFileName = validParameter.validFile(parameters, "lookup", false);
                                
@@ -384,8 +339,9 @@ int SffMultipleCommand::execute(){
                vector<string> sffFiles, oligosFiles;
         readFile(sffFiles, oligosFiles);
         
                vector<string> sffFiles, oligosFiles;
         readFile(sffFiles, oligosFiles);
         
-        outputDir = m->hasPath(filename);
-        string fileroot = outputDir + m->getRootName(m->getSimpleName(filename));
+        string thisOutputDir = outputDir;
+        if (thisOutputDir == "") { thisOutputDir = m->hasPath(filename); }
+        string fileroot = thisOutputDir + m->getRootName(m->getSimpleName(filename));
         map<string, string> variables; 
                variables["[filename]"] = fileroot;
         string fasta = getOutputFileName("fasta",variables);
         map<string, string> variables; 
                variables["[filename]"] = fileroot;
         string fasta = getOutputFileName("fasta",variables);
@@ -414,6 +370,8 @@ int SffMultipleCommand::execute(){
             if (makeGroup) { outputNames.push_back(group); outputTypes["group"].push_back(group); m->setGroupFile(group); }
         }
         
             if (makeGroup) { outputNames.push_back(group); outputTypes["group"].push_back(group); m->setGroupFile(group); }
         }
         
+        m->setProcessors(toString(processors));
+        
                //report output filenames
                m->mothurOutEndLine();
                m->mothurOut("Output File Names: "); m->mothurOutEndLine();
                //report output filenames
                m->mothurOutEndLine();
                m->mothurOut("Output File Names: "); m->mothurOutEndLine();
@@ -443,11 +401,11 @@ int SffMultipleCommand::readFile(vector<string>& sffFiles, vector<string>& oligo
             
             in >> sff;
             
             
             in >> sff;
             
-            sff = m->getFullPathName(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
             //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
+                bool ableToOpenSff = m->checkLocations(sff, inputDir);
+                
                 oligos = "";
             
                 // get rest of line in case there is a oligos filename
                 oligos = "";
             
                 // get rest of line in case there is a oligos filename
@@ -456,11 +414,18 @@ int SffMultipleCommand::readFile(vector<string>& sffFiles, vector<string>& oligo
                     if (c == 10 || c == 13 || c == -1){        break;  }
                     else if (c == 32 || c == 9){;} //space or tab
                     else {     oligos += c;  }
                     if (c == 10 || c == 13 || c == -1){        break;  }
                     else if (c == 32 || c == 9){;} //space or tab
                     else {     oligos += c;  }
-                } 
-                sffFiles.push_back(sff);
-                if (oligos != "") { oligos = m->getFullPathName(oligos); allBlank = false;  }
-                if (oligos == "") { allFull = false;  }
-                oligosFiles.push_back(oligos); //will push a blank if there is not an oligos for this sff file
+                }
+                
+                if (ableToOpenSff) {
+                    sffFiles.push_back(sff);
+                    if (oligos != "") {
+                        bool ableToOpenOligos = m->checkLocations(oligos, inputDir);
+                        if (ableToOpenOligos) {  allBlank = false; }
+                        else { m->mothurOut("Can not find " + oligos + ". Ignoring.\n"); oligos = ""; }
+                    }
+                    if (oligos == "") { allFull = false;  }
+                    oligosFiles.push_back(oligos); //will push a blank if there is not an oligos for this sff file
+                }else { m->mothurOut("Can not find " + sff + ". Ignoring.\n"); }
             }
             m->gobble(in);
         }
             }
             m->gobble(in);
         }
@@ -490,8 +455,12 @@ int SffMultipleCommand::driver(vector<string> sffFiles, vector<string> oligosFil
             m->mothurOut("\n>>>>>\tProcessing " + sff + " (file " + toString(s+1) + " of " + toString(sffFiles.size()) + ")\t<<<<<\n");
             
             //run sff.info
             m->mothurOut("\n>>>>>\tProcessing " + sff + " (file " + toString(s+1) + " of " + toString(sffFiles.size()) + ")\t<<<<<\n");
             
             //run sff.info
+            string redirects = "";
+            if (inputDir != "")     { redirects += ", inputdir=" + inputDir;    }
+            if (outputDir != "")    { redirects += ", outputdir=" + outputDir;  }
             string inputString = "sff=" + sff + ", flow=T";
             if (trim) { inputString += ", trim=T"; }
             string inputString = "sff=" + sff + ", flow=T";
             if (trim) { inputString += ", trim=T"; }
+            if (redirects != "") { inputString += redirects; }
             m->mothurOut("/******************************************/"); m->mothurOutEndLine(); 
             m->mothurOut("Running command: sffinfo(" + inputString + ")"); m->mothurOutEndLine(); 
             m->mothurCalling = true;
             m->mothurOut("/******************************************/"); m->mothurOutEndLine(); 
             m->mothurOut("Running command: sffinfo(" + inputString + ")"); m->mothurOutEndLine(); 
             m->mothurCalling = true;
@@ -507,6 +476,9 @@ int SffMultipleCommand::driver(vector<string> sffFiles, vector<string> oligosFil
             m->mothurCalling = false;
             m->mothurOutEndLine(); 
             
             m->mothurCalling = false;
             m->mothurOutEndLine(); 
             
+            redirects = "";
+            if (outputDir != "")    { redirects += ", outputdir=" + outputDir;  }
+
             //run summary.seqs on the fasta file
             string fastaFile = "";
             map<string, vector<string> >::iterator it = filenames.find("fasta");
             //run summary.seqs on the fasta file
             string fastaFile = "";
             map<string, vector<string> >::iterator it = filenames.find("fasta");
@@ -514,6 +486,7 @@ int SffMultipleCommand::driver(vector<string> sffFiles, vector<string> oligosFil
             else {  m->mothurOut("[ERROR]: sffinfo did not create a fasta file, quitting.\n"); m->control_pressed = true; break;  }
             
             inputString = "fasta=" + fastaFile + ", processors=1";
             else {  m->mothurOut("[ERROR]: sffinfo did not create a fasta file, quitting.\n"); m->control_pressed = true; break;  }
             
             inputString = "fasta=" + fastaFile + ", processors=1";
+            if (redirects != "") { inputString += redirects; }
             m->mothurOutEndLine(); 
             m->mothurOut("Running command: summary.seqs(" + inputString + ")"); m->mothurOutEndLine(); 
             m->mothurCalling = true;
             m->mothurOutEndLine(); 
             m->mothurOut("Running command: summary.seqs(" + inputString + ")"); m->mothurOutEndLine(); 
             m->mothurCalling = true;
@@ -542,7 +515,7 @@ int SffMultipleCommand::driver(vector<string> sffFiles, vector<string> oligosFil
             inputString += ", maxhomop=" + toString(maxHomoP) + ", maxflows=" + toString(maxFlows) + ", minflows=" + toString(minFlows);
             inputString += ", pdiffs=" + toString(pdiffs) + ", bdiffs=" + toString(bdiffs) + ", ldiffs=" + toString(ldiffs) + ", sdiffs=" + toString(sdiffs);
             inputString += ", tdiffs=" + toString(tdiffs) + ", signal=" + toString(signal) + ", noise=" + toString(noise) + ", order=" + flowOrder + ", processors=1";
             inputString += ", maxhomop=" + toString(maxHomoP) + ", maxflows=" + toString(maxFlows) + ", minflows=" + toString(minFlows);
             inputString += ", pdiffs=" + toString(pdiffs) + ", bdiffs=" + toString(bdiffs) + ", ldiffs=" + toString(ldiffs) + ", sdiffs=" + toString(sdiffs);
             inputString += ", tdiffs=" + toString(tdiffs) + ", signal=" + toString(signal) + ", noise=" + toString(noise) + ", order=" + flowOrder + ", processors=1";
-            
+            if (redirects != "") { inputString += redirects; }
             m->mothurOutEndLine(); 
             m->mothurOut("Running command: trim.flows(" + inputString + ")"); m->mothurOutEndLine(); 
             m->mothurCalling = true;
             m->mothurOutEndLine(); 
             m->mothurOut("Running command: trim.flows(" + inputString + ")"); m->mothurOutEndLine(); 
             m->mothurCalling = true;
@@ -589,7 +562,7 @@ int SffMultipleCommand::driver(vector<string> sffFiles, vector<string> oligosFil
             inputString += ", sigma=" +toString(sigma);
             inputString += ", mindelta=" + toString(minDelta);  
             inputString += ", order=" + flowOrder + ", processors=1";
             inputString += ", sigma=" +toString(sigma);
             inputString += ", mindelta=" + toString(minDelta);  
             inputString += ", order=" + flowOrder + ", processors=1";
-            
+            if (redirects != "") { inputString += redirects; }
             //run shhh.flows
             m->mothurOutEndLine(); 
             m->mothurOut("Running command: shhh.flows(" + inputString + ")"); m->mothurOutEndLine(); 
             //run shhh.flows
             m->mothurOutEndLine(); 
             m->mothurOut("Running command: shhh.flows(" + inputString + ")"); m->mothurOutEndLine(); 
@@ -637,7 +610,7 @@ int SffMultipleCommand::driver(vector<string> sffFiles, vector<string> oligosFil
             if (keepFirst != 0) { inputString += ", keepfirst=" + toString(keepFirst); }
             if (removeLast != 0) { inputString += ", removelast=" + toString(removeLast); }
             inputString += ", processors=1";
             if (keepFirst != 0) { inputString += ", keepfirst=" + toString(keepFirst); }
             if (removeLast != 0) { inputString += ", removelast=" + toString(removeLast); }
             inputString += ", processors=1";
-            
+            if (redirects != "") { inputString += redirects; }
             //run trim.seqs
             m->mothurOutEndLine(); 
             m->mothurOut("Running command: trim.seqs(" + inputString + ")"); m->mothurOutEndLine(); 
             //run trim.seqs
             m->mothurOutEndLine(); 
             m->mothurOut("Running command: trim.seqs(" + inputString + ")"); m->mothurOutEndLine(); 
@@ -688,6 +661,7 @@ int SffMultipleCommand::driver(vector<string> sffFiles, vector<string> oligosFil
             }
             
             inputString = "fasta=" + fastaFile + ", processors=1, name=" + nameFile;
             }
             
             inputString = "fasta=" + fastaFile + ", processors=1, name=" + nameFile;
+            if (redirects != "") { inputString += redirects; }
             m->mothurOutEndLine(); 
             m->mothurOut("Running command: summary.seqs(" + inputString + ")"); m->mothurOutEndLine(); 
             m->mothurCalling = true;
             m->mothurOutEndLine(); 
             m->mothurOut("Running command: summary.seqs(" + inputString + ")"); m->mothurOutEndLine(); 
             m->mothurCalling = true;
@@ -711,13 +685,14 @@ int SffMultipleCommand::driver(vector<string> sffFiles, vector<string> oligosFil
                 m->appendFiles(nameFile, name);
                 if (makeGroup) { m->appendFiles(groupFile, group);  }
             }
                 m->appendFiles(nameFile, name);
                 if (makeGroup) { m->appendFiles(groupFile, group);  }
             }
-            count++;
+            
             
             for (it = filenames.begin(); it != filenames.end(); it++) {
                 for (int i = 0; i < (it->second).size(); i++) {
                     outputNames.push_back((it->second)[i]); outputTypes[it->first].push_back((it->second)[i]);
                 }
             }
             
             for (it = filenames.begin(); it != filenames.end(); it++) {
                 for (int i = 0; i < (it->second).size(); i++) {
                     outputNames.push_back((it->second)[i]); outputTypes[it->first].push_back((it->second)[i]);
                 }
             }
+            count++;
         }
         
         return count;
         }
         
         return count;
index ee83d727ad3b3a1e910f4b3cb633eae53938f87a..1a492a82155fe0a7314b8c2ec54a9a4b37017909 100644 (file)
@@ -42,7 +42,8 @@ private:
                int end;
                linePair(int i, int j) : start(i), end(j) {}
        };
                int end;
                linePair(int i, int j) : start(i), end(j) {}
        };
-
+    
+    string inputDir;
        string filename, outputDir, flowOrder, lookupFileName, minDelta;
        vector<string> outputNames;
        bool abort, trim, large, flip, allFiles, keepforward, append, makeGroup;
        string filename, outputDir, flowOrder, lookupFileName, minDelta;
        vector<string> outputNames;
        bool abort, trim, large, flip, allFiles, keepforward, append, makeGroup;
index 66dbb8eac3ee13c069b85374503dd87cc0ae538f..8e91b8a93c03e83687ebf574fab99e6b731bd306 100644 (file)
--- a/venn.cpp
+++ b/venn.cpp
@@ -162,7 +162,9 @@ vector<string> Venn::getPic(vector<SharedRAbundVector*> lookup, vector<Calculato
                                if (vCalcs[i]->getName() == "sharedsobs") {
                                        singleCalc = new Sobs();
                     if (sharedOtus &&  (labels.size() != 0)) {
                                if (vCalcs[i]->getName() == "sharedsobs") {
                                        singleCalc = new Sobs();
                     if (sharedOtus &&  (labels.size() != 0)) {
-                        string filenameShared = outputDir + m->getRootName(m->getSimpleName(inputfile)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + ".sharedotus";
+                        string groupsTag = "";
+                        for (int h = 0; h < lookup.size()-1; h++) { groupsTag += lookup[h]->getGroup() + "-"; }  groupsTag += lookup[lookup.size()-1]->getGroup();
+                        string filenameShared = outputDir + m->getRootName(m->getSimpleName(inputfile)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + groupsTag + ".sharedotus";
                         
                         outputNames.push_back(filenameShared);
                         ofstream outShared;
                         
                         outputNames.push_back(filenameShared);
                         ofstream outShared;
@@ -455,7 +457,9 @@ vector<string> Venn::getPic(vector<SharedRAbundVector*> lookup, vector<Calculato
                                        
                     ofstream outShared;
                     if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs")) {
                                        
                     ofstream outShared;
                     if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs")) {
-                        string filenameShared = outputDir + m->getRootName(m->getSimpleName(inputfile)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + ".sharedotus";
+                        string groupsTag = "";
+                        for (int h = 0; h < lookup.size()-1; h++) { groupsTag += lookup[h]->getGroup() + "-"; }  groupsTag += lookup[lookup.size()-1]->getGroup();
+                        string filenameShared = outputDir + m->getRootName(m->getSimpleName(inputfile)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + groupsTag + ".sharedotus";
                         
                         outputNames.push_back(filenameShared);
                        
                         
                         outputNames.push_back(filenameShared);
                        
@@ -660,7 +664,9 @@ vector<string> Venn::getPic(vector<SharedRAbundVector*> lookup, vector<Calculato
                     
                     ofstream outShared;
                     if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs")) {
                     
                     ofstream outShared;
                     if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs")) {
-                        string filenameShared = outputDir + m->getRootName(m->getSimpleName(inputfile)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + ".sharedotus";
+                        string groupsTag = "";
+                        for (int h = 0; h < lookup.size()-1; h++) { groupsTag += lookup[h]->getGroup() + "-"; }  groupsTag += lookup[lookup.size()-1]->getGroup();
+                        string filenameShared = outputDir + m->getRootName(m->getSimpleName(inputfile)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + groupsTag + ".sharedotus";
                         
                         outputNames.push_back(filenameShared);
                         
                         
                         outputNames.push_back(filenameShared);