X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=parsefastaqcommand.cpp;h=051c1dfb057c0148c3f0053f94707b7e6d034dc0;hb=a0f1fca79d2ddfa7ad36b4485039c68b5704fe8d;hp=89f97acf13ad45650a1f8294a3e88895beaa347c;hpb=c85db0a4be3a1f8037a71a23ca73f9762184e28a;p=mothur.git diff --git a/parsefastaqcommand.cpp b/parsefastaqcommand.cpp index 89f97ac..051c1df 100644 --- a/parsefastaqcommand.cpp +++ b/parsefastaqcommand.cpp @@ -16,6 +16,7 @@ vector ParseFastaQCommand::setParameters(){ 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 ppacbio("pacbio", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(ppacbio); CommandParameter pformat("format", "Multiple", "sanger-illumina-solexa-illumina1.8+", "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); @@ -39,6 +40,7 @@ string ParseFastaQCommand::getHelpString(){ helpString += "The format parameter is used to indicate whether your sequences are sanger, solexa, illumina1.8+ or illumina, default=sanger.\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 += "The pacbio parameter allows you to indicate .... When set to true, quality scores of 0 will results in a corresponding base of N. Default=F.\n"; helpString += "Example fastq.info(fastaq=test.fastaq).\n"; helpString += "Note: No spaces between parameter labels (i.e. fastq), '=' and yourFastQFile.\n"; return helpString; @@ -132,7 +134,11 @@ ParseFastaQCommand::ParseFastaQCommand(string option){ fasta = m->isTrue(temp); temp = validParameter.validFile(parameters, "qfile", false); if(temp == "not found"){ temp = "T"; } - qual = m->isTrue(temp); + qual = m->isTrue(temp); + + temp = validParameter.validFile(parameters, "pacbio", false); if(temp == "not found"){ temp = "F"; } + pacbio = m->isTrue(temp); + format = validParameter.validFile(parameters, "format", false); if (format == "not found"){ format = "sanger"; } @@ -183,7 +189,10 @@ int ParseFastaQCommand::execute(){ string name = m->getline(in); m->gobble(in); if (name == "") { m->mothurOut("[ERROR]: Blank fasta name."); m->mothurOutEndLine(); m->control_pressed = true; break; } else if (name[0] != '@') { m->mothurOut("[ERROR]: reading " + name + " expected a name with @ as a leading character."); m->mothurOutEndLine(); m->control_pressed = true; break; } - else { name = name.substr(1); } + else { + name = name.substr(1); + m->checkName(name); + } //read sequence string sequence = m->getline(in); m->gobble(in); @@ -193,7 +202,10 @@ int ParseFastaQCommand::execute(){ string name2 = m->getline(in); m->gobble(in); if (name2 == "") { m->mothurOut("[ERROR]: Blank quality name."); m->mothurOutEndLine(); m->control_pressed = true; break; } else if (name2[0] != '+') { m->mothurOut("[ERROR]: reading " + name2 + " expected a name with + as a leading character."); m->mothurOutEndLine(); m->control_pressed = true; break; } - else { name2 = name2.substr(1); } + else { + name2 = name2.substr(1); + m->checkName(name2); + } //read quality scores string quality = m->getline(in); m->gobble(in); @@ -203,22 +215,33 @@ int ParseFastaQCommand::execute(){ 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 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; } - - if (qual) { - vector qualScores = convertQual(quality); + vector qualScores; + if (qual) { + qualScores = convertQual(quality); outQual << ">" << name << endl; for (int i = 0; i < qualScores.size(); i++) { outQual << qualScores[i] << " "; } outQual << endl; } + + if (m->control_pressed) { break; } + + if (pacbio) { + if (!qual) { qualScores = convertQual(quality); } //get scores if we didn't already + for (int i = 0; i < qualScores.size(); i++) { + if (qualScores[i] == 0){ sequence[i] = 'N'; } + } + } + + //print sequence info to files + if (fasta) { outFasta << ">" << name << endl << sequence << endl; } + } in.close(); if (fasta) { outFasta.close(); } if (qual) { outQual.close(); } - if (m->control_pressed) { outputTypes.clear(); m->mothurRemove(fastaFile); m->mothurRemove(qualFile); return 0; } + if (m->control_pressed) { outputTypes.clear(); outputNames.clear(); m->mothurRemove(fastaFile); m->mothurRemove(qualFile); return 0; } //set fasta file as new current fastafile string current = "";