//**********************************************************************************************************************
vector<string> ClearcutCommand::setParameters(){
try {
- CommandParameter pphylip("phylip", "InputTypes", "", "", "FastaPhylip", "FastaPhylip", "none",false,false); parameters.push_back(pphylip);
- CommandParameter pfasta("fasta", "InputTypes", "", "", "FastaPhylip", "FastaPhylip", "none",false,false); parameters.push_back(pfasta);
- CommandParameter pverbose("verbose", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pverbose);
- CommandParameter pquiet("quiet", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pquiet);
- CommandParameter pversion("version", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pversion);
- CommandParameter pseed("seed", "String", "", "", "*", "", "",false,false); parameters.push_back(pseed);
- CommandParameter pnorandom("norandom", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pnorandom);
- CommandParameter pshuffle("shuffle", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pshuffle);
- CommandParameter pneighbor("neighbor", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pneighbor);
- CommandParameter pexpblen("expblen", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pexpblen);
- CommandParameter pexpdist("expdist", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pexpdist);
- CommandParameter pDNA("DNA", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pDNA);
- CommandParameter pprotein("protein", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pprotein);
- CommandParameter pjukes("jukes", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pjukes);
- CommandParameter pkimura("kimura", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pkimura);
- CommandParameter pstdout("stdout", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pstdout);
- CommandParameter pntrees("ntrees", "Number", "", "1", "", "", "",false,false); parameters.push_back(pntrees);
- CommandParameter pmatrixout("matrixout", "String", "", "", "", "", "",false,false); parameters.push_back(pmatrixout);
- CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
- CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+ CommandParameter pphylip("phylip", "InputTypes", "", "", "FastaPhylip", "FastaPhylip", "none","tree",false,false,true); parameters.push_back(pphylip);
+ CommandParameter pfasta("fasta", "InputTypes", "", "", "FastaPhylip", "FastaPhylip", "none","tree",false,false,true); parameters.push_back(pfasta);
+ CommandParameter pverbose("verbose", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pverbose);
+ CommandParameter pquiet("quiet", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pquiet);
+ CommandParameter pversion("version", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pversion);
+ CommandParameter pseed("seed", "String", "", "", "*", "", "","",false,false); parameters.push_back(pseed);
+ CommandParameter pnorandom("norandom", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pnorandom);
+ CommandParameter pshuffle("shuffle", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pshuffle);
+ CommandParameter pneighbor("neighbor", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pneighbor);
+ CommandParameter pexpblen("expblen", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pexpblen);
+ CommandParameter pexpdist("expdist", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pexpdist);
+ CommandParameter pDNA("DNA", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pDNA);
+ CommandParameter pprotein("protein", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pprotein);
+ CommandParameter pjukes("jukes", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pjukes);
+ CommandParameter pkimura("kimura", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pkimura);
+ CommandParameter pstdout("stdout", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pstdout);
+ CommandParameter pntrees("ntrees", "Number", "", "1", "", "", "","",false,false); parameters.push_back(pntrees);
+ CommandParameter pmatrixout("matrixout", "String", "", "", "", "", "","",false,false); parameters.push_back(pmatrixout);
+ CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+ CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
vector<string> myArray;
for (int i = 0; i < parameters.size(); i++) { myArray.push_back(parameters[i].name); }
}
}
//**********************************************************************************************************************
-string ClearcutCommand::getOutputFileNameTag(string type, string inputName=""){
- try {
- string outputFileName = "";
- map<string, vector<string> >::iterator it;
+string ClearcutCommand::getOutputPattern(string type) {
+ try {
+ string pattern = "";
- //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 == "tree") { outputFileName = "tre"; }
- else if (type == "matrixout") { outputFileName = ""; }
- 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, "ClearcutCommand", "getOutputFileNameTag");
- exit(1);
- }
+ if (type == "matrixout") { pattern = "[filename],"; }
+ else if (type == "tree") { pattern = "[filename],tre"; }
+ else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true; }
+
+ return pattern;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "ClearcutCommand", "getOutputPattern");
+ exit(1);
+ }
}
//**********************************************************************************************************************
ClearcutCommand::ClearcutCommand(){
if (abort == true) { if (calledHelp) { return 0; } return 2; }
//prepare filename
- string outputName = outputDir + m->getRootName(m->getSimpleName(inputFile)) + getOutputFileNameTag("tree");
+ map<string, string> variables;
+ variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(inputFile));
+ string outputName = getOutputFileName("tree", variables);
outputNames.push_back(outputName); outputTypes["tree"].push_back(outputName);
vector<char*> cPara;
- char* tempClearcut = new char[8];
- strcpy(tempClearcut, "clearcut");
+ char* tempClearcut = new char[9];
+ *tempClearcut = '\0'; strncat(tempClearcut, "clearcut", 8);
cPara.push_back(tempClearcut);
//you gave us a distance matrix
- if (phylipfile != "") { char* temp = new char[10]; strcpy(temp, "--distance"); cPara.push_back(temp); }
+ if (phylipfile != "") { char* temp = new char[11]; *temp = '\0'; strncat(temp, "--distance", 10); cPara.push_back(temp); }
//you gave us a fastafile
- if (fastafile != "") { char* temp = new char[11]; strcpy(temp, "--alignment"); cPara.push_back(temp); }
+ if (fastafile != "") { char* temp = new char[12]; *temp = '\0'; strncat(temp, "--alignment", 11); cPara.push_back(temp); }
- if (version) { char* temp = new char[9]; strcpy(temp, "--version"); cPara.push_back(temp); }
- if (verbose) { char* temp = new char[9]; strcpy(temp, "--verbose"); cPara.push_back(temp); }
- if (quiet) { char* temp = new char[7]; strcpy(temp, "--quiet"); cPara.push_back(temp); }
+ if (version) { char* temp = new char[10]; *temp = '\0'; strncat(temp, "--version", 9); cPara.push_back(temp); }
+ if (verbose) { char* temp = new char[10]; *temp = '\0'; strncat(temp, "--verbose", 9); cPara.push_back(temp); }
+ if (quiet) { char* temp = new char[8]; *temp = '\0'; strncat(temp, "--quiet", 7); cPara.push_back(temp); }
if (seed != "*") {
string tempSeed = "--seed=" + seed;
- char* temp = new char[tempSeed.length()];
- strcpy(temp, tempSeed.c_str());
+ char* temp = new char[tempSeed.length()+1];
+ *temp = '\0'; strncat(temp, tempSeed.c_str(), tempSeed.length());
cPara.push_back(temp);
}
- if (norandom) { char* temp = new char[10]; strcpy(temp, "--norandom"); cPara.push_back(temp); }
- if (shuffle) { char* temp = new char[9]; strcpy(temp, "--shuffle"); cPara.push_back(temp); }
- if (neighbor) { char* temp = new char[10]; strcpy(temp, "--neighbor"); cPara.push_back(temp); }
+ if (norandom) { char* temp = new char[11]; *temp = '\0'; strncat(temp, "--norandom", 10); cPara.push_back(temp); }
+ if (shuffle) { char* temp = new char[10]; *temp = '\0'; strncat(temp, "--shuffle", 9); cPara.push_back(temp); }
+ if (neighbor) { char* temp = new char[11]; *temp = '\0'; strncat(temp, "--neighbor", 10); cPara.push_back(temp); }
string tempIn = "--in=" + inputFile;
- char* tempI = new char[tempIn.length()];
- strcpy(tempI, tempIn.c_str());
+ char* tempI = new char[tempIn.length()+1];
+ *tempI = '\0'; strncat(tempI, tempIn.c_str(), tempIn.length());
cPara.push_back(tempI);
- if (stdoutWanted) { char* temp = new char[8]; strcpy(temp, "--stdout"); cPara.push_back(temp); }
+ if (stdoutWanted) { char* temp = new char[9]; *temp = '\0'; strncat(temp, "--stdout", 8); cPara.push_back(temp); }
else{
string tempOut = "--out=" + outputName;
-
- char* temp = new char[tempOut.length()];
- strcpy(temp, tempOut.c_str());
+ char* temp = new char[tempOut.length()+1];
+ *temp = '\0'; strncat(temp, tempOut.c_str(), tempOut.length());
cPara.push_back(temp);
}
- if (DNA) { char* temp = new char[5]; strcpy(temp, "--DNA"); cPara.push_back(temp); }
- if (protein) { char* temp = new char[9]; strcpy(temp, "--protein"); cPara.push_back(temp); }
- if (jukes) { char* temp = new char[7]; strcpy(temp, "--jukes"); cPara.push_back(temp); }
- if (kimura) { char* temp = new char[8]; strcpy(temp, "--kimura"); cPara.push_back(temp); }
+ if (DNA) { char* temp = new char[6]; *temp = '\0'; strncat(temp, "--DNA", 5); cPara.push_back(temp); }
+ if (protein) { char* temp = new char[10]; *temp = '\0'; strncat(temp, "--protein", 9); cPara.push_back(temp); }
+ if (jukes) { char* temp = new char[8]; *temp = '\0'; strncat(temp, "--jukes", 7); cPara.push_back(temp); }
+ if (kimura) { char* temp = new char[9]; *temp = '\0'; strncat(temp, "--kimura", 8); cPara.push_back(temp); }
if (matrixout != "") {
string tempMatrix = "--matrixout=" + outputDir + matrixout;
- char* temp = new char[tempMatrix.length()];
- strcpy(temp, tempMatrix.c_str());
+ char* temp = new char[tempMatrix.length()+1];
+ *temp = '\0'; strncat(temp, tempMatrix.c_str(), tempMatrix.length());
cPara.push_back(temp);
outputNames.push_back((outputDir + matrixout));
outputTypes["matrixout"].push_back((outputDir + matrixout));
if (ntrees != "1") {
string tempNtrees = "--ntrees=" + ntrees;
- char* temp = new char[tempNtrees.length()];
- strcpy(temp, tempNtrees.c_str());
+ char* temp = new char[tempNtrees.length()+1];
+ *temp = '\0'; strncat(temp, tempNtrees.c_str(), tempNtrees.length());
cPara.push_back(temp);
}
- if (expblen) { char* temp = new char[9]; strcpy(temp, "--expblen"); cPara.push_back(temp); }
- if (expdist) { char* temp = new char[9]; strcpy(temp, "--expdist"); cPara.push_back(temp); }
+ if (expblen) { char* temp = new char[10]; *temp = '\0'; strncat(temp, "--expblen", 9); cPara.push_back(temp); }
+ if (expdist) { char* temp = new char[10]; *temp = '\0'; strncat(temp, "--expdist", 9); cPara.push_back(temp); }
char** clearcutParameters;
clearcutParameters = new char*[cPara.size()];