X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=splitabundcommand.cpp;h=d0f925eb0ae26d98cd5f8098eca3ade34fc9e5d4;hb=4169642e8a8d45f71a4a7241ee02f1b1aae29520;hp=fb0326a479efbc64d09bf946316355ce8dc44bac;hpb=191ae1be0679d5cf4eda950b3b1bf26fb7dd503d;p=mothur.git diff --git a/splitabundcommand.cpp b/splitabundcommand.cpp index fb0326a..d0f925e 100644 --- a/splitabundcommand.cpp +++ b/splitabundcommand.cpp @@ -24,8 +24,7 @@ vector SplitAbundCommand::getValidParameters(){ //********************************************************************************************************************** SplitAbundCommand::SplitAbundCommand(){ try { - abort = true; - //initialize outputTypes + abort = true; calledHelp = true; vector tempOutNames; outputTypes["list"] = tempOutNames; outputTypes["name"] = tempOutNames; @@ -64,11 +63,11 @@ vector SplitAbundCommand::getRequiredFiles(){ //********************************************************************************************************************** SplitAbundCommand::SplitAbundCommand(string option) { try { - abort = false; + abort = false; calledHelp = false; allLines = 1; //allow user to run help - if(option == "help") { help(); abort = true; } + if(option == "help") { help(); abort = true; calledHelp = true; } else { //valid paramters for this command @@ -233,32 +232,10 @@ SplitAbundCommand::~SplitAbundCommand(){ int SplitAbundCommand::execute(){ try { - if (abort == true) { return 0; } + if (abort == true) { if (calledHelp) { return 0; } return 2; } if (listfile != "") { //you are using a listfile to determine abundance if (outputDir == "") { outputDir = m->hasPath(listfile); } - - //remove old files so you can append later.... - string fileroot = outputDir + m->getRootName(m->getSimpleName(listfile)); - if (Groups.size() == 0) { - remove((fileroot + "rare.list").c_str()); - remove((fileroot + "abund.list").c_str()); - - outputNames.push_back((fileroot + "rare.list")); - outputNames.push_back((fileroot + "abund.list")); - outputTypes["list"].push_back((fileroot + "rare.list")); - outputTypes["list"].push_back((fileroot + "abund.list")); - }else{ - for (int i=0; i processedLabels; @@ -354,7 +331,7 @@ int SplitAbundCommand::execute(){ if (accnos) { writeAccnos(tag); } if (fastafile != "") { parseFasta(tag); } } - + m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } @@ -390,9 +367,11 @@ int SplitAbundCommand::splitList(ListVector* thisList) { } }//end for - writeList(thisList); string tag = thisList->getLabel() + "."; + + writeList(thisList, tag); + if (groupfile != "") { parseGroup(tag); } if (accnos) { writeAccnos(tag); } if (fastafile != "") { parseFasta(tag); } @@ -406,7 +385,7 @@ int SplitAbundCommand::splitList(ListVector* thisList) { } } /**********************************************************************************************************************/ -int SplitAbundCommand::writeList(ListVector* thisList) { +int SplitAbundCommand::writeList(ListVector* thisList, string tag) { try { map filehandles; @@ -428,13 +407,13 @@ int SplitAbundCommand::writeList(ListVector* thisList) { ofstream aout; ofstream rout; - string rare = outputDir + m->getRootName(m->getSimpleName(listfile)) + "rare.list"; - m->openOutputFileAppend(rare, rout); - //outputNames.push_back(rare); + string rare = outputDir + m->getRootName(m->getSimpleName(listfile)) + tag + "rare.list"; + m->openOutputFile(rare, rout); + outputNames.push_back(rare); outputTypes["list"].push_back(rare); - string abund = outputDir + m->getRootName(m->getSimpleName(listfile)) + "abund.list"; - m->openOutputFileAppend(abund, aout); - //outputNames.push_back(abund); + string abund = outputDir + m->getRootName(m->getSimpleName(listfile)) + tag + "abund.list"; + m->openOutputFile(abund, aout); + outputNames.push_back(abund); outputTypes["list"].push_back(abund); if (rareNames.size() != 0) { rout << thisList->getLabel() << '\t' << numRareBins << '\t'; } if (abundNames.size() != 0) { aout << thisList->getLabel() << '\t' << numAbundBins << '\t'; } @@ -470,8 +449,10 @@ int SplitAbundCommand::writeList(ListVector* thisList) { temp2 = new ofstream; filehandles[Groups[i]+".abund"] = temp2; - m->openOutputFileAppend(fileroot + Groups[i] + ".rare.list", *(filehandles[Groups[i]+".rare"])); - m->openOutputFileAppend(fileroot + Groups[i] + ".abund.list", *(filehandles[Groups[i]+".abund"])); + m->openOutputFile(fileroot + Groups[i] + tag + ".rare.list", *(filehandles[Groups[i]+".rare"])); + m->openOutputFile(fileroot + Groups[i] + tag + ".abund.list", *(filehandles[Groups[i]+".abund"])); + outputNames.push_back(fileroot + Groups[i] + tag + ".rare.list"); outputTypes["list"].push_back(fileroot + Groups[i] + tag + ".rare.list"); + outputNames.push_back(fileroot + Groups[i] + tag + ".abund.list"); outputTypes["list"].push_back(fileroot + Groups[i] + tag + ".abund.list"); } map groupVector;