]> git.donarmstrong.com Git - mothur.git/blobdiff - reversecommand.cpp
added pca command
[mothur.git] / reversecommand.cpp
index b8ccc0747d54300f4fbc655729d9ce58b6f2d112..37e95685430184760cd0919c18a1cfeea2ec4c42 100644 (file)
@@ -15,7 +15,6 @@
 
 ReverseSeqsCommand::ReverseSeqsCommand(string option){
        try {
-               globaldata = GlobalData::getInstance();
                abort = false;
                
                //allow user to run help
@@ -26,51 +25,41 @@ ReverseSeqsCommand::ReverseSeqsCommand(string option){
                        string Array[] =  {"fasta"};
                        vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
                        
-                       parser = new OptionParser();
-                       parser->parse(option, parameters);  delete parser;
+                       OptionParser parser(option);
+                       map<string,string> parameters = parser.getParameters();
                        
-                       ValidParameters* validParameter = new ValidParameters();
+                       ValidParameters validParameter;
                
                        //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;  }
+                       for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) { 
+                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
                        //check for required parameters
-                       fasta = validParameter->validFile(parameters, "fasta", true);
+                       fasta = validParameter.validFile(parameters, "fasta", true);
                        if (fasta == "not open") { abort = true; }
-                       else if (fasta == "not found") { fasta = ""; cout << "fasta is a required parameter for the reverse.seqs command." << endl; abort = true;  }    
-                       else {  globaldata->setFastaFile(fasta);  globaldata->setFormat("fasta");       }
+                       else if (fasta == "not found") { fasta = ""; mothurOut("fasta is a required parameter for the reverse.seqs command."); mothurOutEndLine(); abort = true;  }     
                        
-                       delete validParameter;
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ReverseSeqsCommand class Function ReverseSeqsCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ReverseSeqsCommand", "ReverseSeqsCommand");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ReverseSeqsCommand class function ReverseSeqsCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 //**********************************************************************************************************************
 
 void ReverseSeqsCommand::help(){
        try {
-               cout << "The reverse.seqs command reads a fastafile and ...." << "\n";
-               cout << "The reverse.seqs command parameter is fasta and it is required." << "\n";
-               cout << "The reverse.seqs command should be in the following format: " << "\n";
-               cout << "reverse.seqs(fasta=yourFastaFile) " << "\n";   
+               mothurOut("The reverse.seqs command reads a fastafile and ....\n");
+               mothurOut("The reverse.seqs command parameter is fasta and it is required.\n");
+               mothurOut("The reverse.seqs command should be in the following format: \n");
+               mothurOut("reverse.seqs(fasta=yourFastaFile) \n");      
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ReverseSeqsCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ReverseSeqsCommand", "help");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the ReverseSeqsCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 //***************************************************************************************************************
@@ -93,9 +82,11 @@ int ReverseSeqsCommand::execute(){
                openOutputFile(reverseFile, outFASTA);
                
                while(!inFASTA.eof()){
-                       Sequence currSeq(inFASTA);
-                       currSeq.reverseComplement();
-                       currSeq.printSequence(outFASTA);
+                       Sequence currSeq(inFASTA);  gobble(inFASTA);
+                       if (currSeq.getName() != "") {
+                               currSeq.reverseComplement();
+                               currSeq.printSequence(outFASTA);
+                       }
                }
                inFASTA.close();
                outFASTA.close();
@@ -104,11 +95,7 @@ int ReverseSeqsCommand::execute(){
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ReverseSeqsCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ReverseSeqsCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "ReverseSeqsCommand", "execute");
                exit(1);
        }
 }