X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=mergefilecommand.cpp;h=643cf287bb9aded0847390aeea1091c12e95dd74;hp=cece52d9cd06b78950f5b197c19d2e9574b7daa8;hb=615301e57c25e241356a9c2380648d117709458d;hpb=1d898dc6edaf9e9f287fab53bf1f21fb29757a17 diff --git a/mergefilecommand.cpp b/mergefilecommand.cpp index cece52d..643cf28 100644 --- a/mergefilecommand.cpp +++ b/mergefilecommand.cpp @@ -12,10 +12,10 @@ //********************************************************************************************************************** vector MergeFileCommand::setParameters(){ try { - CommandParameter pinput("input", "String", "", "", "", "", "",false,true); parameters.push_back(pinput); - CommandParameter poutput("output", "String", "", "", "", "", "",false,true); parameters.push_back(poutput); - CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir); - CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir); + CommandParameter pinput("input", "String", "", "", "", "", "","",false,true,true); parameters.push_back(pinput); + CommandParameter poutput("output", "String", "", "", "", "", "","",false,true,true); parameters.push_back(poutput); + CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir); + CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir); vector myArray; for (int i = 0; i < parameters.size(); i++) { myArray.push_back(parameters[i].name); } @@ -41,7 +41,6 @@ string MergeFileCommand::getHelpString(){ exit(1); } } - //********************************************************************************************************************** MergeFileCommand::MergeFileCommand(){ try { @@ -64,7 +63,7 @@ MergeFileCommand::MergeFileCommand(string option) { if(option == "help") { help(); abort = true; calledHelp = true; - } + }else if(option == "citation") { citation(); abort = true; calledHelp = true;} else { vector myArray = setParameters(); @@ -130,32 +129,13 @@ int MergeFileCommand::execute(){ try { if (abort == true) { if (calledHelp) { return 0; } return 2; } - ofstream outputFile; - m->openOutputFile(outputFileName, outputFile); - - char c; - for(int i=0;iopenInputFile(fileNames[i], inputFile); - - while(!inputFile.eof()){ - if (m->control_pressed) { outputTypes.clear(); inputFile.close(); outputFile.close(); remove(outputFileName.c_str()); return 0; } - - c = inputFile.get(); - //-1 is eof char - if (int(c) != -1) { outputFile << c; } - } - - inputFile.close(); - } - - outputFile.close(); + m->mothurRemove(outputFileName); + for(int i=0;iappendFiles(fileNames[i], outputFileName); } - if (m->control_pressed) { outputTypes.clear(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { m->mothurRemove(outputFileName); return 0; } m->mothurOutEndLine(); - m->mothurOut("Output File Name: "); m->mothurOutEndLine(); + m->mothurOut("Output File Names: "); m->mothurOutEndLine(); m->mothurOut(outputFileName); m->mothurOutEndLine(); outputNames.push_back(outputFileName); outputTypes["merge"].push_back(outputFileName); m->mothurOutEndLine();