X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=clustercommand.cpp;h=4db95b45d00e3857513606383f05810f31a30ecd;hb=753dc84cf289b1d5dc0ca5b0c043640927aa951a;hp=36fff2242ee65d3cdb1e72868d173c69ed5bc3ff;hpb=0470f6d037aacb3563c3f7010708120a4a67d4e6;p=mothur.git diff --git a/clustercommand.cpp b/clustercommand.cpp index 36fff22..4db95b4 100644 --- a/clustercommand.cpp +++ b/clustercommand.cpp @@ -24,14 +24,14 @@ ClusterCommand::ClusterCommand(string option){ string Array[] = {"cutoff","precision","method"}; vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); - parser = new OptionParser(); - parser->parse(option, parameters); delete parser; + OptionParser parser(option); + map 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::iterator it = parameters.begin(); it != parameters.end(); it++) { + if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; } } //error checking to make sure they read a distance file @@ -43,18 +43,17 @@ ClusterCommand::ClusterCommand(string option){ // ...at some point should added some additional type checking... //get user cutoff and precision or use defaults string temp; - temp = validParameter->validFile(parameters, "precision", false); if (temp == "not found") { temp = "100"; } + temp = validParameter.validFile(parameters, "precision", false); if (temp == "not found") { temp = "100"; } //saves precision legnth for formatting below length = temp.length(); convert(temp, precision); - temp = validParameter->validFile(parameters, "cutoff", false); if (temp == "not found") { temp = "10"; } + temp = validParameter.validFile(parameters, "cutoff", false); if (temp == "not found") { temp = "10"; } convert(temp, cutoff); cutoff += (5 / (precision * 10.0)); - method = validParameter->validFile(parameters, "method", false); if (method == "not found") { method = "furthest"; } + method = validParameter.validFile(parameters, "method", false); if (method == "not found") { method = "furthest"; } - delete validParameter; if ((method == "furthest") || (method == "nearest") || (method == "average")) { } else {cout << "Not a valid clustering method. Valid clustering algorithms are furthest, nearest or average." << endl; abort = true; } @@ -63,10 +62,10 @@ ClusterCommand::ClusterCommand(string option){ if (abort == false) { //get matrix, list and rabund for execute - if(globaldata->gSparseMatrix != NULL) { matrix = new SparseMatrix(*globaldata->gSparseMatrix); } + if(globaldata->gSparseMatrix != NULL) { matrix = globaldata->gSparseMatrix; } if(globaldata->gListVector != NULL){ - list = new ListVector(*globaldata->gListVector); + list = globaldata->gListVector; rabund = new RAbundVector(list->getRAbundVector()); } @@ -122,8 +121,6 @@ void ClusterCommand::help(){ ClusterCommand::~ClusterCommand(){ delete cluster; - delete matrix; - delete list; delete rabund; }