X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=parsefastaqcommand.cpp;h=63ed3144ad2a2b86ed33c6f9449b8d8143d38204;hb=af9291809910b6ddf617490ed5c16254b77b449f;hp=ba23ae3253eed3c9ef3f5cbd8dc0b927348875a6;hpb=79a7d3273749b08d4f9f8dfe350c964ff0c4351e;p=mothur.git diff --git a/parsefastaqcommand.cpp b/parsefastaqcommand.cpp index ba23ae3..63ed314 100644 --- a/parsefastaqcommand.cpp +++ b/parsefastaqcommand.cpp @@ -13,12 +13,12 @@ //********************************************************************************************************************** vector ParseFastaQCommand::setParameters(){ try { - CommandParameter pfastq("fastq", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfastq); - CommandParameter pfasta("fasta", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pfasta); - CommandParameter pqual("qfile", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pqual); - CommandParameter pformat("format", "Multiple", "sanger-illumina-solexa", "sanger", "", "", "",false,false); parameters.push_back(pformat); - CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir); - CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir); + CommandParameter pfastq("fastq", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(pfastq); + CommandParameter pfasta("fasta", "Boolean", "", "T", "", "", "","fasta",false,false); parameters.push_back(pfasta); + CommandParameter pqual("qfile", "Boolean", "", "T", "", "", "","qfile",false,false); parameters.push_back(pqual); + CommandParameter pformat("format", "Multiple", "sanger-illumina-solexa", "sanger", "", "", "","",false,false,true); parameters.push_back(pformat); + 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); } @@ -49,27 +49,21 @@ string ParseFastaQCommand::getHelpString(){ } } //********************************************************************************************************************** -string ParseFastaQCommand::getOutputFileNameTag(string type, string inputName=""){ - try { - string outputFileName = ""; - map >::iterator it; +string ParseFastaQCommand::getOutputPattern(string type) { + try { + string pattern = ""; - //is this a type this command creates - it = outputTypes.find(type); - if (it == outputTypes.end()) { m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); } - else { - if (type == "fasta") { outputFileName = "fasta"; } - else if (type == "qfile") { outputFileName = "qual"; } - else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true; } - } - return outputFileName; - } - catch(exception& e) { - m->errorOut(e, "ParseFastaQCommand", "getOutputFileNameTag"); - exit(1); - } + if (type == "fasta") { pattern = "[filename],fasta"; } + else if (type == "qfile") { pattern = "[filename],qual"; } + else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true; } + + return pattern; + } + catch(exception& e) { + m->errorOut(e, "ParseFastaQCommand", "getOutputPattern"); + exit(1); + } } - //********************************************************************************************************************** ParseFastaQCommand::ParseFastaQCommand(){ try { @@ -163,8 +157,10 @@ int ParseFastaQCommand::execute(){ if (abort == true) { if (calledHelp) { return 0; } return 2; } //open Output Files - string fastaFile = outputDir + m->getRootName(m->getSimpleName(fastaQFile)) + getOutputFileNameTag("fasta"); - string qualFile = outputDir + m->getRootName(m->getSimpleName(fastaQFile)) + getOutputFileNameTag("qfile"); + map variables; + variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(fastaQFile)); + string fastaFile = getOutputFileName("fasta",variables); + string qualFile = getOutputFileName("qfile",variables); ofstream outFasta, outQual; if (fasta) { m->openOutputFile(fastaFile, outFasta); outputNames.push_back(fastaFile); outputTypes["fasta"].push_back(fastaFile); } @@ -261,9 +257,9 @@ vector ParseFastaQCommand::convertQual(string qual) { temp -= 64; //char '@' }else if (format == "solexa") { temp = int(convertTable[temp]); //convert to sanger - temp -= 33; //char '!' + temp -= int('!'); //char '!' }else { - temp -= 33; //char '!' + temp -= int('!'); //char '!' } qualScores.push_back(temp); }