]> git.donarmstrong.com Git - mothur.git/blobdiff - rarefactcommand.cpp
merged pat's trim seqs edits with sarah's major overhaul of global data; also added...
[mothur.git] / rarefactcommand.cpp
index 680f68c1e6694557edac00e259449d0d53169400..6bf42fc8a2e7d33374f73ba04d0df4f8eff57e1a 100644 (file)
@@ -39,14 +39,14 @@ RareFactCommand::RareFactCommand(string option){
                        string Array[] =  {"iters","freq","line","label","calc","abund"};
                        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;  }
                        }
                        
                        //make sure the user has already run the read.otu command
@@ -54,14 +54,14 @@ RareFactCommand::RareFactCommand(string option){
                        
                        //check for optional parameter and set defaults
                        // ...at some point should added some additional type checking...
-                       line = validParameter->validFile(parameters, "line", false);                            
+                       line = validParameter.validFile(parameters, "line", false);                             
                        if (line == "not found") { line = "";  }
                        else { 
                                if(line != "all") {  splitAtDash(line, lines);  allLines = 0;  }
                                else { allLines = 1;  }
                        }
                        
-                       label = validParameter->validFile(parameters, "label", false);                  
+                       label = validParameter.validFile(parameters, "label", false);                   
                        if (label == "not found") { label = ""; }
                        else { 
                                if(label != "all") {  splitAtDash(label, labels);  allLines = 0;  }
@@ -77,7 +77,7 @@ RareFactCommand::RareFactCommand(string option){
                                lines = globaldata->lines;
                        }
                                
-                       calc = validParameter->validFile(parameters, "calc", false);                    
+                       calc = validParameter.validFile(parameters, "calc", false);                     
                        if (calc == "not found") { calc = "sobs";  }
                        else { 
                                 if (calc == "default")  {  calc = "sobs";  }
@@ -85,16 +85,14 @@ RareFactCommand::RareFactCommand(string option){
                        splitAtDash(calc, Estimators);
 
                        string temp;
-                       temp = validParameter->validFile(parameters, "freq", false);                    if (temp == "not found") { temp = "100"; }
+                       temp = validParameter.validFile(parameters, "freq", false);                     if (temp == "not found") { temp = "100"; }
                        convert(temp, freq); 
                        
-                       temp = validParameter->validFile(parameters, "abund", false);                   if (temp == "not found") { temp = "10"; }
+                       temp = validParameter.validFile(parameters, "abund", false);                    if (temp == "not found") { temp = "10"; }
                        convert(temp, abund); 
                        
-                       temp = validParameter->validFile(parameters, "iters", false);                   if (temp == "not found") { temp = "1000"; }
+                       temp = validParameter.validFile(parameters, "iters", false);                    if (temp == "not found") { temp = "1000"; }
                        convert(temp, nIters); 
-       
-                       delete validParameter;
                        
                        if (abort == false) {