helpString += "Example unifrac.unweighted(groups=A-B-C, iters=500).\n";
helpString += "The default value for groups is all the groups in your groupfile, and iters is 1000.\n";
helpString += "The unifrac.unweighted command output two files: .unweighted and .uwsummary their descriptions are in the manual.\n";
- helpString += "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n\n";
+ helpString += "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n";
return helpString;
}
catch(exception& e) {
//allow user to run help
if(option == "help") { help(); abort = true; calledHelp = true; }
+ else if(option == "citation") { citation(); abort = true; calledHelp = true;}
else {
- //valid paramters for this command
- string Array[] = {"groups","iters","distance","random","root", "processors","outputdir","inputdir"};
- vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+ vector<string> myArray = setParameters();
OptionParser parser(option);
map<string,string> parameters = parser.getParameters();
}
m->runParse = true;
+ m->clearGroups();
+ m->clearAllGroups();
+ m->Treenames.clear();
+ m->names.clear();
//check for required parameters
treefile = validParameter.validFile(parameters, "tree", true);
treefile = m->getTreeFile();
if (treefile != "") { m->mothurOut("Using " + treefile + " as input file for the tree parameter."); m->mothurOutEndLine(); }
else { m->mothurOut("You have no current tree file and the tree parameter is required."); m->mothurOutEndLine(); abort = true; }
- }
+ }else { m->setTreeFile(treefile); }
//check for required parameters
groupfile = validParameter.validFile(parameters, "group", true);
if (groupfile == "not open") { abort = true; }
else if (groupfile == "not found") { groupfile = ""; }
+ 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); }
outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){ outputDir = ""; }
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 = ""; }
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 ((phylip) && (Groups.size() == 0)) {
groups = "all";
m->splitAtDash(groups, Groups);
- m->Groups = Groups;
+ m->setGroups(Groups);
+ }
+
+ if (namefile == "") {
+ vector<string> files; files.push_back(treefile);
+ parser.getNameFile(files);
}
}
if (abort == true) { if (calledHelp) { return 0; } return 2; }
+ m->setTreeFile(treefile);
+
if (groupfile != "") {
//read in group map info.
tmap = new TreeMap(groupfile);
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++) { remove(outputNames[i].c_str()); } outputTypes.clear();
- m->Groups.clear();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
+ m->clearGroups();
return 0;
}
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<string> 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); }
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++) {
delete tmap; delete unweighted;
for (int i = 0; i < T.size(); i++) { delete T[i]; }
outSum.close();
- for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); }
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); }
return 0;
}
userData = unweighted->getValues(T[i], processors, outputDir); //userData[0] = unweightedscore
if (m->control_pressed) { delete tmap; delete unweighted;
- for (int i = 0; i < T.size(); i++) { delete T[i]; }if (random) { delete output; } outSum.close(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); }return 0; }
+ for (int i = 0; i < T.size(); i++) { delete T[i]; }if (random) { delete output; } outSum.close(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); }return 0; }
//output scores for each combination
for(int k = 0; k < numComp; k++) {
randomData = unweighted->getValues(T[i], "", "", processors, outputDir);
if (m->control_pressed) { delete tmap; delete unweighted;
- for (int i = 0; i < T.size(); i++) { delete T[i]; }if (random) { delete output; } outSum.close(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; }
+ for (int i = 0; i < T.size(); i++) { delete T[i]; }if (random) { delete output; } outSum.close(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
for(int k = 0; k < numComp; k++) {
//add trees unweighted score to map of scores
}
if (m->control_pressed) { delete tmap; delete unweighted;
- for (int i = 0; i < T.size(); i++) { delete T[i]; }if (random) { delete output; } outSum.close(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; }
+ for (int i = 0; i < T.size(); i++) { delete T[i]; }if (random) { delete output; } outSum.close(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
//print output files
printUWSummaryFile(i);
outSum.close();
- m->Groups.clear();
+ m->clearGroups();
delete tmap; delete unweighted;
for (int i = 0; i < T.size(); i++) { delete T[i]; }
- if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; }
+ if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
m->mothurOut("It took " + toString(time(NULL) - start) + " secs to run unifrac.unweighted."); m->mothurOutEndLine();
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");
}
}
if ((outputForm == "lt") || (outputForm == "square")) {
//output numSeqs
- out << m->Groups.size() << endl;
+ out << m->getNumGroups() << endl;
}
//make matrix with scores in it
- vector< vector<float> > 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<float> > 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; r<m->Groups.size(); r++) {
+ for (int r=0; r<m->getNumGroups(); r++) {
for (int l = 0; l < r; l++) {
dists[r][l] = utreeScores[count][0];
dists[l][r] = utreeScores[count][0];
}
//output to file
- for (int r=0; r<m->Groups.size(); r++) {
+ for (int r=0; r<m->getNumGroups(); 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 += " "; }
}
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 += " "; }
}