X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=deuniqueseqscommand.cpp;h=918079cfe45aa2fbe6f14b155a6edd494e555c1d;hb=e8e13c129ba8184ec5932a090773f353f3ae3406;hp=2ba6f3d2363d86cc49108e2cb3db71fddd1ae879;hpb=220dc345e493cddc569521111ce32ac4d965ab7f;p=mothur.git diff --git a/deuniqueseqscommand.cpp b/deuniqueseqscommand.cpp index 2ba6f3d..918079c 100644 --- a/deuniqueseqscommand.cpp +++ b/deuniqueseqscommand.cpp @@ -45,6 +45,26 @@ string DeUniqueSeqsCommand::getHelpString(){ } } //********************************************************************************************************************** +string DeUniqueSeqsCommand::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 = "redundant.fasta"; } + 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, "DeUniqueSeqsCommand", "getOutputFileNameTag"); + exit(1); + } +} +//********************************************************************************************************************** DeUniqueSeqsCommand::DeUniqueSeqsCommand(){ try { abort = true; calledHelp = true; @@ -148,21 +168,21 @@ int DeUniqueSeqsCommand::execute() { string outFastaFile = m->getRootName(m->getSimpleName(fastaFile)); int pos = outFastaFile.find("unique"); if (pos != string::npos) { - outFastaFile = outputDir + outFastaFile.substr(0, pos) + "redundant" + m->getExtension(fastaFile); + outFastaFile = outputDir + outFastaFile.substr(0, pos) + getOutputFileNameTag("fasta"); }else{ - outFastaFile = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + "redundant" + m->getExtension(fastaFile); + outFastaFile = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + getOutputFileNameTag("fasta"); } m->openOutputFile(outFastaFile, out); readNamesFile(); - if (m->control_pressed) { out.close(); outputTypes.clear(); remove(outFastaFile.c_str()); return 0; } + if (m->control_pressed) { out.close(); outputTypes.clear(); m->mothurRemove(outFastaFile); return 0; } ifstream in; m->openInputFile(fastaFile, in); while (!in.eof()) { - if (m->control_pressed) { in.close(); out.close(); outputTypes.clear(); remove(outFastaFile.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); outputTypes.clear(); m->mothurRemove(outFastaFile); return 0; } Sequence seq(in); m->gobble(in); @@ -196,7 +216,7 @@ int DeUniqueSeqsCommand::execute() { } } - if (m->control_pressed) { outputTypes.clear(); remove(outFastaFile.c_str()); return 0; } + if (m->control_pressed) { outputTypes.clear(); m->mothurRemove(outFastaFile); return 0; } m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine();