+ abort = false;
+ allLines = 1;
+
+ //allow user to run help
+ if(option == "help") { help(); abort = true; }
+
+ else {
+ //valid paramters for this command
+ string Array[] = {"list","order","shared", "line", "label","group","sabund", "rabund"};
+ 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; }
+ }
+
+ globaldata->newRead();
+
+ //check for required parameters
+ listfile = validParameter.validFile(parameters, "list", true);
+ if (listfile == "not open") { abort = true; }
+ else if (listfile == "not found") { listfile = ""; }
+ else { globaldata->setListFile(listfile); globaldata->setFormat("list"); }
+
+ sabundfile = validParameter.validFile(parameters, "sabund", true);
+ if (sabundfile == "not open") { abort = true; }
+ else if (sabundfile == "not found") { sabundfile = ""; }
+ else { globaldata->setSabundFile(sabundfile); globaldata->setFormat("sabund"); }
+
+ rabundfile = validParameter.validFile(parameters, "rabund", true);
+ if (rabundfile == "not open") { abort = true; }
+ else if (rabundfile == "not found") { rabundfile = ""; }
+ else { globaldata->setRabundFile(rabundfile); globaldata->setFormat("rabund");}
+
+ sharedfile = validParameter.validFile(parameters, "shared", true);
+ if (sharedfile == "not open") { abort = true; }
+ else if (sharedfile == "not found") { sharedfile = ""; }
+ else { globaldata->setSharedFile(sharedfile); globaldata->setFormat("sharedfile"); }
+
+ groupfile = validParameter.validFile(parameters, "group", true);
+ if (groupfile == "not open") { abort = true; }
+ else if (groupfile == "not found") { groupfile = ""; }
+ else {
+ globaldata->setGroupFile(groupfile);
+ groupMap = new GroupMap(groupfile);
+ groupMap->readMap();
+ globaldata->gGroupmap = groupMap;
+ }
+
+ //you are doing a list and group shared
+ if ((listfile != "") && (groupfile != "")) { globaldata->setFormat("shared"); }
+
+ //you have not given a file
+ if ((listfile == "") && (sharedfile == "") && (rabundfile == "") && (sabundfile == "")) {
+ cout << "You must enter either a listfile, rabundfile, sabundfile or a sharedfile with the read.otu command. " << endl; 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; }
+ globaldata->lines = lines;
+ }
+
+ label = validParameter.validFile(parameters, "label", false);
+ if (label == "not found") { label = ""; }
+ else {
+ if(label != "all") { splitAtDash(label, labels); allLines = 0; }
+ else { allLines = 1; }
+ globaldata->labels = labels;
+ }
+
+ globaldata->allLines = allLines;
+
+ //make sure user did not use both the line and label parameters
+ if ((line != "") && (label != "")) { cout << "You cannot use both the line and label parameters at the same time. " << endl; abort = true; }
+
+ orderfile = validParameter.validFile(parameters, "order", true);
+ if (orderfile == "not open") { abort = true; }
+ else if (orderfile == "not found") { orderfile = ""; }
+ else { globaldata->setOrderFile(orderfile); }
+
+
+ if (abort == false) {
+ //gets whichever one of the above is set
+ filename = globaldata->inputFileName;
+ }
+