+ abort = false;
+ allLines = 1;
+ labels.clear();
+
+ //allow user to run help
+ if(option == "help") { help(); abort = true; }
+
+ else {
+ //valid paramters for this command
+ string AlignArray[] = {"groups","label","calc", "abund","outputdir","inputdir"};
+ vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/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->getSharedFile() == "")) {
+ m->mothurOut("You must read a list, or a list and a group, or a shared before you can use the venn 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->inputFileName); //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;
+ }
+
+ groups = validParameter.validFile(parameters, "groups", false);
+ if (groups == "not found") { groups = ""; }
+ else {
+ m->splitAtDash(groups, Groups);
+ globaldata->Groups = Groups;
+ }
+
+ format = globaldata->getFormat();
+ calc = validParameter.validFile(parameters, "calc", false);
+ if (calc == "not found") {
+ if(format == "list") { calc = "sobs"; }
+ else { calc = "sharedsobs"; }
+ }
+ else {
+ if (calc == "default") {
+ if(format == "list") { calc = "sobs"; }
+ else { calc = "sharedsobs"; }
+ }
+ }
+ m->splitAtDash(calc, Estimators);
+
+ string temp;
+ temp = validParameter.validFile(parameters, "abund", false); if (temp == "not found") { temp = "10"; }
+ convert(temp, abund);
+
+ if (abort == false) {
+ validCalculator = new ValidCalculators();
+
+ int i;
+
+ if (format == "list") {
+ for (i=0; i<Estimators.size(); i++) {
+ if (validCalculator->isValidCalculator("vennsingle", Estimators[i]) == true) {
+ if (Estimators[i] == "sobs") {
+ vennCalculators.push_back(new Sobs());
+ }else if (Estimators[i] == "chao") {
+ vennCalculators.push_back(new Chao1());
+ }else if (Estimators[i] == "ace") {
+ if(abund < 5)
+ abund = 10;
+ vennCalculators.push_back(new Ace(abund));
+ }
+ }
+ }
+ }else {
+ for (i=0; i<Estimators.size(); i++) {
+ if (validCalculator->isValidCalculator("vennshared", Estimators[i]) == true) {
+ if (Estimators[i] == "sharedsobs") {
+ vennCalculators.push_back(new SharedSobsCS());
+ }else if (Estimators[i] == "sharedchao") {
+ vennCalculators.push_back(new SharedChao1());
+ }else if (Estimators[i] == "sharedace") {
+ vennCalculators.push_back(new SharedAce());
+ }
+ }
+ }
+ }
+
+ //if the users entered no valid calculators don't execute command
+ if (vennCalculators.size() == 0) { m->mothurOut("No valid calculators given, please correct."); m->mothurOutEndLine(); abort = true; }
+ else { venn = new Venn(outputDir); }
+ }
+
+ }
+