]> git.donarmstrong.com Git - mothur.git/blobdiff - filterseqscommand.cpp
added set.current and get.current commands and modified existing commands to update...
[mothur.git] / filterseqscommand.cpp
index b9436f8078df0da22408dafc889d16e62d8a7d6c..cb0b131f58e039f5eea76b784334715e1e7481e3 100644 (file)
@@ -25,8 +25,7 @@ vector<string> FilterSeqsCommand::getValidParameters(){
 //**********************************************************************************************************************
 FilterSeqsCommand::FilterSeqsCommand(){        
        try {
-               abort = true;
-               //initialize outputTypes
+               abort = true; calledHelp = true; 
                vector<string> tempOutNames;
                outputTypes["fasta"] = tempOutNames;
                outputTypes["filter"] = tempOutNames;
@@ -62,11 +61,11 @@ vector<string> FilterSeqsCommand::getRequiredFiles(){
 /**************************************************************************************/
 FilterSeqsCommand::FilterSeqsCommand(string option)  {
        try {
-               abort = false;
+               abort = false; calledHelp = false;   
                filterFileName = "";
                
                //allow user to run help
-               if(option == "help") { help(); abort = true; }
+               if(option == "help") { help(); abort = true; calledHelp = true; }
                
                else {
                        //valid paramters for this command
@@ -240,7 +239,7 @@ void FilterSeqsCommand::help(){
 int FilterSeqsCommand::execute() {     
        try {
        
-               if (abort == true) { return 0; }
+               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                ifstream inFASTA;
                m->openInputFile(fastafileNames[0], inFASTA);
@@ -303,6 +302,12 @@ int FilterSeqsCommand::execute() {
                m->mothurOut("Length of the original alignment: " + toString(alignmentLength)); m->mothurOutEndLine();
                m->mothurOut("Number of sequences used to construct filter: " + toString(numSeqs)); m->mothurOutEndLine();
                
+               //set fasta file as new current fastafile
+               string current = "";
+               itTypes = outputTypes.find("fasta");
+               if (itTypes != outputTypes.end()) {
+                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
+               }
                
                m->mothurOutEndLine();
                m->mothurOut("Output File Names: "); m->mothurOutEndLine();
@@ -329,7 +334,7 @@ int FilterSeqsCommand::filterSequences() {
                                
                                string filteredFasta = outputDir + m->getRootName(m->getSimpleName(fastafileNames[s])) + "filter.fasta";
 #ifdef USE_MPI 
-                               int pid, start, end, numSeqsPerProcessor, num; 
+                               int pid, numSeqsPerProcessor, num; 
                                int tag = 2001;
                                vector<unsigned long int>MPIPos;
                                                
@@ -338,7 +343,6 @@ int FilterSeqsCommand::filterSequences() {
                                MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
                                
                                MPI_File outMPI;
-                               MPI_File tempMPI;
                                MPI_File inMPI;
                                int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY; 
                                int inMode=MPI_MODE_RDONLY;