- outputFileName = ((getRootName(globaldata->inputFileName)) + "shared.summary");
- openOutputFile(outputFileName, outputFileHandle);
- format = globaldata->getFormat();
- validCalculator = new ValidCalculators();
- util = new SharedUtil();
-
- 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 if (globaldata->Estimators[i] == "sharedkstest") {
- sumCalculators.push_back(new SharedKSTest());
- }else if (globaldata->Estimators[i] == "sharednseqs") {
- sumCalculators.push_back(new SharedNSeqs());
- }else if (globaldata->Estimators[i] == "sharedochiai") {
- sumCalculators.push_back(new SharedOchiai());
- }else if (globaldata->Estimators[i] == "sharedanderberg") {
- sumCalculators.push_back(new SharedAnderberg());
- }else if (globaldata->Estimators[i] == "sharedkulczynski") {
- sumCalculators.push_back(new SharedKulczynski());
- }else if (globaldata->Estimators[i] == "sharedkulczynskicody") {
- sumCalculators.push_back(new SharedKulczynskiCody());
- }else if (globaldata->Estimators[i] == "sharedlennon") {
- sumCalculators.push_back(new SharedLennon());
- }else if (globaldata->Estimators[i] == "sharedmorisitahorn") {
- sumCalculators.push_back(new SharedMorHorn());
- }else if (globaldata->Estimators[i] == "sharedbraycurtis") {
- sumCalculators.push_back(new SharedBrayCurtis());
- }
- else if (globaldata->Estimators[i] == "sharedbdiversity") {
- sumCalculators.push_back(new SharedBDiversity());
+ abort = false; calledHelp = false;
+ allLines = 1;
+ labels.clear();
+ Estimators.clear();
+
+ //allow user to run help
+ if(option == "help") { validCalculator = new ValidCalculators(); help(); abort = true; calledHelp = true; }
+
+ 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;
+ }
+
+ //initialize outputTypes
+ vector<string> tempOutNames;
+ outputTypes["summary"] = tempOutNames;
+
+ //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());
+ }else if (Estimators[i] == "odum") {
+ sumCalculators.push_back(new Odum());
+ }else if (Estimators[i] == "canberra") {
+ sumCalculators.push_back(new Canberra());
+ }else if (Estimators[i] == "structeuclidean") {
+ sumCalculators.push_back(new StructEuclidean());
+ }else if (Estimators[i] == "structchord") {
+ sumCalculators.push_back(new StructChord());
+ }else if (Estimators[i] == "hellinger") {
+ sumCalculators.push_back(new Hellinger());
+ }else if (Estimators[i] == "manhattan") {
+ sumCalculators.push_back(new Manhattan());
+ }else if (Estimators[i] == "structpearson") {
+ sumCalculators.push_back(new StructPearson());
+ }else if (Estimators[i] == "soergel") {
+ sumCalculators.push_back(new Soergel());
+ }else if (Estimators[i] == "spearman") {
+ sumCalculators.push_back(new Spearman());
+ }else if (Estimators[i] == "structkulczynski") {
+ sumCalculators.push_back(new StructKulczynski());
+ }else if (Estimators[i] == "speciesprofile") {
+ sumCalculators.push_back(new SpeciesProfile());
+ }else if (Estimators[i] == "hamming") {
+ sumCalculators.push_back(new Hamming());
+ }else if (Estimators[i] == "structchi2") {
+ sumCalculators.push_back(new StructChi2());
+ }else if (Estimators[i] == "gower") {
+ sumCalculators.push_back(new Gower());
+ }else if (Estimators[i] == "memchi2") {
+ sumCalculators.push_back(new MemChi2());
+ }else if (Estimators[i] == "memchord") {
+ sumCalculators.push_back(new MemChord());
+ }else if (Estimators[i] == "memeuclidean") {
+ sumCalculators.push_back(new MemEuclidean());
+ }else if (Estimators[i] == "mempearson") {
+ sumCalculators.push_back(new MemPearson());
+ }
+ }