#include "normalizesharedcommand.h"
+//**********************************************************************************************************************
+vector<string> NormalizeSharedCommand::getValidParameters(){
+ try {
+ string Array[] = {"groups","label","method","outputdir","inputdir","norm"};
+ vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+ return myArray;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "NormalizeSharedCommand", "getValidParameters");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+NormalizeSharedCommand::NormalizeSharedCommand(){
+ try {
+ abort = true;
+ //initialize outputTypes
+ vector<string> tempOutNames;
+ outputTypes["shared"] = tempOutNames;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "NormalizeSharedCommand", "NormalizeSharedCommand");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+vector<string> NormalizeSharedCommand::getRequiredParameters(){
+ try {
+ vector<string> myArray;
+ return myArray;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "NormalizeSharedCommand", "getRequiredParameters");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+vector<string> NormalizeSharedCommand::getRequiredFiles(){
+ try {
+ string Array[] = {"shared"};
+ vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+ return myArray;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "NormalizeSharedCommand", "getRequiredFiles");
+ exit(1);
+ }
+}
//**********************************************************************************************************************
NormalizeSharedCommand::NormalizeSharedCommand(string option) {
else {
//valid paramters for this command
- string AlignArray[] = {"groups","label","scale","outputdir","inputdir","norm"};
+ string AlignArray[] = {"groups","label","method","outputdir","inputdir","norm"};
vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
OptionParser parser(option);
if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; }
}
+ //initialize outputTypes
+ vector<string> tempOutNames;
+ outputTypes["shared"] = tempOutNames;
+
//if the user changes the output directory command factory will send this info to us in the output parameter
outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){
outputDir = "";
m->mothurOut("The method parameter allows you to select what method you would like to use to normalize. The only choice is totalgroup. We hope to add more ways to normalize in the future, suggestions are welcome!\n");
m->mothurOut("The norm parameter allows you to number you would like to normalize to. By default this is set to the number of sequences in your smallest group.\n");
m->mothurOut("The normalize.shared command should be in the following format: normalize.shared(groups=yourGroups, label=yourLabels).\n");
- m->mothurOut("Example normalize.shared(groups=A-B-C, scale=averagegroup).\n");
+ m->mothurOut("Example normalize.shared(groups=A-B-C, scale=totalgroup).\n");
m->mothurOut("The default value for groups is all the groups in your groupfile, and all labels in your inputfile will be used.\n");
m->mothurOut("The normalize.shared command outputs a .norm.shared file.\n");
m->mothurOut("Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n\n");
//as long as you are not at the end of the file or done wih the lines you want
while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
- if (m->control_pressed) { for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } globaldata->Groups.clear(); delete read; out.close(); remove(outputFileName.c_str()); return 0; }
+ if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } globaldata->Groups.clear(); delete read; out.close(); remove(outputFileName.c_str()); return 0; }
if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){
//prevent memory leak
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; lookup[i] = NULL; }
- if (m->control_pressed) { globaldata->Groups.clear(); delete read; out.close(); remove(outputFileName.c_str()); return 0; }
+ if (m->control_pressed) { outputTypes.clear(); globaldata->Groups.clear(); delete read; out.close(); remove(outputFileName.c_str()); return 0; }
//get next line to process
lookup = input->getSharedRAbundVectors();
}
- if (m->control_pressed) { globaldata->Groups.clear(); delete read; out.close(); remove(outputFileName.c_str()); return 0; }
+ if (m->control_pressed) { outputTypes.clear(); globaldata->Groups.clear(); delete read; out.close(); remove(outputFileName.c_str()); return 0; }
//output error messages about any remaining user labels
set<string>::iterator it;
delete read;
out.close();
- if (m->control_pressed) { remove(outputFileName.c_str()); return 0;}
+ if (m->control_pressed) { outputTypes.clear(); remove(outputFileName.c_str()); return 0;}
m->mothurOutEndLine();
m->mothurOut("Output File Names: "); m->mothurOutEndLine();
- m->mothurOut(outputFileName); m->mothurOutEndLine();
+ m->mothurOut(outputFileName); m->mothurOutEndLine(); outputNames.push_back(outputFileName); outputTypes["shared"].push_back(outputFileName);
m->mothurOutEndLine();
return 0;
float newNorm = relabund * norm;
//round to nearest int
finalNorm = (int) floor((newNorm + 0.5));
-
+ //cout << thisLookUp[i]->getGroup() << '\t' << abund << '\t' << relabund << '\t' << norm << '\t' << newNorm << '\t' << finalNorm << endl;
+
}else{ m->mothurOut(method + " is not a valid scaling option."); m->mothurOutEndLine(); m->control_pressed = true; return 0; }
//cout << finalNorm << '\t';
eliminateZeroOTUS(thisLookUp);
for (int i = 0; i < thisLookUp.size(); i++) {
- out << thisLookUp[i]->getLabel() << '\t' << thisLookUp[i]->getGroup() << '\t' << thisLookUp[i]->getNumBins() << '\t';
+ out << thisLookUp[i]->getLabel() << '\t' << thisLookUp[i]->getGroup() << '\t';
thisLookUp[i]->print(out);
}