X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=heatmapcommand.cpp;h=d160525c70174131e8d32ac9803f5bcc756cb80f;hb=6c2b1e530a5c0bb87040e58a3e410097acdfcc3d;hp=10c15d8b1dd9daed1ad21dd40b7e712b829a3ba5;hpb=ca9ac1d80c62f57270b0dcd49410ebe08a8aecd6;p=mothur.git diff --git a/heatmapcommand.cpp b/heatmapcommand.cpp index 10c15d8..d160525 100644 --- a/heatmapcommand.cpp +++ b/heatmapcommand.cpp @@ -52,7 +52,7 @@ string HeatMapCommand::getHelpString(){ helpString += "The default value for groups is all the groups in your groupfile, and all labels in your inputfile will be used.\n"; helpString += "The default value for scale is log10; your other options are log2 and linear.\n"; helpString += "The heatmap.bin command outputs a .svg file for each label you specify.\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) { @@ -61,6 +61,28 @@ string HeatMapCommand::getHelpString(){ } } +//********************************************************************************************************************** + +string HeatMapCommand::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, "HeatMapCommand", "getOutputFileNameTag"); + exit(1); + } +} + //********************************************************************************************************************** HeatMapCommand::HeatMapCommand(){ try { @@ -83,6 +105,7 @@ HeatMapCommand::HeatMapCommand(string option) { //allow user to run help if(option == "help") { help(); abort = true; calledHelp = true; } + else if(option == "citation") { citation(); abort = true; calledHelp = true;} else { vector myArray = setParameters(); @@ -152,27 +175,27 @@ HeatMapCommand::HeatMapCommand(string option) { listfile = validParameter.validFile(parameters, "list", true); if (listfile == "not open") { listfile = ""; abort = true; } else if (listfile == "not found") { listfile = ""; } - else { format = "list"; inputfile = listfile; } + else { format = "list"; inputfile = listfile; m->setListFile(listfile); } sabundfile = validParameter.validFile(parameters, "sabund", true); if (sabundfile == "not open") { sabundfile = ""; abort = true; } else if (sabundfile == "not found") { sabundfile = ""; } - else { format = "sabund"; inputfile = sabundfile; } + else { format = "sabund"; inputfile = sabundfile; m->setSabundFile(sabundfile); } rabundfile = validParameter.validFile(parameters, "rabund", true); if (rabundfile == "not open") { rabundfile = ""; abort = true; } else if (rabundfile == "not found") { rabundfile = ""; } - else { format = "rabund"; inputfile = rabundfile; } + else { format = "rabund"; inputfile = rabundfile; m->setRabundFile(rabundfile); } sharedfile = validParameter.validFile(parameters, "shared", true); if (sharedfile == "not open") { sharedfile = ""; abort = true; } else if (sharedfile == "not found") { sharedfile = ""; } - else { format = "sharedfile"; inputfile = sharedfile; } + else { format = "sharedfile"; inputfile = sharedfile; m->setSharedFile(sharedfile); } relabundfile = validParameter.validFile(parameters, "relabund", true); if (relabundfile == "not open") { relabundfile = ""; abort = true; } else if (relabundfile == "not found") { relabundfile = ""; } - else { format = "relabund"; inputfile = relabundfile; } + else { format = "relabund"; inputfile = relabundfile; m->setRelAbundFile(relabundfile); } if ((sharedfile == "") && (listfile == "") && (rabundfile == "") && (sabundfile == "") && (relabundfile == "")) { @@ -221,14 +244,14 @@ HeatMapCommand::HeatMapCommand(string option) { if (groups == "not found") { groups = ""; } else { m->splitAtDash(groups, Groups); - m->Groups = Groups; + m->setGroups(Groups); } string temp = validParameter.validFile(parameters, "numotu", false); if (temp == "not found") { temp = "0"; } - convert(temp, numOTU); + m->mothurConvert(temp, numOTU); temp = validParameter.validFile(parameters, "fontsize", false); if (temp == "not found") { temp = "24"; } - convert(temp, fontSize); + m->mothurConvert(temp, fontSize); sorted = validParameter.validFile(parameters, "sorted", false); if (sorted == "not found") { @@ -285,8 +308,8 @@ int HeatMapCommand::execute(){ while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) { if (m->control_pressed) { for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } - for (int i = 0; i < outputNames.size(); i++) { if (outputNames[i] != "control") { remove(outputNames[i].c_str()); } } outputTypes.clear(); - m->Groups.clear(); + for (int i = 0; i < outputNames.size(); i++) { if (outputNames[i] != "control") { m->mothurRemove(outputNames[i]); } } outputTypes.clear(); + m->clearGroups(); delete input; delete heatmap; return 0; } @@ -328,8 +351,8 @@ int HeatMapCommand::execute(){ if (m->control_pressed) { - for (int i = 0; i < outputNames.size(); i++) { if (outputNames[i] != "control") { remove(outputNames[i].c_str()); } } outputTypes.clear(); - m->Groups.clear(); + for (int i = 0; i < outputNames.size(); i++) { if (outputNames[i] != "control") { m->mothurRemove(outputNames[i]); } } outputTypes.clear(); + m->clearGroups(); delete input; delete heatmap; return 0; } @@ -358,13 +381,13 @@ int HeatMapCommand::execute(){ } //reset groups parameter - m->Groups.clear(); + m->clearGroups(); }else if ((format == "list") || (format == "rabund") || (format == "sabund")) { while((rabund != NULL) && ((allLines == 1) || (userLabels.size() != 0))) { if (m->control_pressed) { - for (int i = 0; i < outputNames.size(); i++) { if (outputNames[i] != "control") { remove(outputNames[i].c_str()); } } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { if (outputNames[i] != "control") { m->mothurRemove(outputNames[i]); } } outputTypes.clear(); delete rabund; delete input; delete heatmap; return 0; } @@ -403,7 +426,7 @@ int HeatMapCommand::execute(){ } if (m->control_pressed) { - for (int i = 0; i < outputNames.size(); i++) { if (outputNames[i] != "control") { remove(outputNames[i].c_str()); } } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { if (outputNames[i] != "control") { m->mothurRemove(outputNames[i]); } } outputTypes.clear(); delete input; delete heatmap; return 0; } @@ -438,8 +461,8 @@ int HeatMapCommand::execute(){ while((lookupFloat[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) { if (m->control_pressed) { for (int i = 0; i < lookupFloat.size(); i++) { delete lookupFloat[i]; } - for (int i = 0; i < outputNames.size(); i++) { if (outputNames[i] != "control") { remove(outputNames[i].c_str()); } } outputTypes.clear(); - m->Groups.clear(); + for (int i = 0; i < outputNames.size(); i++) { if (outputNames[i] != "control") { m->mothurRemove(outputNames[i]); } } outputTypes.clear(); + m->clearGroups(); delete input; delete heatmap; return 0; } @@ -480,8 +503,8 @@ int HeatMapCommand::execute(){ if (m->control_pressed) { - for (int i = 0; i < outputNames.size(); i++) { if (outputNames[i] != "control") { remove(outputNames[i].c_str()); } } outputTypes.clear(); - m->Groups.clear(); + for (int i = 0; i < outputNames.size(); i++) { if (outputNames[i] != "control") { m->mothurRemove(outputNames[i]); } } outputTypes.clear(); + m->clearGroups(); delete input; delete heatmap; return 0; } @@ -510,7 +533,7 @@ int HeatMapCommand::execute(){ } //reset groups parameter - m->Groups.clear(); + m->clearGroups(); } @@ -518,7 +541,7 @@ int HeatMapCommand::execute(){ delete heatmap; if (m->control_pressed) { - for (int i = 0; i < outputNames.size(); i++) { if (outputNames[i] != "control") { remove(outputNames[i].c_str()); } } outputTypes.clear(); return 0; + for (int i = 0; i < outputNames.size(); i++) { if (outputNames[i] != "control") { m->mothurRemove(outputNames[i]); } } outputTypes.clear(); return 0; } m->mothurOutEndLine();