#include "seqerrorcommand.h"
+//**********************************************************************************************************************
+vector<string> SeqErrorCommand::getValidParameters(){
+ try {
+ string Array[] = {"query", "reference", "name", "threshold", "inputdir", "outputdir"};
+ vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+ return myArray;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "SeqErrorCommand", "getValidParameters");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+SeqErrorCommand::SeqErrorCommand(){
+ try {
+ abort = true;
+ //initialize outputTypes
+ vector<string> tempOutNames;
+ outputTypes["error"] = tempOutNames;
+ outputTypes["count"] = tempOutNames;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "SeqErrorCommand", "SeqErrorCommand");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+vector<string> SeqErrorCommand::getRequiredParameters(){
+ try {
+ string Array[] = {"query","reference"};
+ vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+ return myArray;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "SeqErrorCommand", "getRequiredParameters");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+vector<string> SeqErrorCommand::getRequiredFiles(){
+ try {
+ vector<string> myArray;
+ return myArray;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "SeqErrorCommand", "getRequiredFiles");
+ exit(1);
+ }
+}
//***************************************************************************************************************
SeqErrorCommand::SeqErrorCommand(string option) {
string temp;
//valid paramters for this command
- string AlignArray[] = {"query", "reference", "name", "threshold"};
+ string AlignArray[] = {"query", "reference", "name", "threshold", "inputdir", "outputdir"};
//need to implement name file option
if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; }
}
+ //initialize outputTypes
+ vector<string> tempOutNames;
+ outputTypes["error"] = tempOutNames;
+ outputTypes["count"] = tempOutNames;
+
//if the user changes the input directory command factory will send this info to us in the output parameter
string inputDir = validParameter.validFile(parameters, "inputdir", false);
if (inputDir == "not found"){ inputDir = ""; }
it = parameters.find("query");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["query"] = inputDir + it->second; }
}
it = parameters.find("reference");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["reference"] = inputDir + it->second; }
}
it = parameters.find("name");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["name"] = inputDir + it->second; }
}
outputDir = validParameter.validFile(parameters, "outputdir", false);
if (outputDir == "not found"){
outputDir = "";
- outputDir += hasPath(queryFileName); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(queryFileName); //if user entered a file with a path then preserve it
}
//check for optional parameter and set defaults
convert(temp, threshold);
errorFileName = queryFileName.substr(0,queryFileName.find_last_of('.')) + ".errors";
- openOutputFile(errorFileName, errorFile);
+ m->openOutputFile(errorFileName, errorFile);
+ outputNames.push_back(errorFileName); outputTypes["error"].push_back(errorFileName);
printErrorHeader();
}
}
if(namesFileName != ""){ weights = getWeights(); }
ifstream queryFile;
- openInputFile(queryFileName, queryFile);
+ m->openInputFile(queryFileName, queryFile);
int totalBases = 0;
int totalMatches = 0;
string errorCountFileName = queryFileName.substr(0,queryFileName.find_last_of('.')) + ".count";
ofstream errorCountFile;
- openOutputFile(errorCountFileName, errorCountFile);
+ m->openOutputFile(errorCountFileName, errorCountFile);
+ outputNames.push_back(errorCountFileName); outputTypes["count"].push_back(errorCountFileName);
m->mothurOut("Overall error rate:\t" + toString((double)(totalBases - totalMatches) / (double)totalBases) + "\n\n");
m->mothurOut("Errors\tSequences\n");
try {
ifstream referenceFile;
- openInputFile(referenceFileName, referenceFile);
+ m->openInputFile(referenceFileName, referenceFile);
while(referenceFile){
Sequence currentSeq(referenceFile);
currentSeq.removeAmbigBases();
}
referenceSeqs.push_back(currentSeq);
- gobble(referenceFile);
+ m->gobble(referenceFile);
}
numRefs = referenceSeqs.size();
map<string, int> SeqErrorCommand::getWeights(){
ifstream nameFile;
- openInputFile(namesFileName, nameFile);
+ m->openInputFile(namesFileName, nameFile);
string seqName;
string redundantSeqs;
while(nameFile){
nameFile >> seqName >> redundantSeqs;
- nameCountMap[seqName] = getNumNames(redundantSeqs);
- gobble(nameFile);
+ nameCountMap[seqName] = m->getNumNames(redundantSeqs);
+ m->gobble(nameFile);
}
return nameCountMap;
}