exit(1);
}
}
-
+//**********************************************************************************************************************
+string ReverseSeqsCommand::getOutputFileNameTag(string type, string inputName=""){
+ try {
+ string outputFileName = "";
+ map<string, vector<string> >::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 = "rc" + m->getExtension(inputName); }
+ else if (type == "qfile") { outputFileName = "rc" + m->getExtension(inputName); }
+ 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, "ReverseSeqsCommand", "getOutputFileNameTag");
+ exit(1);
+ }
+}
//**********************************************************************************************************************
ReverseSeqsCommand::ReverseSeqsCommand(){
try {
fastaFileName = validParameter.validFile(parameters, "fasta", true);
if (fastaFileName == "not open") { abort = true; }
else if (fastaFileName == "not found") { fastaFileName = "";}// m->mothurOut("fasta is a required parameter for the reverse.seqs command."); m->mothurOutEndLine(); abort = true; }
+ else { m->setFastaFile(fastaFileName); }
qualFileName = validParameter.validFile(parameters, "qfile", true);
if (qualFileName == "not open") { abort = true; }
else if (qualFileName == "not found") { qualFileName = ""; }//m->mothurOut("fasta is a required parameter for the reverse.seqs command."); m->mothurOutEndLine(); abort = true; }
-
+ else { m->setQualFile(qualFileName); }
+
if((fastaFileName == "") && (qualFileName == "")){
fastaFileName = m->getFastaFile();
if (fastaFileName != "") { m->mothurOut("Using " + fastaFileName + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
ofstream outFASTA;
string tempOutputDir = outputDir;
if (outputDir == "") { tempOutputDir += m->hasPath(fastaFileName); } //if user entered a file with a path then preserve it
- fastaReverseFileName = tempOutputDir + m->getRootName(m->getSimpleName(fastaFileName)) + "rc" + m->getExtension(fastaFileName);
+ fastaReverseFileName = tempOutputDir + m->getRootName(m->getSimpleName(fastaFileName)) + getOutputFileNameTag("fasta", fastaFileName);
m->openOutputFile(fastaReverseFileName, outFASTA);
while(!inFASTA.eof()){
- if (m->control_pressed) { inFASTA.close(); outFASTA.close(); remove(fastaReverseFileName.c_str()); return 0; }
+ if (m->control_pressed) { inFASTA.close(); outFASTA.close(); m->mothurRemove(fastaReverseFileName); return 0; }
Sequence currSeq(inFASTA); m->gobble(inFASTA);
if (currSeq.getName() != "") {
ofstream outQual;
string tempOutputDir = outputDir;
if (outputDir == "") { tempOutputDir += m->hasPath(qualFileName); } //if user entered a file with a path then preserve it
- string qualReverseFileName = tempOutputDir + m->getRootName(m->getSimpleName(qualFileName)) + "rc" + m->getExtension(qualFileName);
- m->openOutputFile(qualReverseFileName, outQual);
+ string qualReverseFileName = tempOutputDir + m->getRootName(m->getSimpleName(qualFileName)) + getOutputFileNameTag("qfile", qualFileName);
+ m->openOutputFile(qualReverseFileName, outQual);
while(!inQual.eof()){
- if (m->control_pressed) { inQual.close(); outQual.close(); remove(qualReverseFileName.c_str()); return 0; }
+ if (m->control_pressed) { inQual.close(); outQual.close(); m->mothurRemove(qualReverseFileName); return 0; }
currQual = QualityScores(inQual); m->gobble(inQual);
currQual.flipQScores();
currQual.printQScores(outQual);
outputNames.push_back(qualReverseFileName); outputTypes["qfile"].push_back(qualReverseFileName);
}
- if (m->control_pressed) { remove(qualReverseFileName.c_str()); remove(fastaReverseFileName.c_str()); return 0; }
+ if (m->control_pressed) { m->mothurRemove(qualReverseFileName); m->mothurRemove(fastaReverseFileName); return 0; }
//set fasta file as new current fastafile
string current = "";