X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=unifracweightedcommand.cpp;h=cf54e6420e6b1e4e2c54c87672142b0fb89dc655;hp=a7a41f37b820cb8af77ede45cf31d0b0f4885d84;hb=cd37904452dc95b183ff313ff05720c562902487;hpb=0470f6d037aacb3563c3f7010708120a4a67d4e6 diff --git a/unifracweightedcommand.cpp b/unifracweightedcommand.cpp index a7a41f3..cf54e64 100644 --- a/unifracweightedcommand.cpp +++ b/unifracweightedcommand.cpp @@ -24,14 +24,14 @@ UnifracWeightedCommand::UnifracWeightedCommand(string option) { string Array[] = {"groups","iters"}; 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 (it4 = parameters.begin(); it4 != parameters.end(); it4++) { - if (validParameter->isValidParameter(it4->first, myArray, it4->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; } } if (globaldata->gTree.size() == 0) {//no trees were read @@ -39,17 +39,16 @@ UnifracWeightedCommand::UnifracWeightedCommand(string option) { //check for optional parameter and set defaults // ...at some point should added some additional type checking... - groups = validParameter->validFile(parameters, "groups", false); + groups = validParameter.validFile(parameters, "groups", false); if (groups == "not found") { groups = ""; } else { splitAtDash(groups, Groups); globaldata->Groups = Groups; } - itersString = validParameter->validFile(parameters, "iters", false); if (itersString == "not found") { itersString = "1000"; } + itersString = validParameter.validFile(parameters, "iters", false); if (itersString == "not found") { itersString = "1000"; } convert(itersString, iters); - - delete validParameter; + if (abort == false) { T = globaldata->gTree; @@ -222,7 +221,7 @@ void UnifracWeightedCommand::printWeightedFile() { for(int a = 0; a < numComp; a++) { output->initFile(groupComb[a], tags); //print each line - for (it = validScores.begin(); it != validScores.end(); it++) { + for (map::iterator it = validScores.begin(); it != validScores.end(); it++) { data.push_back(it->first); data.push_back(rScoreFreq[a][it->first]); data.push_back(rCumul[a][it->first]); output->output(data); data.clear(); @@ -310,7 +309,7 @@ void UnifracWeightedCommand::calculateFreqsCumuls() { for (int f = 0; f < numComp; f++) { for (int i = 0; i < rScores[f].size(); i++) { //looks like 0,0,1,1,1,2,4,7... you want to make a map that say rScoreFreq[0] = 2, rScoreFreq[1] = 3... validScores[rScores[f][i]] = rScores[f][i]; - it = rScoreFreq[f].find(rScores[f][i]); + map::iterator it = rScoreFreq[f].find(rScores[f][i]); if (it != rScoreFreq[f].end()) { rScoreFreq[f][rScores[f][i]]++; }else{ @@ -323,9 +322,9 @@ void UnifracWeightedCommand::calculateFreqsCumuls() { for(int a = 0; a < numComp; a++) { float rcumul = 1.0000; //this loop fills the cumulative maps and put 0.0000 in the score freq map to make it easier to print. - for (it = validScores.begin(); it != validScores.end(); it++) { + for (map::iterator it = validScores.begin(); it != validScores.end(); it++) { //make rscoreFreq map and rCumul - it2 = rScoreFreq[a].find(it->first); + map::iterator it2 = rScoreFreq[a].find(it->first); rCumul[a][it->first] = rcumul; //get percentage of random trees with that info if (it2 != rScoreFreq[a].end()) { rScoreFreq[a][it->first] /= iters; rcumul-= it2->second; }