- int i;
- for (i=0; i<globaldata->summaryEstimators.size(); i++) {
- if(globaldata->summaryEstimators[i] == "sobs"){
- sumCalculators.push_back(new Sobs());
- }else if(globaldata->summaryEstimators[i] == "chao"){
- sumCalculators.push_back(new Chao1());
- }else if(globaldata->summaryEstimators[i] == "ace"){
- sumCalculators.push_back(new Ace());
- }else if(globaldata->summaryEstimators[i] == "jack"){
- sumCalculators.push_back(new Jackknife());
- }else if(globaldata->summaryEstimators[i] == "shannon"){
- sumCalculators.push_back(new Shannon());
- }else if(globaldata->summaryEstimators[i] == "npshannon"){
- sumCalculators.push_back(new NPShannon());
- }else if(globaldata->summaryEstimators[i] == "simpson"){
- sumCalculators.push_back(new Simpson());
- }else if(globaldata->summaryEstimators[i] == "bootstrap"){
- sumCalculators.push_back(new Bootstrap());
+ abort = false;
+ allLines = 1;
+ lines.clear();
+ labels.clear();
+ Estimators.clear();
+
+ //allow user to run help
+ if(option == "help") { validCalculator = new ValidCalculators(); help(); abort = true; }
+
+ else {
+ //valid paramters for this command
+ string Array[] = {"line","label","calc","abund","size"};
+ vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+
+ OptionParser parser(option);
+ map<string,string> parameters = parser.getParameters();
+
+ ValidParameters validParameter;
+
+ //check to make sure all parameters are valid for command
+ 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
+ if ((globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "")) { mothurOut("You must read a list, sabund or rabund before you can use the summary.single command."); mothurOutEndLine(); abort = true; }
+
+ //check for optional parameter and set defaults
+ // ...at some point should added some additional type checking...
+ 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);
+ if (label == "not found") { label = ""; }
+ else {
+ if(label != "all") { splitAtDash(label, labels); allLines = 0; }
+ else { allLines = 1; }
+ }
+
+ //make sure user did not use both the line and label parameters
+ if ((line != "") && (label != "")) { mothurOut("You cannot use both the line and label parameters at the same time. "); mothurOutEndLine(); abort = true; }
+ //if the user has not specified any line or labels use the ones from read.otu
+ else if((line == "") && (label == "")) {
+ allLines = globaldata->allLines;
+ labels = globaldata->labels;
+ lines = globaldata->lines;
+ }
+
+ calc = validParameter.validFile(parameters, "calc", false);
+ if (calc == "not found") { calc = "sobs-chao-ace-jack-shannon-npshannon-simpson"; }
+ else {
+ if (calc == "default") { calc = "sobs-chao-ace-jack-shannon-npshannon-simpson"; }
+ }
+ splitAtDash(calc, Estimators);
+
+ string temp;
+ temp = validParameter.validFile(parameters, "abund", false); if (temp == "not found") { temp = "10"; }
+ convert(temp, abund);
+
+ temp = validParameter.validFile(parameters, "size", false); if (temp == "not found") { temp = "0"; }
+ convert(temp, size);
+
+ if (abort == false) {
+
+ validCalculator = new ValidCalculators();
+ int i;
+
+ for (i=0; i<Estimators.size(); i++) {
+ if (validCalculator->isValidCalculator("summary", Estimators[i]) == true) {
+ if(Estimators[i] == "sobs"){
+ sumCalculators.push_back(new Sobs());
+ }else if(Estimators[i] == "chao"){
+ sumCalculators.push_back(new Chao1());
+ }else if(Estimators[i] == "coverage"){
+ sumCalculators.push_back(new Coverage());
+ }else if(Estimators[i] == "geometric"){
+ sumCalculators.push_back(new Geom());
+ }else if(Estimators[i] == "logseries"){
+ sumCalculators.push_back(new LogSD());
+ }else if(Estimators[i] == "qstat"){
+ sumCalculators.push_back(new QStat());
+ }else if(Estimators[i] == "bergerparker"){
+ sumCalculators.push_back(new BergerParker());
+ }else if(Estimators[i] == "bstick"){
+ sumCalculators.push_back(new BStick());
+ }else if(Estimators[i] == "ace"){
+ if(abund < 5)
+ abund = 10;
+ sumCalculators.push_back(new Ace(abund));
+ }else if(Estimators[i] == "jack"){
+ sumCalculators.push_back(new Jackknife());
+ }else if(Estimators[i] == "shannon"){
+ sumCalculators.push_back(new Shannon());
+ }else if(Estimators[i] == "npshannon"){
+ sumCalculators.push_back(new NPShannon());
+ }else if(Estimators[i] == "simpson"){
+ sumCalculators.push_back(new Simpson());
+ }else if(Estimators[i] == "bootstrap"){
+ sumCalculators.push_back(new Bootstrap());
+ }else if (Estimators[i] == "nseqs") {
+ sumCalculators.push_back(new NSeqs());
+ }else if (Estimators[i] == "goodscoverage") {
+ sumCalculators.push_back(new GoodsCoverage());
+ }else if (Estimators[i] == "efron") {
+ sumCalculators.push_back(new Efron(size));
+ }else if (Estimators[i] == "boneh") {
+ sumCalculators.push_back(new Boneh(size));
+ }else if (Estimators[i] == "solow") {
+ sumCalculators.push_back(new Solow(size));
+ }else if (Estimators[i] == "shen") {
+ sumCalculators.push_back(new Shen(size, abund));
+ }
+ }
+ }