+SummarySharedCommand::SummarySharedCommand(string option) {
+ try {
+ abort = false; calledHelp = false;
+ allLines = 1;
+
+ //allow user to run help
+ if(option == "help") { help(); abort = true; calledHelp = true; }
+ else if(option == "citation") { citation(); abort = true; calledHelp = true;}
+
+ else {
+ vector<string> myArray = setParameters();
+
+ OptionParser parser(option);
+ map<string, string> parameters = parser.getParameters();
+ map<string, string>::iterator it;
+
+ 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; }
+ }
+
+ //initialize outputTypes
+ vector<string> tempOutNames;
+ outputTypes["summary"] = tempOutNames;
+
+ //if the user changes the input directory command factory will send this info to us in the output parameter
+ string inputDir = validParameter.validFile(parameters, "inputdir", false);
+ if (inputDir == "not found"){ inputDir = ""; }
+ else {
+ string path;
+ it = parameters.find("shared");
+ //user has given a template file
+ if(it != parameters.end()){
+ path = m->hasPath(it->second);
+ //if the user has not given a path then, add inputdir. else leave path alone.
+ if (path == "") { parameters["shared"] = inputDir + it->second; }
+ }
+ }
+
+ //get shared file
+ sharedfile = validParameter.validFile(parameters, "shared", true);
+ if (sharedfile == "not open") { sharedfile = ""; abort = true; }
+ else if (sharedfile == "not found") {
+ //if there is a current shared file, use it
+ sharedfile = m->getSharedFile();
+ if (sharedfile != "") { m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
+ else { m->mothurOut("You have no current sharedfile and the shared parameter is required."); m->mothurOutEndLine(); abort = true; }
+ }else { m->setSharedFile(sharedfile); }
+
+
+ //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 = m->hasPath(sharedfile); }
+
+
+ //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; }
+ }
+
+
+ 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);
+ if (m->inUsersGroups("citation", Estimators)) {
+ ValidCalculators validCalc; validCalc.printCitations(Estimators);
+ //remove citation from list of calcs
+ for (int i = 0; i < Estimators.size(); i++) { if (Estimators[i] == "citation") { Estimators.erase(Estimators.begin()+i); break; } }
+ }
+
+ groups = validParameter.validFile(parameters, "groups", false);
+ if (groups == "not found") { groups = ""; }
+ else {
+ m->splitAtDash(groups, Groups);
+ m->setGroups(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 = m->getProcessors(); }
+ m->setProcessors(temp);
+ m->mothurConvert(temp, processors);
+
+ if (abort == false) {
+
+ ValidCalculators validCalculator;
+ 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());
+ }
+ }
+ }
+
+ mult = false;
+ }
+ }
+ }
+ catch(exception& e) {
+ m->errorOut(e, "SummarySharedCommand", "SummarySharedCommand");
+ exit(1);
+ }
+}