X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=heatmapsimcommand.cpp;h=3de10e6a8cd9411d6829ac699ffd11991af81007;hb=5b72d1cf3fa48730e5bb70d59cced1e43e1fe424;hp=e791f0c65c88e55b8eaf7a022c3d6be454633f69;hpb=19fcbbdba99658f5eca244803280f9ee7f9f6607;p=mothur.git diff --git a/heatmapsimcommand.cpp b/heatmapsimcommand.cpp index e791f0c..3de10e6 100644 --- a/heatmapsimcommand.cpp +++ b/heatmapsimcommand.cpp @@ -30,6 +30,7 @@ vector HeatMapSimCommand::setParameters(){ CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups); CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel); CommandParameter pcalc("calc", "Multiple", "jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-morisitahorn-braycurtis", "jest-thetayc", "", "", "",true,false); parameters.push_back(pcalc); + CommandParameter pfontsize("fontsize", "Number", "", "24", "", "", "",false,false); parameters.push_back(pfontsize); CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir); CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir); @@ -47,11 +48,12 @@ string HeatMapSimCommand::getHelpString(){ try { string helpString = ""; ValidCalculators validCalculator; - helpString += "The heatmap.sim command parameters are shared, phylip, column, name, groups, calc and label. shared or phylip or column and name are required unless valid current files exist.\n"; + helpString += "The heatmap.sim command parameters are shared, phylip, column, name, groups, calc, fontsize and label. shared or phylip or column and name are required unless valid current files exist.\n"; helpString += "There are two ways to use the heatmap.sim command. The first is with the read.otu command. \n"; helpString += "With the read.otu command you may use the groups, label and calc parameters. \n"; helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like included in your heatmap.\n"; helpString += "The group names are separated by dashes. The label parameter allows you to select what distance levels you would like a heatmap created for, and is also separated by dashes.\n"; + helpString += "The fontsize parameter allows you to adjust the font size of the picture created, default=24.\n"; helpString += "The heatmap.sim command should be in the following format: heatmap.sim(groups=yourGroups, calc=yourCalc, label=yourLabels).\n"; helpString += "Example heatmap.sim(groups=A-B-C, calc=jabund).\n"; helpString += "The default value for groups is all the groups in your groupfile, and all labels in your inputfile will be used.\n"; @@ -70,6 +72,28 @@ string HeatMapSimCommand::getHelpString(){ exit(1); } } +//********************************************************************************************************************** + +string HeatMapSimCommand::getOutputFileNameTag(string type, string inputName=""){ + try { + string outputFileName = ""; + map >::iterator it; + + //is this a type this command creates + it = outputTypes.find(type); + if (it == outputTypes.end()) { m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); } + else { + if (type == "svg") { outputFileName = "svg"; } + else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true; } + } + return outputFileName; + } + catch(exception& e) { + m->errorOut(e, "HeatMapSimCommand", "getOutputFileNameTag"); + exit(1); + } +} + //********************************************************************************************************************** HeatMapSimCommand::HeatMapSimCommand(){ try { @@ -113,9 +137,7 @@ HeatMapSimCommand::HeatMapSimCommand(string option) { outputTypes["svg"] = tempOutNames; format = ""; - //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 = ""; } - + //if the user changes the input directory command factory will send this info to us in the output parameter string inputDir = validParameter.validFile(parameters, "inputdir", false); if (inputDir == "not found"){ inputDir = ""; } @@ -208,6 +230,10 @@ HeatMapSimCommand::HeatMapSimCommand(string option) { } } + + //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->hasPath(inputfile); } + //check for optional parameter and set defaults // ...at some point should added some additional type checking... @@ -234,9 +260,11 @@ HeatMapSimCommand::HeatMapSimCommand(string option) { if (groups == "not found") { groups = ""; } else { m->splitAtDash(groups, Groups); - m->Groups = Groups; + m->setGroups(Groups); } + string temp = validParameter.validFile(parameters, "fontsize", false); if (temp == "not found") { temp = "24"; } + m->mothurConvert(temp, fontsize); if (abort == false) { ValidCalculators validCalculator; @@ -286,7 +314,7 @@ int HeatMapSimCommand::execute(){ if (abort == true) { if (calledHelp) { return 0; } return 2; } - heatmap = new HeatMapSim(outputDir, inputfile); + heatmap = new HeatMapSim(outputDir, inputfile, fontsize); if (format == "shared") { runCommandShared(); @@ -325,12 +353,12 @@ int HeatMapSimCommand::runCommandShared() { set processedLabels; set userLabels = labels; - if (m->control_pressed) { delete input; for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } m->Groups.clear(); return 0; } + if (m->control_pressed) { delete input; for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } m->clearGroups(); return 0; } //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) { delete input; for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } m->Groups.clear(); return 0; } + if (m->control_pressed) { delete input; for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } m->clearGroups(); return 0; } if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){ @@ -370,7 +398,7 @@ int HeatMapSimCommand::runCommandShared() { } - if (m->control_pressed) { delete input; m->Groups.clear(); return 0; } + if (m->control_pressed) { delete input; m->clearGroups(); return 0; } //output error messages about any remaining user labels set::iterator it; @@ -385,7 +413,7 @@ int HeatMapSimCommand::runCommandShared() { } } - if (m->control_pressed) { delete input; m->Groups.clear(); return 0; } + if (m->control_pressed) { delete input; m->clearGroups(); return 0; } //run last label if you need to if (needToRun == true) { @@ -399,10 +427,10 @@ int HeatMapSimCommand::runCommandShared() { for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } } - if (m->control_pressed) { delete input; m->Groups.clear(); return 0; } + if (m->control_pressed) { delete input; m->clearGroups(); return 0; } //reset groups parameter - m->Groups.clear(); + m->clearGroups(); delete input;