X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=shhhseqscommand.cpp;h=82d956189a6f025fd57dc7e901e585456f59f8ab;hp=5c6359ec58bb776ce9a050a132e8409e60cf197b;hb=050a3ff02473a3d4c0980964e1a9ebe52e55d6b8;hpb=91a27e0483827c06c21c4fe89558923bbfe86573 diff --git a/shhhseqscommand.cpp b/shhhseqscommand.cpp index 5c6359e..82d9561 100644 --- a/shhhseqscommand.cpp +++ b/shhhseqscommand.cpp @@ -14,13 +14,13 @@ //********************************************************************************************************************** vector ShhhSeqsCommand::setParameters(){ try { - CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta); - CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pname); - CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pgroup); - 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 psigma("sigma", "Number", "", "0.01", "", "", "",false,false); parameters.push_back(psigma); + CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","fasta-map",false,true,true); parameters.push_back(pfasta); + CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none","name",false,true,true); parameters.push_back(pname); + CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(pgroup); + 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 psigma("sigma", "Number", "", "0.01", "", "", "","",false,false); parameters.push_back(psigma); vector myArray; for (int i = 0; i < parameters.size(); i++) { myArray.push_back(parameters[i].name); } @@ -54,6 +54,24 @@ string ShhhSeqsCommand::getHelpString(){ exit(1); } } +//********************************************************************************************************************** +string ShhhSeqsCommand::getOutputPattern(string type) { + try { + string pattern = ""; + + if (type == "fasta") { pattern = "[filename],shhh_seqs.fasta"; } + else if (type == "name") { pattern = "[filename],shhh_seqs.names"; } + else if (type == "map") { pattern = "[filename],shhh_seqs.map"; } + else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true; } + + return pattern; + } + catch(exception& e) { + m->errorOut(e, "ShhhSeqsCommand", "getOutputPattern"); + exit(1); + } +} + //********************************************************************************************************************** ShhhSeqsCommand::ShhhSeqsCommand(){ @@ -184,10 +202,13 @@ int ShhhSeqsCommand::execute() { if (abort == true) { if (calledHelp) { return 0; } return 2; } - if (outputDir == "") { outputDir = m->hasPath(fastafile); }//if user entered a file with a path then preserve it - string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "shhh.fasta"; - string nameFileName = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "shhh.names"; - string mapFileName = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "shhh.map"; + if (outputDir == "") { outputDir = m->hasPath(fastafile); }//if user entered a file with a path then preserve it + + map variables; + variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(fastafile)); + string outputFileName = getOutputFileName("fasta",variables); + string nameFileName = getOutputFileName("name",variables); + string mapFileName = getOutputFileName("map",variables); if (groupfile != "") { //Parse sequences by group @@ -453,6 +474,9 @@ vector ShhhSeqsCommand::createProcessesGroups(SequenceParser& parser, st //Close all thread handles and free memory allocations. for(int i=0; i < pDataArray.size(); i++){ + if (pDataArray[i]->count != (pDataArray[i]->end-pDataArray[i]->start)) { + m->mothurOut("[ERROR]: process " + toString(i) + " only processed " + toString(pDataArray[i]->count) + " of " + toString(pDataArray[i]->end-pDataArray[i]->start) + " groups assigned to it, quitting. \n"); m->control_pressed = true; + } for (int j = 0; j < pDataArray[i]->mapfileNames.size(); j++) { mapfileNames.push_back(pDataArray[i]->mapfileNames[j]); }