X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=clearcutcommand.cpp;h=d6c284d68159b66255d3cdb29d57217e9dd73af6;hb=260ae19c36cb11a53ddc5a75b5e507f8dd8b31d6;hp=fc028a2f91fae5f2c50e3ba33fef889806f46a6c;hpb=b1bcc272003b50a8c06dc9120754da1f5b744598;p=mothur.git diff --git a/clearcutcommand.cpp b/clearcutcommand.cpp index fc028a2..d6c284d 100644 --- a/clearcutcommand.cpp +++ b/clearcutcommand.cpp @@ -8,7 +8,6 @@ */ #include "clearcutcommand.h" -#include "globaldata.hpp" /**************************************************************************************/ ClearcutCommand::ClearcutCommand(string option) { @@ -21,7 +20,7 @@ ClearcutCommand::ClearcutCommand(string option) { else { //valid paramters for this command string Array[] = {"fasta","phylip","version","verbose","quiet","seed","norandom","shuffle","neighbor","expblen", - "expdist","ntrees","matrixout","stdout","kimura","jukes","protein","DNA","stdin","outputdir","inputdir"}; + "expdist","ntrees","matrixout","stdout","kimura","jukes","protein","DNA","outputdir","inputdir"}; vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); OptionParser parser(option); @@ -43,7 +42,7 @@ ClearcutCommand::ClearcutCommand(string option) { it = parameters.find("fasta"); //user has given a template file if(it != parameters.end()){ - path = hasPath(it->second); + path = m->hasPath(it->second); //if the user has not given a path then, add inputdir. else leave path alone. if (path == "") { parameters["fasta"] = inputDir + it->second; } } @@ -51,7 +50,7 @@ ClearcutCommand::ClearcutCommand(string option) { it = parameters.find("phylip"); //user has given a template file if(it != parameters.end()){ - path = hasPath(it->second); + path = m->hasPath(it->second); //if the user has not given a path then, add inputdir. else leave path alone. if (path == "") { parameters["phylip"] = inputDir + it->second; } } @@ -73,56 +72,53 @@ ClearcutCommand::ClearcutCommand(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 = ""; } + outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){ outputDir = m->hasPath(inputFile); } string temp; temp = validParameter.validFile(parameters, "version", false); if (temp == "not found"){ temp = "F"; } - version = isTrue(temp); + version = m->isTrue(temp); temp = validParameter.validFile(parameters, "verbose", false); if (temp == "not found"){ temp = "F"; } - verbose = isTrue(temp); + verbose = m->isTrue(temp); temp = validParameter.validFile(parameters, "quiet", false); if (temp == "not found"){ temp = "F"; } - quiet = isTrue(temp); + quiet = m->isTrue(temp); seed = validParameter.validFile(parameters, "seed", false); if (seed == "not found"){ seed = "*"; } temp = validParameter.validFile(parameters, "norandom", false); if (temp == "not found"){ temp = "F"; } - norandom = isTrue(temp); + norandom = m->isTrue(temp); temp = validParameter.validFile(parameters, "shuffle", false); if (temp == "not found"){ temp = "F"; } - shuffle = isTrue(temp); + shuffle = m->isTrue(temp); - temp = validParameter.validFile(parameters, "neighbor", false); if (temp == "not found"){ temp = "F"; } - neighbor = isTrue(temp); - - temp = validParameter.validFile(parameters, "stdin", false); if (temp == "not found"){ temp = "F"; } - stdin = isTrue(temp); + temp = validParameter.validFile(parameters, "neighbor", false); if (temp == "not found"){ temp = "T"; } + neighbor = m->isTrue(temp); temp = validParameter.validFile(parameters, "DNA", false); if (temp == "not found"){ temp = "F"; } - DNA = isTrue(temp); + DNA = m->isTrue(temp); temp = validParameter.validFile(parameters, "protein", false); if (temp == "not found"){ temp = "F"; } - protein = isTrue(temp); + protein = m->isTrue(temp); temp = validParameter.validFile(parameters, "jukes", false); if (temp == "not found"){ temp = "F"; } - jukes = isTrue(temp); + jukes = m->isTrue(temp); temp = validParameter.validFile(parameters, "kimura", false); if (temp == "not found"){ temp = "F"; } - kimura = isTrue(temp); + kimura = m->isTrue(temp); temp = validParameter.validFile(parameters, "stdout", false); if (temp == "not found"){ temp = "F"; } - stdout = isTrue(temp); + stdoutWanted = m->isTrue(temp); matrixout = validParameter.validFile(parameters, "matrixout", false); if (matrixout == "not found"){ matrixout = ""; } ntrees = validParameter.validFile(parameters, "ntrees", false); if (ntrees == "not found"){ ntrees = "1"; } temp = validParameter.validFile(parameters, "expblen", false); if (temp == "not found"){ temp = "F"; } - expblen = isTrue(temp); + expblen = m->isTrue(temp); temp = validParameter.validFile(parameters, "expdist", false); if (temp == "not found"){ temp = "F"; } - expdist = isTrue(temp); + expdist = m->isTrue(temp); if ((fastafile != "") && ((!DNA) && (!protein))) { m->mothurOut("You must specify the type of sequences you are using: DNA or protein"); m->mothurOutEndLine(); abort=true; } } @@ -139,7 +135,8 @@ void ClearcutCommand::help(){ try { m->mothurOut("The clearcut command interfaces mothur with the clearcut program written by Initiative for Bioinformatics and Evolutionary Studies (IBEST) at the University of Idaho.\n"); m->mothurOut("For more information about clearcut refer to http://bioinformatics.hungry.com/clearcut/ \n"); - m->mothurOut("The clearcut command parameters are phylip, fasta, version, verbose, quiet, seed, norandom, shuffle, neighbor, expblen, expdist, ntrees, matrixout, stdout, kimura, jukes, protein, DNA, stdin. \n"); + m->mothurOut("The clearcut executable must be in a folder called clearcut in the same folder as your mothur executable, similar to mothur's requirements for using blast. \n"); + m->mothurOut("The clearcut command parameters are phylip, fasta, version, verbose, quiet, seed, norandom, shuffle, neighbor, expblen, expdist, ntrees, matrixout, stdout, kimura, jukes, protein, DNA. \n"); m->mothurOut("The phylip parameter allows you to enter your phylip formatted distance matrix. \n"); m->mothurOut("The fasta parameter allows you to enter your aligned fasta file, if you enter a fastafile you specify if the sequences are DNA or protein using the DNA or protein parameters. \n"); @@ -149,9 +146,8 @@ void ClearcutCommand::help(){ m->mothurOut("The seed parameter allows you to explicitly set the PRNG seed to a specific value. \n"); m->mothurOut("The norandom parameter allows you to attempt joins deterministically, default=F. \n"); m->mothurOut("The shuffle parameter allows you to randomly shuffle the distance matrix, default=F. \n"); - m->mothurOut("The neighbor parameter allows you to use traditional Neighbor-Joining algorithm, default=F. \n"); + m->mothurOut("The neighbor parameter allows you to use traditional Neighbor-Joining algorithm, default=T. \n"); - m->mothurOut("The stdin parameter reads input from STDIN, default=F. \n"); m->mothurOut("The DNA parameter allows you to indicate your fasta file contains DNA sequences, default=F. \n"); m->mothurOut("The protein parameter allows you to indicate your fasta file contains protein sequences, default=F. \n"); @@ -164,6 +160,7 @@ void ClearcutCommand::help(){ m->mothurOut("The clearcut command should be in the following format: \n"); m->mothurOut("clearcut(phylip=yourDistanceFile) \n"); m->mothurOut("Example: clearcut(phylip=abrecovery.phylip.dist) \n"); + } catch(exception& e) { m->errorOut(e, "ClearcutCommand", "help"); @@ -178,15 +175,15 @@ int ClearcutCommand::execute() { if (abort == true) { return 0; } //prepare filename - string outputName = outputDir + getRootName(getSimpleName(inputFile)) + "tre"; + string outputName = outputDir + m->getRootName(m->getSimpleName(inputFile)) + "tre"; //get location of clearcut GlobalData* globaldata = GlobalData::getInstance(); string path = globaldata->argv; path = path.substr(0, (path.find_last_of('m'))); - - string clearcutCommand = path + "clearcut/clearcut "; + string clearcutCommand = path + "clearcut "; + //you gave us a distance matrix if (phylipfile != "") { clearcutCommand += "--distance "; } @@ -201,27 +198,37 @@ int ClearcutCommand::execute() { if (shuffle) { clearcutCommand += "--shuffle "; } if (neighbor) { clearcutCommand += "--neighbor "; } - if (stdin) { clearcutCommand += "--stdin "; } - else { clearcutCommand += "--in=" + inputFile + " "; } - if (stdout) { clearcutCommand += "--stdout "; } - else { clearcutCommand += "--out=" + outputName + " "; } + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + clearcutCommand += "--in=" + inputFile + " "; + #else + clearcutCommand += "--in=\"" + inputFile + "\" "; + #endif + + if (stdoutWanted) { clearcutCommand += "--stdout "; } + else{ + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + clearcutCommand += "--out=" + outputName + " "; } + #else + clearcutCommand += "--out=\"" + outputName + "\" "; } + #endif if (DNA) { clearcutCommand += "--DNA "; } if (protein) { clearcutCommand += "--protein "; } if (jukes) { clearcutCommand += "--jukes "; } if (kimura) { clearcutCommand += "--kimura "; } - if (matrixout != "") { clearcutCommand += "--matrixout=" + matrixout + " "; } + if (matrixout != "") { clearcutCommand += "--matrixout=" + matrixout + " "; } if (ntrees != "1") { clearcutCommand += "--ntrees=" + ntrees + " "; } if (expblen) { clearcutCommand += "--expblen "; } if (expdist) { clearcutCommand += "--expdist "; } - + //run clearcut system(clearcutCommand.c_str()); - if (!stdout) { + if (!stdoutWanted) { m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); - m->mothurOut(outputName); m->mothurOutEndLine(); + m->mothurOut(outputName); m->mothurOutEndLine(); + if (matrixout != "") { m->mothurOut(matrixout); m->mothurOutEndLine(); } m->mothurOutEndLine(); } @@ -233,3 +240,7 @@ int ClearcutCommand::execute() { } } /**************************************************************************************/ + + + +