From: westcott Date: Tue, 21 Apr 2009 13:33:41 +0000 (+0000) Subject: fixed bug with parsimony(groups=all) and unifrac.unweighted(groups=all) X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=9653c9f8c1b63ecb1a63b45e781c303713d5b5df;p=mothur.git fixed bug with parsimony(groups=all) and unifrac.unweighted(groups=all) --- diff --git a/parsimonycommand.cpp b/parsimonycommand.cpp index b5c59e8..56305e2 100644 --- a/parsimonycommand.cpp +++ b/parsimonycommand.cpp @@ -36,12 +36,8 @@ ParsimonyCommand::ParsimonyCommand() { util->getCombos(groupComb, globaldata->Groups, numComp); globaldata->setGroups(""); - //ABC - if (numComp != 1) { - groupComb.push_back(allGroups); - numComp++; - } - + if (numGroups == 1) { numComp++; groupComb.push_back(allGroups); } + convert(globaldata->getIters(), iters); //how many random trees to generate pars = new Parsimony(tmap); counter = 0; diff --git a/sharedutilities.cpp b/sharedutilities.cpp index edd16c7..454b7d4 100644 --- a/sharedutilities.cpp +++ b/sharedutilities.cpp @@ -211,24 +211,24 @@ void SharedUtil::setGroups(vector& userGroups, vector& allGroups for (int i=0; i < allGroups.size(); i++) { if (allGroups[i] != "xxx") { userGroups.push_back(allGroups[i]); - label += allGroups[i] + "-"; } } } }else { //the user has not entered groups for (int i=0; i < allGroups.size(); i++) { if (allGroups[i] != "xxx") { - label += allGroups[i] + "-"; if (mode == "weighted") { userGroups.push_back(allGroups[i]); }else { numGroups = 1; + label += allGroups[i] + "-"; } } } + //rip extra - off allgroups + label = label.substr(0, label.length()-1); } - if (mode == "weighted") { //if the user only entered invalid groups if (userGroups.size() == 0) { @@ -256,20 +256,11 @@ void SharedUtil::setGroups(vector& userGroups, vector& allGroups for (int i = 0; i < allGroups.size(); i++) { if (allGroups[i] != "xxx") { userGroups.push_back(allGroups[i]); - label += allGroups[i] + "-"; } } - }else { - for (int i = 0; i < userGroups.size(); i++) { - label += userGroups[i] + "-"; - } } - //rip extra - off allgroups - label = label.substr(0, label.length()-1); - if (numGroups != 1) { numGroups = userGroups.size(); } - } } catch(exception& e) { diff --git a/unifracunweightedcommand.cpp b/unifracunweightedcommand.cpp index a9b46bf..fcff253 100644 --- a/unifracunweightedcommand.cpp +++ b/unifracunweightedcommand.cpp @@ -24,13 +24,8 @@ UnifracUnweightedCommand::UnifracUnweightedCommand() { util->getCombos(groupComb, globaldata->Groups, numComp); globaldata->setGroups(""); - //ABC - if (numComp != 1) { - groupComb.push_back(allGroups); - numComp++; - } - - + if (numGroups == 1) { numComp++; groupComb.push_back(allGroups); } + convert(globaldata->getIters(), iters); //how many random trees to generate unweighted = new Unweighted(tmap); @@ -61,9 +56,6 @@ int UnifracUnweightedCommand::execute() { output = new ColumnFile(globaldata->getTreeFile() + toString(i+1) + ".unweighted"); - outSum << i+1 << '\t'; - cout << i+1 << '\t'; - //get unweighted for users tree rscoreFreq.resize(numComp); rCumul.resize(numComp); @@ -116,7 +108,7 @@ int UnifracUnweightedCommand::execute() { printUnweightedFile(); - printUWSummaryFile(); + printUWSummaryFile(i); delete output; rscoreFreq.clear(); @@ -171,7 +163,7 @@ void UnifracUnweightedCommand::printUnweightedFile() { } /***********************************************************/ -void UnifracUnweightedCommand::printUWSummaryFile() { +void UnifracUnweightedCommand::printUWSummaryFile(int i) { try { //format output @@ -180,6 +172,9 @@ void UnifracUnweightedCommand::printUWSummaryFile() { //print each line for(int a = 0; a < numComp; a++) { + outSum << i+1 << '\t'; + cout << i+1 << '\t'; + if (UWScoreSig[a][0] > (1/(float)iters)) { outSum << setprecision(6) << groupComb[a] << '\t' << utreeScores[a][0] << '\t' << setprecision(globaldata->getIters().length()) << UWScoreSig[a][0] << endl; cout << setprecision(6) << groupComb[a] << '\t' << utreeScores[a][0] << '\t' << setprecision(globaldata->getIters().length()) << UWScoreSig[a][0] << endl; diff --git a/unifracunweightedcommand.h b/unifracunweightedcommand.h index d9991e8..e900af4 100644 --- a/unifracunweightedcommand.h +++ b/unifracunweightedcommand.h @@ -51,7 +51,7 @@ class UnifracUnweightedCommand : public Command { ofstream outSum, out; ifstream inFile; - void printUWSummaryFile(); + void printUWSummaryFile(int); void printUnweightedFile();