-
- if(globaldata->gSparseMatrix != NULL) { matrix = new SparseMatrix(*globaldata->gSparseMatrix); }
-
- //listOfNames bin 0 = first name read in distance matrix, listOfNames bin 1 = second name read in distance matrix
- if(globaldata->gListVector != NULL) {
- listOfNames = new ListVector(*globaldata->gListVector);
-
- vector<string> names;
- string binnames;
- //map names to rows in sparsematrix
- for (int i = 0; i < listOfNames->size(); i++) {
- names.clear();
- binnames = listOfNames->get(i);
- splitAtComma(binnames, names);
-
- for (int j = 0; j < names.size(); j++) {
- nameToIndex[names[j]] = i;
- }
+ abort = false;
+ allLines = 1;
+ lines.clear();
+ labels.clear();
+
+ //allow user to run help
+ if(option == "help") { help(); abort = true; }
+
+ else {
+ //valid paramters for this command
+ string Array[] = {"fasta","list","line","label","name", "group"};
+ 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.otu command
+ if ((globaldata->gSparseMatrix == NULL) || (globaldata->gListVector == NULL)) {
+ cout << "Before you use the get.oturep command, you first need to read in a distance matrix." << endl;
+ abort = true;
+ }
+
+ //check for required parameters
+ fastafile = validParameter.validFile(parameters, "fasta", true);
+ if (fastafile == "not found") { cout << "fasta is a required parameter for the get.oturep command." << endl; abort = true; }
+ else if (fastafile == "not open") { abort = true; }
+
+ listfile = validParameter.validFile(parameters, "list", true);
+ if (listfile == "not found") { cout << "list is a required parameter for the get.oturep command." << endl; 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...
+ line = validParameter.validFile(parameters, "line", false);
+ if (line == "not found") { line = ""; }
+ else {
+ if(line != "all") { splitAtDash(line, lines); allLines = 0; }
+ else { allLines = 1; }