+ //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") { 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;
+ }
+
+ namesfile = validParameter.validFile(parameters, "name", true);
+ if (namesfile == "not open") { abort = true; }
+ else if (namesfile == "not found") { namesfile = ""; }
+
+ groupfile = validParameter.validFile(parameters, "group", true);
+ if (groupfile == "not open") { groupfile = ""; abort = true; }
+ else if (groupfile == "not found") { groupfile = ""; }
+ else {
+ //read in group map info.
+ groupMap = new GroupMap(groupfile);
+ groupMap->readMap();
+ }
+
+ sorted = validParameter.validFile(parameters, "sorted", false); if (sorted == "not found"){ sorted = ""; }
+ if ((sorted != "") && (sorted != "name") && (sorted != "bin") && (sorted != "size") && (sorted != "group")) {
+ mothurOut(sorted + " is not a valid option for the sorted parameter. The only options are: name, bin, size and group. I will not sort."); mothurOutEndLine();
+ sorted = "";
+ }
+
+ if ((sorted == "group") && (groupfile == "")) {
+ mothurOut("You must provide a groupfile to sort by group. I will not sort."); mothurOutEndLine();
+ sorted = "";
+ }
+
+ if (abort == false) {
+
+ if(globaldata->gSparseMatrix != NULL) {
+ matrix = globaldata->gSparseMatrix;
+ }