}
}
//**********************************************************************************************************************
+string NMDSCommand::getOutputFileNameTag(string type, string inputName=""){
+ try {
+ string outputFileName = "";
+ map<string, vector<string> >::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 == "nmds") { outputFileName = "nmds.axes"; }
+ else if (type == "stress") { outputFileName = "nmds.stress"; }
+ else if (type == "iters") { outputFileName = "nmds.iters"; }
+ 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, "NMDSCommand", "getOutputFileNameTag");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
NMDSCommand::NMDSCommand(){
try {
abort = true; calledHelp = true;
}
string temp = validParameter.validFile(parameters, "mindim", false); if (temp == "not found") { temp = "2"; }
- convert(temp, mindim);
+ m->mothurConvert(temp, mindim);
temp = validParameter.validFile(parameters, "maxiters", false); if (temp == "not found") { temp = "500"; }
- convert(temp, maxIters);
+ m->mothurConvert(temp, maxIters);
temp = validParameter.validFile(parameters, "iters", false); if (temp == "not found") { temp = "10"; }
- convert(temp, iters);
+ m->mothurConvert(temp, iters);
temp = validParameter.validFile(parameters, "maxdim", false); if (temp == "not found") { temp = "2"; }
- convert(temp, maxdim);
+ m->mothurConvert(temp, maxdim);
temp = validParameter.validFile(parameters, "epsilon", false); if (temp == "not found") { temp = "0.000000000001"; }
- convert(temp, epsilon);
+ m->mothurConvert(temp, epsilon);
if (mindim < 1) { m->mothurOut("mindim must be at least 1."); m->mothurOutEndLine(); abort = true; }
- if (maxdim < mindim) { m->mothurOut("maxdim must be greater than mindim."); m->mothurOutEndLine(); abort = true; }
+ if (maxdim < mindim) { maxdim = mindim; }
}
}
vector< vector<double> > axes;
if (axesfile != "") { axes = readAxes(names); }
- string outputFileName = outputDir + m->getRootName(m->getSimpleName(phylipfile)) + "nmds.iters";
- string stressFileName = outputDir + m->getRootName(m->getSimpleName(phylipfile)) + "nmds.stress";
+ string outputFileName = outputDir + m->getRootName(m->getSimpleName(phylipfile)) + getOutputFileNameTag("iters");
+ string stressFileName = outputDir + m->getRootName(m->getSimpleName(phylipfile)) + getOutputFileNameTag("stress");
outputNames.push_back(outputFileName); outputTypes["iters"].push_back(outputFileName);
outputNames.push_back(stressFileName); outputTypes["stress"].push_back(stressFileName);
out.close(); out2.close();
//output best config
- string BestFileName = outputDir + m->getRootName(m->getSimpleName(phylipfile)) + "nmds.axes";
+ string BestFileName = outputDir + m->getRootName(m->getSimpleName(phylipfile)) + getOutputFileNameTag("nmds");
outputNames.push_back(BestFileName); outputTypes["nmds"].push_back(BestFileName);
m->mothurOut("\nNumber of dimensions:\t" + toString(bestDim) + "\n");