+ abort = false; calledHelp = false;
+ Groups.clear();
+
+ //allow user to run help
+ if(option == "help") { help(); abort = true; calledHelp = true; }
+
+ else {
+ //valid paramters for this command
+ string Array[] = {"iters","groups","step","form","cutoff","outputdir","inputdir"};
+ 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; }
+ }
+
+ //initialize outputTypes
+ vector<string> tempOutNames;
+ outputTypes["coverage"] = tempOutNames;
+ outputTypes["libshuffsummary"] = 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->getPhylipFile()); //if user entered a file with a path then preserve it
+ }
+
+ //make sure the user has already run the read.dist command
+ if ((globaldata->gMatrix == NULL) || (globaldata->gGroupmap == NULL)) {
+ m->mothurOut("You must read in a matrix and groupfile using the read.dist command, before you use the libshuff command. "); m->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;
+ m->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 and sorts them
+
+ /********************************************************************************************/
+ //this is needed because when we read the matrix we sort it into groups in alphabetical order
+ //the rest of the command and the classes used in this command assume specific order
+ /********************************************************************************************/
+ matrix->setGroups(globaldata->gGroupmap->namesOfGroups);
+ vector<int> sizes;
+ for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) { sizes.push_back(globaldata->gGroupmap->getNumSeqs(globaldata->gGroupmap->namesOfGroups[i])); }
+ matrix->setSizes(sizes);
+