#include "sensspeccommand.h"
+//**********************************************************************************************************************
+vector<string> SensSpecCommand::getValidParameters(){
+ try {
+ string Array[] = {"list", "phylip", "column", "name", "hard", "label", "cutoff", "precision", "outputdir", "inputdir"};
+ vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+ return myArray;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "SensSpecCommand", "getValidParameters");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+SensSpecCommand::SensSpecCommand(){
+ try {
+ abort = true;
+ //initialize outputTypes
+ vector<string> tempOutNames;
+ outputTypes["sensspec"] = tempOutNames;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "SensSpecCommand", "SensSpecCommand");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+vector<string> SensSpecCommand::getRequiredParameters(){
+ try {
+ string Array[] = {"list","phylip","column","or"};
+ vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+ return myArray;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "SensSpecCommand", "getRequiredParameters");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+vector<string> SensSpecCommand::getRequiredFiles(){
+ try {
+ vector<string> myArray;
+ return myArray;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "SensSpecCommand", "getRequiredFiles");
+ exit(1);
+ }
+}
//***************************************************************************************************************
SensSpecCommand::SensSpecCommand(string option) {
if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; }
}
+ //initialize outputTypes
+ vector<string> tempOutNames;
+ outputTypes["sensspec"] = 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("list");
//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["list"] = inputDir + it->second; }
}
it = parameters.find("phylip");
//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["phylip"] = inputDir + it->second; }
}
it = parameters.find("column");
//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["column"] = 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(listFile); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(listFile); //if user entered a file with a path then preserve it
}
//check for optional parameter and set defaults
// ...at some point should added some additional type checking...
temp = validParameter.validFile(parameters, "hard", false);
if (temp == "not found"){ hard = 0; }
- else if(!isTrue(temp)) { hard = 0; }
- else if(isTrue(temp)) { hard = 1; }
+ else if(!m->isTrue(temp)) { hard = 0; }
+ else if(m->isTrue(temp)) { hard = 1; }
// temp = validParameter.validFile(parameters, "name", true);
// if (temp == "not found") { nameFile = ""; }
if (abort == true) { return 0; }
setUpOutput();
+ outputNames.push_back(sensSpecFileName); outputTypes["sensspec"].push_back(sensSpecFileName);
if(format == "phylip") { processPhylip(); }
else if(format == "column") { processColumn(); }
//probably need some checking to confirm that the names in the distance matrix are the same as those in the list file
ifstream inputListFile;
- openInputFile(listFile, inputListFile);
+ m->openInputFile(listFile, inputListFile);
string origCutoff = "";
bool getCutoff = 0;
}
seqMap[seqName] = i;
}
- gobble(inputListFile);
+ m->gobble(inputListFile);
int lNumSeqs = seqMap.size();
int pNumSeqs = 0;
ifstream phylipFile;
- openInputFile(distFile, phylipFile);
+ m->openInputFile(distFile, phylipFile);
phylipFile >> pNumSeqs;
if(pNumSeqs != lNumSeqs){ cout << "numSeq mismatch!" << endl; }
void SensSpecCommand::processColumn(){
try{
ifstream inputListFile;
- openInputFile(listFile, inputListFile);
+ m->openInputFile(listFile, inputListFile);
string origCutoff = "";
bool getCutoff = 0;
}
}
}
- gobble(inputListFile);
+ m->gobble(inputListFile);
int numDists = (numSeqs * (numSeqs-1) / 2);
ifstream columnFile;
- openInputFile(distFile, columnFile);
+ m->openInputFile(distFile, columnFile);
string seqNameA, seqNameB, seqPairString;
double distance;
seqPairSet.erase(it);
}
- gobble(columnFile);
+ m->gobble(columnFile);
}
falsePositives += seqPairSet.size();
void SensSpecCommand::setUpOutput(){
try{
ofstream sensSpecFile;
- openOutputFile(sensSpecFileName, sensSpecFile);
+ m->openOutputFile(sensSpecFileName, sensSpecFile);
sensSpecFile << "label\tcutoff\ttp\ttn\tfp\tfn\tsensitivity\tspecificity\tppv\tnpv\tfdr\taccuracy\tmcc\tf1score\n";
if(nPrime == 0) { negativePredictiveValue = 0; matthewsCorrCoef = 0; }
ofstream sensSpecFile;
- openOutputFileAppend(sensSpecFileName, sensSpecFile);
+ m->openOutputFileAppend(sensSpecFileName, sensSpecFile);
sensSpecFile << label << '\t' << cutoff << '\t';
sensSpecFile << truePositives << '\t' << trueNegatives << '\t' << falsePositives << '\t' << falseNegatives << '\t';