X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=unifracunweightedcommand.cpp;h=a404f79222ac83cf41d42c04ceb614df1e01dceb;hb=8dd3c225255d7084e3aff8740aa4f1f1cabb367a;hp=501e6123f3566d001e48ea266d5a64d42d14dd49;hpb=19fcbbdba99658f5eca244803280f9ee7f9f6607;p=mothur.git diff --git a/unifracunweightedcommand.cpp b/unifracunweightedcommand.cpp index 501e612..a404f79 100644 --- a/unifracunweightedcommand.cpp +++ b/unifracunweightedcommand.cpp @@ -134,8 +134,8 @@ UnifracUnweightedCommand::UnifracUnweightedCommand(string option) { } m->runParse = true; - m->Groups.clear(); - m->namesOfGroups.clear(); + m->clearGroups(); + m->clearAllGroups(); m->Treenames.clear(); m->names.clear(); @@ -155,7 +155,7 @@ UnifracUnweightedCommand::UnifracUnweightedCommand(string option) { else { m->setGroupFile(groupfile); } namefile = validParameter.validFile(parameters, "name", true); - if (namefile == "not open") { abort = true; } + if (namefile == "not open") { namefile = ""; abort = true; } else if (namefile == "not found") { namefile = ""; } else { m->setNameFile(namefile); } @@ -167,11 +167,11 @@ UnifracUnweightedCommand::UnifracUnweightedCommand(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"; } - convert(itersString, iters); + m->mothurConvert(itersString, iters); string temp = validParameter.validFile(parameters, "distance", false); if (temp == "not found") { phylip = false; outputForm = ""; } @@ -188,7 +188,7 @@ UnifracUnweightedCommand::UnifracUnweightedCommand(string option) { temp = validParameter.validFile(parameters, "processors", false); if (temp == "not found"){ temp = m->getProcessors(); } m->setProcessors(temp); - convert(temp, processors); + m->mothurConvert(temp, processors); if (!random) { iters = 0; } //turn off random calcs @@ -196,7 +196,12 @@ UnifracUnweightedCommand::UnifracUnweightedCommand(string option) { if ((phylip) && (Groups.size() == 0)) { groups = "all"; m->splitAtDash(groups, Groups); - m->Groups = Groups; + m->setGroups(Groups); + } + + if (namefile == "") { + vector files; files.push_back(treefile); + parser.getNameFile(files); } } @@ -259,7 +264,7 @@ int UnifracUnweightedCommand::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; } @@ -282,8 +287,11 @@ int UnifracUnweightedCommand::execute() { m->openOutputFile(sumFile, outSum); util = new SharedUtil(); - util->setGroups(m->Groups, tmap->namesOfGroups, allGroups, numGroups, "unweighted"); //sets the groups the user wants to analyze - util->getCombos(groupComb, m->Groups, numComp); + Groups = m->getGroups(); + vector namesGroups = tmap->getNamesOfGroups(); + util->setGroups(Groups, namesGroups, allGroups, numGroups, "unweighted"); //sets the groups the user wants to analyze + util->getCombos(groupComb, Groups, numComp); + m->setGroups(Groups); delete util; if (numGroups == 1) { numComp++; groupComb.push_back(allGroups); } @@ -298,8 +306,10 @@ int UnifracUnweightedCommand::execute() { if (numComp < processors) { processors = numComp; } - outSum << "Tree#" << '\t' << "Groups" << '\t' << "UWScore" <<'\t' << "UWSig" << endl; - m->mothurOut("Tree#\tGroups\tUWScore\tUWSig"); m->mothurOutEndLine(); + outSum << "Tree#" << '\t' << "Groups" << '\t' << "UWScore" <<'\t'; + m->mothurOut("Tree#\tGroups\tUWScore\t"); + if (random) { outSum << "UWSig"; m->mothurOut("UWSig"); } + outSum << endl; m->mothurOutEndLine(); //get pscores for users trees for (int i = 0; i < T.size(); i++) { @@ -401,7 +411,7 @@ int UnifracUnweightedCommand::execute() { outSum.close(); - m->Groups.clear(); + m->clearGroups(); delete tmap; delete unweighted; for (int i = 0; i < T.size(); i++) { delete T[i]; } @@ -485,9 +495,9 @@ void UnifracUnweightedCommand::printUWSummaryFile(int i) { m->mothurOutJustToLog(groupComb[a] + "\t" + toString(utreeScores[a][0]) + "\t<" + toString((1/float(iters))) + "\n"); } }else{ - outSum << setprecision(6) << groupComb[a] << '\t' << utreeScores[a][0] << '\t' << "0.00" << endl; - cout << setprecision(6) << groupComb[a] << '\t' << utreeScores[a][0] << '\t' << "0.00" << endl; - m->mothurOutJustToLog(groupComb[a] + "\t" + toString(utreeScores[a][0]) + "\t0.00\n"); + outSum << setprecision(6) << groupComb[a] << '\t' << utreeScores[a][0] << endl; + cout << setprecision(6) << groupComb[a] << '\t' << utreeScores[a][0] << endl; + m->mothurOutJustToLog(groupComb[a] + "\t" + toString(utreeScores[a][0]) + "\n"); } } @@ -514,18 +524,18 @@ void UnifracUnweightedCommand::createPhylipFile(int i) { 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 int count = 0; - 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][0]; dists[l][r] = utreeScores[count][0]; @@ -534,9 +544,9 @@ void UnifracUnweightedCommand::createPhylipFile(int i) { } //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 += " "; } } @@ -551,12 +561,12 @@ void UnifracUnweightedCommand::createPhylipFile(int i) { 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 += " "; } }