X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=parsefastaqcommand.cpp;h=1331b7f47f4e131cb5a76913889d275b7ec93121;hb=c7e8c2d15bd7cedcfdf18675cb0ea1a0dcd0e3c0;hp=9509a20af2528392c2df8590aea61fef6a7665b4;hpb=16abd6271c455bd01b34ff89a2e3641bef0fa128;p=mothur.git diff --git a/parsefastaqcommand.cpp b/parsefastaqcommand.cpp index 9509a20..1331b7f 100644 --- a/parsefastaqcommand.cpp +++ b/parsefastaqcommand.cpp @@ -33,8 +33,10 @@ string ParseFastaQCommand::getHelpString(){ try { string helpString = ""; helpString += "The fastq.info command reads a fastq file and creates a fasta and quality file.\n"; - helpString += "The fastq.info command parameter is fastq, and it is required.\n"; + helpString += "The fastq.info command parameters are fastq, fasta and qfile; fastq is required.\n"; helpString += "The fastq.info command should be in the following format: fastq.info(fastaq=yourFastaQFile).\n"; + helpString += "The fasta parameter allows you to indicate whether you want a fasta file generated. Default=T.\n"; + helpString += "The qfile parameter allows you to indicate whether you want a quality file generated. Default=T.\n"; helpString += "Example fastq.info(fastaq=test.fastaq).\n"; helpString += "Note: No spaces between parameter labels (i.e. fastq), '=' and yourFastQFile.\n"; return helpString; @@ -44,6 +46,28 @@ string ParseFastaQCommand::getHelpString(){ exit(1); } } +//********************************************************************************************************************** +string ParseFastaQCommand::getOutputFileNameTag(string type, string inputName=""){ + try { + string outputFileName = ""; + map >::iterator it; + + //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); + } +} + //********************************************************************************************************************** ParseFastaQCommand::ParseFastaQCommand(){ try { @@ -130,8 +154,8 @@ int ParseFastaQCommand::execute(){ if (abort == true) { if (calledHelp) { return 0; } return 2; } //open Output Files - string fastaFile = outputDir + m->getRootName(m->getSimpleName(fastaQFile)) + "fasta"; - string qualFile = outputDir + m->getRootName(m->getSimpleName(fastaQFile)) + "qual"; + string fastaFile = outputDir + m->getRootName(m->getSimpleName(fastaQFile)) + getOutputFileNameTag("fasta"); + string qualFile = outputDir + m->getRootName(m->getSimpleName(fastaQFile)) + getOutputFileNameTag("qfile"); ofstream outFasta, outQual; if (fasta) { m->openOutputFile(fastaFile, outFasta); outputNames.push_back(fastaFile); outputTypes["fasta"].push_back(fastaFile); } @@ -166,7 +190,7 @@ int ParseFastaQCommand::execute(){ //sanity check sequence length and number of quality scores match if (name2 != "") { if (name != name2) { m->mothurOut("[ERROR]: names do not match. read " + name + " for fasta and " + name2 + " for quality."); m->mothurOutEndLine(); m->control_pressed = true; break; } } - if (quality.length() != sequence.length()) { m->mothurOut("[ERROR]: lengths do not match. read " + toString(sequence.length()) + " characters for fasta and " + toString(quality.length()) + " characters for quality scores."); m->mothurOutEndLine(); m->control_pressed = true; break; } + if (quality.length() != sequence.length()) { m->mothurOut("[ERROR]: Lengths do not match for sequence " + name + ". Read " + toString(sequence.length()) + " characters for fasta and " + toString(quality.length()) + " characters for quality scores."); m->mothurOutEndLine(); m->control_pressed = true; break; } //print sequence info to files if (fasta) { outFasta << ">" << name << endl << sequence << endl; } @@ -214,7 +238,7 @@ vector ParseFastaQCommand::convertQual(string qual) { try { vector qualScores; - int controlChar = int('!'); + int controlChar = int('@'); for (int i = 0; i < qual.length(); i++) { int temp = int(qual[i]);