string Array[] = {"line","label","calc","groups"};
vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
- parser = new OptionParser();
- parser->parse(option, parameters); delete parser;
+ OptionParser parser(option);
+ map<string, string> parameters = parser.getParameters();
- ValidParameters* validParameter = new ValidParameters();
+ ValidParameters validParameter;
//check to make sure all parameters are valid for command
- for (it = parameters.begin(); it != parameters.end(); it++) {
- if (validParameter->isValidParameter(it->first, myArray, it->second) != true) { abort = true; }
+ 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->getSharedFile() == "") {
- if (globaldata->getListFile() == "") { cout << "You must read a list and a group, or a shared before you can use the summary.shared command." << endl; abort = true; }
- else if (globaldata->getGroupFile() == "") { cout << "You must read a list and a group, or a shared before you can use the summary.shared command." << endl; abort = true; }
+ cout << "You must read a list and a group, or a shared before you can use the summary.shared 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);
+ line = validParameter.validFile(parameters, "line", false);
if (line == "not found") { line = ""; }
else {
if(line != "all") { splitAtDash(line, lines); allLines = 0; }
else { allLines = 1; }
}
- label = validParameter->validFile(parameters, "label", false);
+ label = validParameter.validFile(parameters, "label", false);
if (label == "not found") { label = ""; }
else {
if(label != "all") { splitAtDash(label, labels); allLines = 0; }
lines = globaldata->lines;
}
- calc = validParameter->validFile(parameters, "calc", false);
+ calc = validParameter.validFile(parameters, "calc", false);
if (calc == "not found") { calc = "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan"; }
else {
if (calc == "default") { calc = "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan"; }
}
splitAtDash(calc, Estimators);
- groups = validParameter->validFile(parameters, "groups", false);
+ groups = validParameter.validFile(parameters, "groups", false);
if (groups == "not found") { groups = ""; }
else {
splitAtDash(groups, Groups);
globaldata->Groups = Groups;
}
- delete validParameter;
-
if (abort == false) {
validCalculator = new ValidCalculators();
outputFileName = ((getRootName(globaldata->inputFileName)) + "shared.summary");
openOutputFile(outputFileName, outputFileHandle);
- format = globaldata->getFormat();
mult = false;
}
}
-
}
catch(exception& e) {
cout << "Standard Error: " << e.what() << " has occurred in the SummarySharedCommand class Function SummarySharedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
//**********************************************************************************************************************
SummarySharedCommand::~SummarySharedCommand(){
- delete input;
- delete read;
- delete validCalculator;
+ if (abort == false) {
+ delete read;
+ delete validCalculator;
+ }
}
//**********************************************************************************************************************
//close files
outputFileHandle.close();
if (mult == true) { outAll.close(); }
+
+ for(int i=0;i<sumCalculators.size();i++){ delete sumCalculators[i]; }
+
+ delete input; globaldata->ginput = NULL;
return 0;
}