+ listfile = validParameter.validFile(parameters, "list", true);
+ if (listfile == "not found") { mothurOut("list is a required parameter for the get.oturep command."); mothurOutEndLine(); abort = true; }
+ else if (listfile == "not open") { abort = true; }
+
+ //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;
+ }
+
+ //globaldata->gListVector bin 0 = first name read in distance matrix, globaldata->gListVector bin 1 = second name read in distance matrix
+ if (globaldata->gListVector != NULL) {
+ vector<string> names;
+ string binnames;
+ //map names to rows in sparsematrix
+ for (int i = 0; i < globaldata->gListVector->size(); i++) {
+ names.clear();
+ binnames = globaldata->gListVector->get(i);
+
+ splitAtComma(binnames, names);
+
+ for (int j = 0; j < names.size(); j++) {
+ nameToIndex[names[j]] = i;
+ }
+ }
+ } else { mothurOut("error, no listvector."); mothurOutEndLine(); }
+
+ // Create a data structure to quickly access the distance information.
+ // It consists of a vector of distance maps, where each map contains
+ // all distances of a certain sequence. Vector and maps are accessed
+ // via the index of a sequence in the distance matrix
+ seqVec = vector<SeqMap>(globaldata->gListVector->size());
+ for (MatData currentCell = matrix->begin(); currentCell != matrix->end(); currentCell++) {
+ seqVec[currentCell->row][currentCell->column] = currentCell->dist;
+ }