X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=unifracweightedcommand.cpp;h=bc9d0c5048f198ac6e30309e4af0255c67dcf605;hb=4f2c7f477a1ef2d60a1c0c84ab1ba8243af67f87;hp=d6431a051b56f3144dcfc80d430e7d61351da30a;hpb=19fcbbdba99658f5eca244803280f9ee7f9f6607;p=mothur.git diff --git a/unifracweightedcommand.cpp b/unifracweightedcommand.cpp index d6431a0..bc9d0c5 100644 --- a/unifracweightedcommand.cpp +++ b/unifracweightedcommand.cpp @@ -134,8 +134,8 @@ UnifracWeightedCommand::UnifracWeightedCommand(string option) { } m->runParse = true; - m->Groups.clear(); - m->namesOfGroups.clear(); + m->clearGroups(); + m->clearAllGroups(); m->Treenames.clear(); m->names.clear(); @@ -168,7 +168,7 @@ UnifracWeightedCommand::UnifracWeightedCommand(string option) { if (groups == "not found") { groups = ""; } else { m->splitAtDash(groups, Groups); - m->Groups = Groups; + m->setGroups(Groups); } itersString = validParameter.validFile(parameters, "iters", false); if (itersString == "not found") { itersString = "1000"; } @@ -253,7 +253,7 @@ int UnifracWeightedCommand::execute() { if (m->control_pressed) { delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; } for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); - m->Groups.clear(); + m->clearGroups(); return 0; } @@ -277,8 +277,11 @@ int UnifracWeightedCommand::execute() { util = new SharedUtil(); string s; //to make work with setgroups - util->setGroups(m->Groups, tmap->namesOfGroups, s, numGroups, "weighted"); //sets the groups the user wants to analyze - util->getCombos(groupComb, m->Groups, numComp); + Groups = m->getGroups(); + vector nameGroups = tmap->getNamesOfGroups(); + util->setGroups(Groups, nameGroups, s, numGroups, "weighted"); //sets the groups the user wants to analyze + util->getCombos(groupComb, Groups, numComp); + m->setGroups(Groups); delete util; weighted = new Weighted(tmap, includeRoot); @@ -327,7 +330,7 @@ int UnifracWeightedCommand::execute() { vector< vector > namesOfGroupCombos; for (int a=0; a groups; groups.push_back(m->Groups[a]); groups.push_back(m->Groups[l]); + vector groups; groups.push_back((m->getGroups())[a]); groups.push_back((m->getGroups())[l]); namesOfGroupCombos.push_back(groups); } } @@ -409,7 +412,7 @@ int UnifracWeightedCommand::execute() { if (phylip) { createPhylipFile(); } //clear out users groups - m->Groups.clear(); + m->clearGroups(); delete tmap; delete weighted; for (int i = 0; i < T.size(); i++) { delete T[i]; } @@ -581,8 +584,10 @@ void UnifracWeightedCommand::printWeightedFile() { void UnifracWeightedCommand::printWSummaryFile() { try { //column headers - outSum << "Tree#" << '\t' << "Groups" << '\t' << "WScore" << '\t' << "WSig" << endl; - m->mothurOut("Tree#\tGroups\tWScore\tWSig"); m->mothurOutEndLine(); + outSum << "Tree#" << '\t' << "Groups" << '\t' << "WScore" << '\t'; + m->mothurOut("Tree#\tGroups\tWScore\t"); + if (random) { outSum << "WSig"; m->mothurOut("WSig"); } + outSum << endl; m->mothurOutEndLine(); //format output outSum.setf(ios::fixed, ios::floatfield); outSum.setf(ios::showpoint); @@ -602,9 +607,9 @@ void UnifracWeightedCommand::printWSummaryFile() { m->mothurOutJustToLog(toString(i+1) +"\t" + groupComb[j] +"\t" + toString(utreeScores[count]) +"\t<" + toString((1/float(iters))) + "\n"); } }else{ - outSum << setprecision(6) << i+1 << '\t' << groupComb[j] << '\t' << utreeScores[count] << '\t' << "0.00" << endl; - cout << setprecision(6) << i+1 << '\t' << groupComb[j] << '\t' << utreeScores[count] << '\t' << "0.00" << endl; - m->mothurOutJustToLog(toString(i+1) +"\t" + groupComb[j] +"\t" + toString(utreeScores[count]) +"\t0.00\n"); + outSum << setprecision(6) << i+1 << '\t' << groupComb[j] << '\t' << utreeScores[count] << endl; + cout << setprecision(6) << i+1 << '\t' << groupComb[j] << '\t' << utreeScores[count] << endl; + m->mothurOutJustToLog(toString(i+1) +"\t" + groupComb[j] +"\t" + toString(utreeScores[count]) +"\n"); } count++; } @@ -637,17 +642,17 @@ void UnifracWeightedCommand::createPhylipFile() { if ((outputForm == "lt") || (outputForm == "square")) { //output numSeqs - out << m->Groups.size() << endl; + out << m->getNumGroups() << endl; } //make matrix with scores in it - vector< vector > dists; dists.resize(m->Groups.size()); - for (int i = 0; i < m->Groups.size(); i++) { - dists[i].resize(m->Groups.size(), 0.0); + vector< vector > dists; dists.resize(m->getNumGroups()); + for (int i = 0; i < m->getNumGroups(); i++) { + dists[i].resize(m->getNumGroups(), 0.0); } //flip it so you can print it - for (int r=0; rGroups.size(); r++) { + for (int r=0; rgetNumGroups(); r++) { for (int l = 0; l < r; l++) { dists[r][l] = utreeScores[count]; dists[l][r] = utreeScores[count]; @@ -656,9 +661,9 @@ void UnifracWeightedCommand::createPhylipFile() { } //output to file - for (int r=0; rGroups.size(); r++) { + for (int r=0; rgetNumGroups(); r++) { //output name - string name = m->Groups[r]; + string name = (m->getGroups())[r]; if (name.length() < 10) { //pad with spaces to make compatible while (name.length() < 10) { name += " "; } } @@ -673,12 +678,12 @@ void UnifracWeightedCommand::createPhylipFile() { out << name << '\t'; //output distances - for (int l = 0; l < m->Groups.size(); l++) { out << dists[r][l] << '\t'; } + for (int l = 0; l < m->getNumGroups(); l++) { out << dists[r][l] << '\t'; } out << endl; }else{ //output distances for (int l = 0; l < r; l++) { - string otherName = m->Groups[l]; + string otherName = (m->getGroups())[l]; if (otherName.length() < 10) { //pad with spaces to make compatible while (otherName.length() < 10) { otherName += " "; } }