+
+ it = parameters.find("name");
+ //user has given a template file
+ if(it != parameters.end()){
+ path = m->hasPath(it->second);
+ //if the user has not given a path then, add inputdir. else leave path alone.
+ if (path == "") { parameters["name"] = inputDir + it->second; }
+ }
+
+ it = parameters.find("shared");
+ //user has given a template file
+ if(it != parameters.end()){
+ path = m->hasPath(it->second);
+ //if the user has not given a path then, add inputdir. else leave path alone.
+ if (path == "") { parameters["shared"] = inputDir + it->second; }
+ }
+ }
+
+ //required parameters
+ phylipfile = validParameter.validFile(parameters, "phylip", true);
+ if (phylipfile == "not open") { abort = true; }
+ else if (phylipfile == "not found") { phylipfile = ""; }
+ else { format = "phylip"; inputfile = phylipfile; m-> setPhylipFile(phylipfile); if (outputDir == "") { outputDir += m->hasPath(phylipfile); } }
+
+ columnfile = validParameter.validFile(parameters, "column", true);
+ if (columnfile == "not open") { abort = true; }
+ else if (columnfile == "not found") { columnfile = ""; }
+ else { format = "column"; inputfile = columnfile; m->setColumnFile(columnfile); if (outputDir == "") { outputDir += m->hasPath(columnfile); } }
+
+ sharedfile = validParameter.validFile(parameters, "shared", true);
+ if (sharedfile == "not open") { abort = true; }
+ else if (sharedfile == "not found") { sharedfile = ""; }
+ else { format = "shared"; inputfile = sharedfile; m->setSharedFile(sharedfile); if (outputDir == "") { outputDir += m->hasPath(sharedfile); } }
+
+ namefile = validParameter.validFile(parameters, "name", true);
+ if (namefile == "not open") { abort = true; }
+ else if (namefile == "not found") { namefile = ""; }
+ else { m->setNameFile(namefile); }
+
+
+ //error checking on files
+ if ((sharedfile == "") && ((phylipfile == "") && (columnfile == ""))) {
+ sharedfile = m->getSharedFile();
+ if (sharedfile != "") { format = "shared"; inputfile = sharedfile; m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
+ else {
+ //is there are current file available for either of these?
+ //give priority to column, then phylip
+ columnfile = m->getColumnFile();
+ if (columnfile != "") { format = "column"; inputfile = columnfile; m->mothurOut("Using " + columnfile + " as input file for the column parameter."); m->mothurOutEndLine(); }
+ else {
+ phylipfile = m->getPhylipFile();
+ if (phylipfile != "") { format = "phylip"; inputfile = phylipfile; m->mothurOut("Using " + phylipfile + " as input file for the phylip parameter."); m->mothurOutEndLine(); }
+ else {
+ m->mothurOut("No valid current files. You must provide a shared or phylip or column file."); m->mothurOutEndLine();
+ abort = true;
+ }
+ }
+ }
+ }
+ else if ((phylipfile != "") && (columnfile != "")) { m->mothurOut("When running the heatmap.sim command with a distance file you may not use both the column and the phylip parameters."); m->mothurOutEndLine(); abort = true; }
+
+ if (columnfile != "") {
+ if (namefile == "") {
+ namefile = m->getNameFile();
+ if (namefile != "") { m->mothurOut("Using " + namefile + " as input file for the name parameter."); m->mothurOutEndLine(); }
+ else {
+ m->mothurOut("You need to provide a namefile if you are going to use the column format."); m->mothurOutEndLine();
+ abort = true;
+ }
+ }
+ }
+
+
+ //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...
+
+ label = validParameter.validFile(parameters, "label", false);
+ if (label == "not found") { label = ""; }
+ else {
+ if(label != "all") { m->splitAtDash(label, labels); allLines = 0; }
+ else { allLines = 1; }
+ }
+
+ calc = validParameter.validFile(parameters, "calc", false);
+ if (calc == "not found") { calc = "jest-thetayc"; }
+ else {
+ if (calc == "default") { calc = "jest-thetayc"; }
+ }
+ m->splitAtDash(calc, Estimators);
+ if (m->inUsersGroups("citation", Estimators)) {
+ ValidCalculators validCalc; validCalc.printCitations(Estimators);
+ //remove citation from list of calcs
+ for (int i = 0; i < Estimators.size(); i++) { if (Estimators[i] == "citation") { Estimators.erase(Estimators.begin()+i); break; } }
+ }
+
+ groups = validParameter.validFile(parameters, "groups", false);
+ if (groups == "not found") { groups = ""; }
+ else {
+ m->splitAtDash(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;
+
+ int i;
+ for (i=0; i<Estimators.size(); i++) {
+ if (validCalculator.isValidCalculator("heat", Estimators[i]) == true) {
+ if (Estimators[i] == "jabund") {
+ heatCalculators.push_back(new JAbund());
+ }else if (Estimators[i] == "sorabund") {
+ heatCalculators.push_back(new SorAbund());
+ }else if (Estimators[i] == "jclass") {
+ heatCalculators.push_back(new Jclass());
+ }else if (Estimators[i] == "sorclass") {
+ heatCalculators.push_back(new SorClass());
+ }else if (Estimators[i] == "jest") {
+ heatCalculators.push_back(new Jest());
+ }else if (Estimators[i] == "sorest") {
+ heatCalculators.push_back(new SorEst());
+ }else if (Estimators[i] == "thetayc") {
+ heatCalculators.push_back(new ThetaYC());
+ }else if (Estimators[i] == "thetan") {
+ heatCalculators.push_back(new ThetaN());
+ }else if (Estimators[i] == "morisitahorn") {
+ heatCalculators.push_back(new MorHorn());
+ }else if (Estimators[i] == "braycurtis") {
+ heatCalculators.push_back(new BrayCurtis());
+ }
+ }
+ }
+