]> git.donarmstrong.com Git - mothur.git/commitdiff
added reverse.seqs command
authorpschloss <pschloss>
Sat, 6 Jun 2009 10:35:06 +0000 (10:35 +0000)
committerpschloss <pschloss>
Sat, 6 Jun 2009 10:35:06 +0000 (10:35 +0000)
Mothur.xcodeproj/project.pbxproj
commandfactory.cpp
filterseqscommand.cpp
reversecommand.cpp [new file with mode: 0644]
reversecommand.h [new file with mode: 0644]
screenseqscommand.cpp
validcommands.cpp
validparameter.cpp

index 8d362b69205396a26faaf766b14bd6c4ef994bb3..bed134c8d0e6cb80a0ebd02a2e13411b4a84cae9 100644 (file)
                37D9289F0F21331F001D4494 /* validparameter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D928530F21331F001D4494 /* validparameter.cpp */; };
                37E5F3E30F29FD4200F8D827 /* treenode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37E5F3E20F29FD4200F8D827 /* treenode.cpp */; };
                37E5F4920F2A3DA800F8D827 /* readtreecommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37E5F4910F2A3DA800F8D827 /* readtreecommand.cpp */; };
+               7E09C5140FDA79C5002ECAE5 /* reversecommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E09C5130FDA79C5002ECAE5 /* reversecommand.cpp */; };
                7E412F490F8D21B600381DD0 /* slibshuff.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E412F480F8D21B600381DD0 /* slibshuff.cpp */; };
                7E412FEA0F8D3E2C00381DD0 /* libshuff.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E412FE90F8D3E2C00381DD0 /* libshuff.cpp */; };
                7E4130F80F8E58FA00381DD0 /* dlibshuff.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E4130F60F8E58FA00381DD0 /* dlibshuff.cpp */; };
                37E5F3E20F29FD4200F8D827 /* treenode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = treenode.cpp; sourceTree = SOURCE_ROOT; };
                37E5F4900F2A3DA800F8D827 /* readtreecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readtreecommand.h; sourceTree = SOURCE_ROOT; };
                37E5F4910F2A3DA800F8D827 /* readtreecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readtreecommand.cpp; sourceTree = SOURCE_ROOT; };
+               7E09C5120FDA79C5002ECAE5 /* reversecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = reversecommand.h; sourceTree = "<group>"; };
+               7E09C5130FDA79C5002ECAE5 /* reversecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = reversecommand.cpp; sourceTree = "<group>"; };
                7E412F420F8D213C00381DD0 /* libshuff.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libshuff.h; sourceTree = SOURCE_ROOT; };
                7E412F470F8D21B600381DD0 /* slibshuff.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = slibshuff.h; sourceTree = SOURCE_ROOT; };
                7E412F480F8D21B600381DD0 /* slibshuff.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = slibshuff.cpp; sourceTree = SOURCE_ROOT; };
                37D928A90F2133E5001D4494 /* commands */ = {
                        isa = PBXGroup;
                        children = (
+                               7E09C5120FDA79C5002ECAE5 /* reversecommand.h */,
+                               7E09C5130FDA79C5002ECAE5 /* reversecommand.cpp */,
                                37D927CD0F21331F001D4494 /* command.hpp */,
                                378DC5CD0FBDE1C8003B8607 /* aligncommand.h */,
                                378DC5CE0FBDE1C8003B8607 /* aligncommand.cpp */,
                                3799A9500FD6A58C00E33EDE /* distancedb.cpp in Sources */,
                                3799A9510FD6A58C00E33EDE /* seqsummarycommand.cpp in Sources */,
                                371B30B40FD7EE67000414CA /* screenseqscommand.cpp in Sources */,
+                               7E09C5140FDA79C5002ECAE5 /* reversecommand.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index c9a3e6aab4841f8656e813f4acb9fc4e41817b60..a559c81a4fc5a5703858be458d3e472420723f27 100644 (file)
@@ -47,7 +47,7 @@
 #include "getrabundcommand.h"
 #include "seqsummarycommand.h"
 #include "screenseqscommand.h"
-
+#include "reversecommand.h"
 
 /***********************************************************/
 
@@ -105,6 +105,7 @@ Command* CommandFactory::getCommand(string commandName){
                else if(commandName == "align.seqs")                    {   command = new AlignCommand();                               }
                else if(commandName == "summary.seqs")                  {       command = new SeqSummaryCommand();                      }
                else if(commandName == "screen.seqs")                   {       command = new ScreenSeqsCommand();                      }
+               else if(commandName == "reverse.seqs")                  {       command = new ReverseSeqsCommand();                     }
                else                                                                                    {       command = new NoCommand();                                      }
 
                return command;
index e493cbfbf84f90fb0b2c30c58dc7619ca21c437b..e024a242ed8b35771580b00cffd66bc7dd78d66d 100644 (file)
@@ -74,7 +74,6 @@ void FilterSeqsCommand::doSoft() {
                
                if(keep == 0)   {       filter[i] = 0;          }
        }
-       
 }
 
 /**************************************************************************************/
diff --git a/reversecommand.cpp b/reversecommand.cpp
new file mode 100644 (file)
index 0000000..9be2915
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ *  reversecommand.cpp
+ *  Mothur
+ *
+ *  Created by Pat Schloss on 6/6/09.
+ *  Copyright 2009 Patrick D. Schloss. All rights reserved.
+ *
+ */
+
+#include "reversecommand.h"
+#include "sequence.hpp"
+
+
+//***************************************************************************************************************
+
+ReverseSeqsCommand::ReverseSeqsCommand(){
+       try {
+               globaldata = GlobalData::getInstance();
+               if(globaldata->getFastaFile() == "")            {       cout << "you need to at least enter a fasta file name" << endl; }
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the SeqCoordCommand class Function SeqCoordCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the SeqCoordCommand class function SeqCoordCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }       
+}
+
+//***************************************************************************************************************
+
+ReverseSeqsCommand::~ReverseSeqsCommand(){     /*      do nothing      */      }
+
+//***************************************************************************************************************
+
+
+int ReverseSeqsCommand::execute(){
+       try{
+               
+               ifstream inFASTA;
+               openInputFile(globaldata->getFastaFile(), inFASTA);
+               
+               ofstream outFASTA;
+               string reverseFile = getRootName(globaldata->getFastaFile()) + "rc" + getExtension(globaldata->getFastaFile());
+               openOutputFile(reverseFile, outFASTA);
+               
+               while(!inFASTA.eof()){
+                       Sequence currSeq(inFASTA);
+                       currSeq.reverseComplement();
+                       currSeq.printSequence(outFASTA);
+               }
+               inFASTA.close();
+               outFASTA.close();
+               
+               return 0;
+               
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the FilterSeqsCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the FilterSeqsCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+}
+
+//***************************************************************************************************************
diff --git a/reversecommand.h b/reversecommand.h
new file mode 100644 (file)
index 0000000..46211a5
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef REVERSECOMMAND_H
+#define REVERSECOMMAND_H
+
+/*
+ *  reversecommand.h
+ *  Mothur
+ *
+ *  Created by Pat Schloss on 6/6/09.
+ *  Copyright 2009 Patrick D. Schloss. All rights reserved.
+ *
+ */
+
+#include "mothur.h"
+#include "command.hpp"
+#include "globaldata.hpp"
+
+class ReverseSeqsCommand : public Command {
+public:
+       ReverseSeqsCommand();
+       ~ReverseSeqsCommand();
+       int execute();
+       
+private:
+       GlobalData* globaldata; 
+       
+};
+
+#endif
index 05389072025dcaaf05b2dcaf5e3c4a3ab25c892b..3ad84795d784b5a633351021999159d01940ffdb 100644 (file)
@@ -48,8 +48,8 @@ int ScreenSeqsCommand::execute(){
                
                set<string> badSeqNames;
                
-               string goodSeqFile = getRootName(globaldata->inputFileName) + "good" + getExtension(globaldata->inputFileName);
-               string badSeqFile = getRootName(globaldata->inputFileName) + "bad" + getExtension(globaldata->inputFileName);
+               string goodSeqFile = getRootName(globaldata->getFastaFile()) + "good" + getExtension(globaldata->getFastaFile());
+               string badSeqFile = getRootName(globaldata->getFastaFile()) + "bad" + getExtension(globaldata->getFastaFile());
                
                ofstream goodSeqOut;    openOutputFile(goodSeqFile, goodSeqOut);
                ofstream badSeqOut;             openOutputFile(badSeqFile, badSeqOut);          
@@ -73,6 +73,12 @@ int ScreenSeqsCommand::execute(){
                        }
                        gobble(inFASTA);
                }       
+               if(globaldata->getNameFile() != ""){
+                       screenNameGroupFile(badSeqNames);
+               }
+               else if(globaldata->getGroupFile() != ""){
+                       screenGroupFile(badSeqNames);
+               }
                
                return 0;
        }
index ec60b3b974ad832be1b71092bf3cfbdf9bf28e71..a12bacc85f6c61b0dc64e7ab5ee3987bb7a802fa 100644 (file)
@@ -48,6 +48,7 @@ ValidCommands::ValidCommands() {
                commands["align.seqs"]                  = "align.seqs";
                commands["summary.seqs"]                = "summary.seqs";
                commands["screen.seqs"]                 = "screen.seqs";
+               commands["reverse.seqs"]                = "reverse.seqs";
                commands["quit"]                                = "quit"; 
 
                                
index c8144d0cb32fbcd38138986316f607e9f42346df..05cdb1a1ff6829863770a05b31a2bd6e72cabc65 100644 (file)
@@ -282,6 +282,9 @@ void ValidParameters::initCommandParameters() {
                string screenseqsArray[] =  {"fasta", "start", "end", "maxambig", "maxhomop", "minlength", "maxlength", "name", "group"};
                commandParameters["screen.seqs"] = addParameters(screenseqsArray, sizeof(screenseqsArray)/sizeof(string));
 
+               string reverseseqsArray[] =  {"fasta"};
+               commandParameters["reverse.seqs"] = addParameters(reverseseqsArray, sizeof(reverseseqsArray)/sizeof(string));
+
                string vennArray[] =  {"groups","line","label","calc"};
                commandParameters["venn"] = addParameters(vennArray, sizeof(vennArray)/sizeof(string));