- int i;
- for (i=0; i<globaldata->Estimators.size(); i++) {
- if (validCalculator->isValidCalculator("sharedsummary", globaldata->Estimators[i]) == true) {
- if (globaldata->Estimators[i] == "sharedsobs") {
- sumCalculators.push_back(new SharedSobsCS());
- }else if (globaldata->Estimators[i] == "sharedchao") {
- sumCalculators.push_back(new SharedChao1());
- }else if (globaldata->Estimators[i] == "sharedace") {
- sumCalculators.push_back(new SharedAce());
- }else if (globaldata->Estimators[i] == "sharedjabund") {
- sumCalculators.push_back(new SharedJAbund());
- }else if (globaldata->Estimators[i] == "sharedsorensonabund") {
- sumCalculators.push_back(new SharedSorAbund());
- }else if (globaldata->Estimators[i] == "sharedjclass") {
- sumCalculators.push_back(new SharedJclass());
- }else if (globaldata->Estimators[i] == "sharedsorclass") {
- sumCalculators.push_back(new SharedSorClass());
- }else if (globaldata->Estimators[i] == "sharedjest") {
- sumCalculators.push_back(new SharedJest());
- }else if (globaldata->Estimators[i] == "sharedsorest") {
- sumCalculators.push_back(new SharedSorEst());
- }else if (globaldata->Estimators[i] == "sharedthetayc") {
- sumCalculators.push_back(new SharedThetaYC());
- }else if (globaldata->Estimators[i] == "sharedthetan") {
- sumCalculators.push_back(new SharedThetaN());
+ else {
+ //valid paramters for this command
+ string Array[] = {"label","calc","groups","all","outputdir","distance","inputdir", "processors"};
+ 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->getSharedFile() == "") {
+ m->mothurOut("You must read a list and a group, or a shared before you can use the summary.shared command."); m->mothurOutEndLine(); abort = true;
+ }
+
+ //if the user changes the output directory command factory will send this info to us in the output parameter
+ outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){
+ outputDir = "";
+ outputDir += m->hasPath(globaldata->getSharedFile()); //if user entered a file with a path then preserve it
+ }
+
+ //check for optional parameter and set defaults
+ // ...at some point should added some additional type checking...
+ label = validParameter.validFile(parameters, "label", false);
+ if (label == "not found") { label = ""; }
+ else {
+ if(label != "all") { m->splitAtDash(label, labels); allLines = 0; }
+ else { allLines = 1; }
+ }
+
+ //if the user has not specified any labels use the ones from read.otu
+ if(label == "") {
+ allLines = globaldata->allLines;
+ labels = globaldata->labels;
+ }
+
+ calc = validParameter.validFile(parameters, "calc", false);
+ if (calc == "not found") { calc = "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan"; }
+ else {
+ if (calc == "default") { calc = "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan"; }
+ }
+ m->splitAtDash(calc, Estimators);
+
+ groups = validParameter.validFile(parameters, "groups", false);
+ if (groups == "not found") { groups = ""; }
+ else {
+ m->splitAtDash(groups, Groups);
+ globaldata->Groups = Groups;
+ }
+
+ string temp = validParameter.validFile(parameters, "all", false); if (temp == "not found") { temp = "false"; }
+ all = m->isTrue(temp);
+
+ temp = validParameter.validFile(parameters, "distance", false); if (temp == "not found") { temp = "false"; }
+ createPhylip = m->isTrue(temp);
+
+ temp = validParameter.validFile(parameters, "processors", false); if(temp == "not found"){ temp = "1"; }
+ convert(temp, processors);
+
+ if (abort == false) {
+
+ validCalculator = new ValidCalculators();
+ int i;
+
+ for (i=0; i<Estimators.size(); i++) {
+ if (validCalculator->isValidCalculator("sharedsummary", Estimators[i]) == true) {
+ if (Estimators[i] == "sharedsobs") {
+ sumCalculators.push_back(new SharedSobsCS());
+ }else if (Estimators[i] == "sharedchao") {
+ sumCalculators.push_back(new SharedChao1());
+ }else if (Estimators[i] == "sharedace") {
+ sumCalculators.push_back(new SharedAce());
+ }else if (Estimators[i] == "jabund") {
+ sumCalculators.push_back(new JAbund());
+ }else if (Estimators[i] == "sorabund") {
+ sumCalculators.push_back(new SorAbund());
+ }else if (Estimators[i] == "jclass") {
+ sumCalculators.push_back(new Jclass());
+ }else if (Estimators[i] == "sorclass") {
+ sumCalculators.push_back(new SorClass());
+ }else if (Estimators[i] == "jest") {
+ sumCalculators.push_back(new Jest());
+ }else if (Estimators[i] == "sorest") {
+ sumCalculators.push_back(new SorEst());
+ }else if (Estimators[i] == "thetayc") {
+ sumCalculators.push_back(new ThetaYC());
+ }else if (Estimators[i] == "thetan") {
+ sumCalculators.push_back(new ThetaN());
+ }else if (Estimators[i] == "kstest") {
+ sumCalculators.push_back(new KSTest());
+ }else if (Estimators[i] == "sharednseqs") {
+ sumCalculators.push_back(new SharedNSeqs());
+ }else if (Estimators[i] == "ochiai") {
+ sumCalculators.push_back(new Ochiai());
+ }else if (Estimators[i] == "anderberg") {
+ sumCalculators.push_back(new Anderberg());
+ }else if (Estimators[i] == "kulczynski") {
+ sumCalculators.push_back(new Kulczynski());
+ }else if (Estimators[i] == "kulczynskicody") {
+ sumCalculators.push_back(new KulczynskiCody());
+ }else if (Estimators[i] == "lennon") {
+ sumCalculators.push_back(new Lennon());
+ }else if (Estimators[i] == "morisitahorn") {
+ sumCalculators.push_back(new MorHorn());
+ }else if (Estimators[i] == "braycurtis") {
+ sumCalculators.push_back(new BrayCurtis());
+ }else if (Estimators[i] == "whittaker") {
+ sumCalculators.push_back(new Whittaker());
+ }
+ }