X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=unifracweightedcommand.cpp;h=f9dc450444b242555710f91dc3567f96e69e6d3d;hb=8dd3c225255d7084e3aff8740aa4f1f1cabb367a;hp=994f09bcda36aa0bd5705b921cdc647387bd9500;hpb=c651c46022761aef61644f78462365d8f767ff0b;p=mothur.git diff --git a/unifracweightedcommand.cpp b/unifracweightedcommand.cpp index 994f09b..f9dc450 100644 --- a/unifracweightedcommand.cpp +++ b/unifracweightedcommand.cpp @@ -134,14 +134,14 @@ UnifracWeightedCommand::UnifracWeightedCommand(string option) { } m->runParse = true; - m->Groups.clear(); - m->namesOfGroups.clear(); + m->clearGroups(); + m->clearAllGroups(); m->Treenames.clear(); m->names.clear(); //check for required parameters treefile = validParameter.validFile(parameters, "tree", true); - if (treefile == "not open") { abort = true; } + if (treefile == "not open") { treefile = ""; abort = true; } else if (treefile == "not found") { //if there is a current design file, use it treefile = m->getTreeFile(); if (treefile != "") { m->mothurOut("Using " + treefile + " as input file for the tree parameter."); m->mothurOutEndLine(); } @@ -155,7 +155,7 @@ UnifracWeightedCommand::UnifracWeightedCommand(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); } @@ -168,11 +168,11 @@ 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"; } - convert(itersString, iters); + m->mothurConvert(itersString, iters); string temp = validParameter.validFile(parameters, "distance", false); if (temp == "not found") { phylip = false; outputForm = ""; } @@ -189,9 +189,14 @@ UnifracWeightedCommand::UnifracWeightedCommand(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 + + if (namefile == "") { + vector files; files.push_back(treefile); + parser.getNameFile(files); + } } @@ -253,7 +258,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 +282,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 +335,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 +417,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]; } @@ -639,17 +647,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]; @@ -658,9 +666,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 += " "; } } @@ -675,12 +683,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 += " "; } }