else {
//valid paramters for this command
- string Array[] = {"groups","iters","distance","random"};
+ string Array[] = {"groups","iters","distance","random", "outputdir","inputdir"};
vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
OptionParser parser(option);
if (globaldata->gTree.size() == 0) {//no trees were read
mothurOut("You must execute the read.tree command, before you may execute the unifrac.unweighted command."); 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 = "";
+ outputDir += hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it
+ }
+
//check for optional parameter and set defaults
// ...at some point should added some additional type checking...
groups = validParameter.validFile(parameters, "groups", false);
if (abort == false) {
T = globaldata->gTree;
tmap = globaldata->gTreemap;
- sumFile = globaldata->getTreeFile() + ".uwsummary";
+ sumFile = outputDir + getSimpleName(globaldata->getTreeFile()) + ".uwsummary";
openOutputFile(sumFile, outSum);
util = new SharedUtil();
for (int i = 0; i < T.size(); i++) {
counter = 0;
- if (random) { output = new ColumnFile(globaldata->getTreeFile() + toString(i+1) + ".unweighted", itersString); }
+ if (random) { output = new ColumnFile(outputDir + getSimpleName(globaldata->getTreeFile()) + toString(i+1) + ".unweighted", itersString); }
//get unweighted for users tree
rscoreFreq.resize(numComp);
/***********************************************************/
void UnifracUnweightedCommand::createPhylipFile(int i) {
try {
- string phylipFileName = globaldata->getTreeFile() + toString(i+1) + ".unweighted.dist";
+ string phylipFileName = outputDir + getSimpleName(globaldata->getTreeFile()) + toString(i+1) + ".unweighted.dist";
ofstream out;
openOutputFile(phylipFileName, out);