X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=chimeraccodecommand.cpp;h=d890db4087813cc3c4c4e453b55013fa555e7689;hp=af6e33a1254adc623948604100f8b9109e6c18e6;hb=cf9987b67aa49777a4c91c2d21f96e58bf17aa82;hpb=0ca63a8165baa0afa459e644ebe140ba496d5ba0 diff --git a/chimeraccodecommand.cpp b/chimeraccodecommand.cpp index af6e33a..d890db4 100644 --- a/chimeraccodecommand.cpp +++ b/chimeraccodecommand.cpp @@ -13,16 +13,16 @@ //********************************************************************************************************************** vector ChimeraCcodeCommand::setParameters(){ try { - CommandParameter ptemplate("reference", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptemplate); - CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta); - CommandParameter pfilter("filter", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pfilter); - CommandParameter pwindow("window", "Number", "", "0", "", "", "",false,false); parameters.push_back(pwindow); - CommandParameter pnumwanted("numwanted", "Number", "", "20", "", "", "",false,false); parameters.push_back(pnumwanted); - CommandParameter pmask("mask", "String", "", "", "", "", "",false,false); parameters.push_back(pmask); - CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors); - CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir); - CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir); - CommandParameter psave("save", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(psave); + CommandParameter ptemplate("reference", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(ptemplate); + CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","chimera-mapinfo-accnos",false,true,true); parameters.push_back(pfasta); + CommandParameter pfilter("filter", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pfilter); + CommandParameter pwindow("window", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pwindow); + CommandParameter pnumwanted("numwanted", "Number", "", "20", "", "", "","",false,false); parameters.push_back(pnumwanted); + CommandParameter pmask("mask", "String", "", "", "", "", "","",false,false); parameters.push_back(pmask); + CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors); + CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir); + CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir); + CommandParameter psave("save", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(psave); vector myArray; for (int i = 0; i < parameters.size(); i++) { myArray.push_back(parameters[i].name); } @@ -38,7 +38,7 @@ string ChimeraCcodeCommand::getHelpString(){ try { string helpString = ""; helpString += "The chimera.ccode command reads a fastafile and referencefile and outputs potentially chimeric sequences.\n"; - helpString += "This command was created using the algorythms described in the 'Evaluating putative chimeric sequences from PCR-amplified products' paper by Juan M. Gonzalez, Johannes Zimmerman and Cesareo Saiz-Jimenez.\n"; + helpString += "This command was created using the algorithms described in the 'Evaluating putative chimeric sequences from PCR-amplified products' paper by Juan M. Gonzalez, Johannes Zimmerman and Cesareo Saiz-Jimenez.\n"; helpString += "The chimera.ccode command parameters are fasta, reference, filter, mask, processors, window and numwanted.\n"; helpString += "The fasta parameter allows you to enter the fasta file containing your potentially chimeric sequences, and is required unless you have a valid current fasta file. \n"; helpString += "You may enter multiple fasta files by separating their names with dashes. ie. fasta=abrecovery.fasta-amzon.fasta \n"; @@ -64,6 +64,23 @@ string ChimeraCcodeCommand::getHelpString(){ } } //********************************************************************************************************************** +string ChimeraCcodeCommand::getOutputPattern(string type) { + try { + string pattern = ""; + + if (type == "chimera") { pattern = "[filename],[tag],ccode.chimeras-[filename],ccode.chimeras"; } + else if (type == "accnos") { pattern = "[filename],[tag],ccode.accnos-[filename],ccode.accnos"; } + else if (type == "mapinfo") { pattern = "[filename],mapinfo"; } + else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true; } + + return pattern; + } + catch(exception& e) { + m->errorOut(e, "ChimeraCcodeCommand", "getOutputPattern"); + exit(1); + } +} +//********************************************************************************************************************** ChimeraCcodeCommand::ChimeraCcodeCommand(){ try { abort = true; calledHelp = true; @@ -72,6 +89,7 @@ ChimeraCcodeCommand::ChimeraCcodeCommand(){ outputTypes["chimera"] = tempOutNames; outputTypes["mapinfo"] = tempOutNames; outputTypes["accnos"] = tempOutNames; + } catch(exception& e) { m->errorOut(e, "ChimeraCcodeCommand", "ChimeraCcodeCommand"); @@ -106,6 +124,7 @@ ChimeraCcodeCommand::ChimeraCcodeCommand(string option) { outputTypes["chimera"] = tempOutNames; outputTypes["mapinfo"] = tempOutNames; outputTypes["accnos"] = tempOutNames; + //if the user changes the input directory command factory will send this info to us in the output parameter string inputDir = validParameter.validFile(parameters, "inputdir", false); @@ -283,16 +302,13 @@ int ChimeraCcodeCommand::execute(){ if (outputDir == "") { outputDir = m->hasPath(fastaFileNames[s]); }//if user entered a file with a path then preserve it string outputFileName, accnosFileName; - if (maskfile != "") { - outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + maskfile + ".ccode.chimeras"; - accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + maskfile + ".ccode.accnos"; - }else { - outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "ccode.chimeras"; - accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "ccode.accnos"; - } - - string mapInfo = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "mapinfo"; - + map variables; + variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])); + string mapInfo = getOutputFileName("mapinfo", variables); + if (maskfile != "") { variables["[tag]"] = maskfile; } + outputFileName = getOutputFileName("chimera", variables); + accnosFileName = getOutputFileName("accnos", variables); + if (m->control_pressed) { delete chimera; for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } outputTypes.clear(); return 0; } #ifdef USE_MPI @@ -393,7 +409,7 @@ int ChimeraCcodeCommand::execute(){ //break up file - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) vector positions = m->divideFile(fastaFileNames[s], processors); for (int i = 0; i < (positions.size()-1); i++) { @@ -524,7 +540,7 @@ int ChimeraCcodeCommand::driver(linePair* filePos, string outputFName, string fi } delete candidateSeq; - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) unsigned long long pos = inFASTA.tellg(); if ((pos == -1) || (pos >= filePos->end)) { break; } #else @@ -532,10 +548,10 @@ int ChimeraCcodeCommand::driver(linePair* filePos, string outputFName, string fi #endif //report progress - if((count) % 100 == 0){ m->mothurOut("Processing sequence: " + toString(count)); m->mothurOutEndLine(); } + if((count) % 100 == 0){ m->mothurOutJustToScreen("Processing sequence: " + toString(count) + "\n"); } } //report progress - if((count) % 100 != 0){ m->mothurOut("Processing sequence: " + toString(count)); m->mothurOutEndLine(); } + if((count) % 100 != 0){ m->mothurOutJustToScreen("Processing sequence: " + toString(count) + "\n"); } out.close(); out2.close(); @@ -611,7 +627,7 @@ int ChimeraCcodeCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File int ChimeraCcodeCommand::createProcesses(string outputFileName, string filename, string accnos) { try { -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) int process = 0; int num = 0;