+//**********************************************************************************************************************
+LibShuffCommand::LibShuffCommand(string option) {
+ try {
+ abort = false; calledHelp = false;
+
+ //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 (it = parameters.begin(); it != parameters.end(); it++) {
+ if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; }
+ }
+
+ //initialize outputTypes
+ vector<string> tempOutNames;
+ outputTypes["coverage"] = tempOutNames;
+ outputTypes["libshuffsummary"] = tempOutNames;
+
+ string inputDir = validParameter.validFile(parameters, "inputdir", false);
+ if (inputDir == "not found"){ inputDir = ""; }
+ else {
+ string path;
+ it = parameters.find("phylip");
+ //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["phylip"] = inputDir + it->second; }
+ }
+
+ it = parameters.find("group");
+ //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["group"] = inputDir + it->second; }
+ }
+ }
+
+ //check for required parameters
+ phylipfile = validParameter.validFile(parameters, "phylip", true);
+ if (phylipfile == "not open") { phylipfile = ""; abort = true; }
+ else if (phylipfile == "not found") {
+ phylipfile = m->getPhylipFile();
+ if (phylipfile != "") { m->mothurOut("Using " + phylipfile + " as input file for the phylip parameter."); m->mothurOutEndLine(); }
+ else {
+ m->mothurOut("You must provide a phylip file."); m->mothurOutEndLine();
+ abort = true;
+ }
+ }else { m->setPhylipFile(phylipfile); }
+
+ //check for required parameters
+ groupfile = validParameter.validFile(parameters, "group", true);
+ if (groupfile == "not open") { groupfile = ""; abort = true; }
+ else if (groupfile == "not found") {
+ groupfile = m->getGroupFile();
+ if (groupfile != "") { m->mothurOut("Using " + groupfile + " as input file for the group parameter."); m->mothurOutEndLine(); }
+ else {
+ m->mothurOut("You must provide a group file."); m->mothurOutEndLine();
+ abort = true;
+ }
+ }else { m->setGroupFile(groupfile); }
+
+ //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(phylipfile); //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...
+ groups = validParameter.validFile(parameters, "groups", false);
+ if (groups == "not found") { groups = ""; savegroups = groups; }
+ else {
+ savegroups = groups;
+ m->splitAtDash(groups, Groups);
+ m->setGroups(Groups);
+ }
+
+ string temp;
+ temp = validParameter.validFile(parameters, "iters", false); if (temp == "not found") { temp = "10000"; }
+ m->mothurConvert(temp, iters);
+
+ temp = validParameter.validFile(parameters, "cutoff", false); if (temp == "not found") { temp = "1.0"; }
+ m->mothurConvert(temp, cutOff);
+
+ temp = validParameter.validFile(parameters, "step", false); if (temp == "not found") { temp = "0.01"; }
+ m->mothurConvert(temp, step);
+
+ temp = validParameter.validFile(parameters, "sim", false); if (temp == "not found") { temp = "F"; }
+ sim = m->isTrue(temp);
+
+ userform = validParameter.validFile(parameters, "form", false); if (userform == "not found") { userform = "integral"; }
+
+ }
+
+ }
+ catch(exception& e) {
+ m->errorOut(e, "LibShuffCommand", "LibShuffCommand");
+ exit(1);
+ }
+}