+ //allow user to run help
+ if(option == "help") { help(); abort = true; }
+
+ else {
+ //valid paramters for this command
+ string Array[] = {"iters","groups","step","form","cutoff"};
+ 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.dist command
+ if ((globaldata->gMatrix == NULL) || (globaldata->gGroupmap == NULL)) {
+ mothurOut("You must read in a matrix and groupfile using the read.dist command, before you use the libshuff command. "); mothurOutEndLine(); abort = true;;
+ }
+
+ //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;
+ splitAtDash(groups, Groups);
+ globaldata->Groups = Groups;
+ }
+
+ string temp;
+ temp = validParameter.validFile(parameters, "iters", false); if (temp == "not found") { temp = "10000"; }
+ convert(temp, iters);
+
+ temp = validParameter.validFile(parameters, "cutoff", false); if (temp == "not found") { temp = "1.0"; }
+ convert(temp, cutOff);
+
+ temp = validParameter.validFile(parameters, "step", false); if (temp == "not found") { temp = "0.01"; }
+ convert(temp, step);
+
+ userform = validParameter.validFile(parameters, "form", false); if (userform == "not found") { userform = "integral"; }
+
+ if (abort == false) {
+
+ matrix = globaldata->gMatrix; //get the distance matrix
+ setGroups(); //set the groups to be analyzed
+
+ if(userform == "discrete"){
+ form = new DLibshuff(matrix, iters, step, cutOff);
+ }
+ else{
+ form = new SLibshuff(matrix, iters, cutOff);