X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=chopseqscommand.cpp;h=05037f6817a5a554a029a7d635460d048bf73203;hb=5a4ac4f954c4b4445bcee272f1f8220ddcc9c1e4;hp=abfd8dc239b185a69e86e7641a8505761ff9766e;hpb=7f0cae4f4853cc3f12bc751ee06ea31c7c97496e;p=mothur.git diff --git a/chopseqscommand.cpp b/chopseqscommand.cpp index abfd8dc..05037f6 100644 --- a/chopseqscommand.cpp +++ b/chopseqscommand.cpp @@ -51,7 +51,27 @@ string ChopSeqsCommand::getHelpString(){ exit(1); } } - +//********************************************************************************************************************** +string ChopSeqsCommand::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 = "chop.fasta"; } + else if (type == "accnos") { outputFileName = "chop.accnos"; } + 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, "ChopSeqsCommand", "getOutputFileNameTag"); + exit(1); + } +} //********************************************************************************************************************** ChopSeqsCommand::ChopSeqsCommand(){ try { @@ -121,7 +141,7 @@ ChopSeqsCommand::ChopSeqsCommand(string option) { outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){ outputDir = m->hasPath(fastafile); } string temp = validParameter.validFile(parameters, "numbases", false); if (temp == "not found") { temp = "0"; } - convert(temp, numbases); + m->mothurConvert(temp, numbases); temp = validParameter.validFile(parameters, "countgaps", false); if (temp == "not found") { temp = "f"; } countGaps = m->isTrue(temp); @@ -147,8 +167,8 @@ int ChopSeqsCommand::execute(){ if (abort == true) { if (calledHelp) { return 0; } return 2; } - string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "chop.fasta"; - string outputFileNameAccnos = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "chop.accnos"; + string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("fasta"); + string outputFileNameAccnos = outputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("accnos"); ofstream out; m->openOutputFile(outputFileName, out); @@ -233,7 +253,7 @@ string ChopSeqsCommand::getChopped(Sequence seq) { for (int i = 0; i < temp.length(); i++) { //eliminate N's - if (toupper(temp[i]) == 'N') { temp[i] == '.'; } + if (toupper(temp[i]) == 'N') { temp[i] = '.'; } numBasesCounted++; @@ -255,7 +275,7 @@ string ChopSeqsCommand::getChopped(Sequence seq) { for (int i = (temp.length()-1); i >= 0; i--) { //eliminate N's - if (toupper(temp[i]) == 'N') { temp[i] == '.'; } + if (toupper(temp[i]) == 'N') { temp[i] = '.'; } numBasesCounted++; @@ -283,7 +303,7 @@ string ChopSeqsCommand::getChopped(Sequence seq) { for (int i = 0; i < temp.length(); i++) { //eliminate N's if (toupper(temp[i]) == 'N') { - temp[i] == '.'; + temp[i] = '.'; tempLength--; if (tempLength < numbases) { stopSpot = 0; break; } } @@ -309,7 +329,7 @@ string ChopSeqsCommand::getChopped(Sequence seq) { for (int i = (temp.length()-1); i >= 0; i--) { //eliminate N's if (toupper(temp[i]) == 'N') { - temp[i] == '.'; + temp[i] = '.'; tempLength--; if (tempLength < numbases) { stopSpot = 0; break; } }