- globaldata = GlobalData::getInstance();
- validCalculator = new ValidCalculators();
- ends = globaldata->getEnds();
- convert(globaldata->getProcessors(), processors);
- convert(globaldata->getCutOff(), cutoff);
-
- int i;
- if (ends != "T") {
- for (i=0; i<globaldata->Estimators.size(); i++) {
- if (validCalculator->isValidCalculator("distance", globaldata->Estimators[i]) == true) {
- if (globaldata->Estimators[i] == "nogaps") {
- distCalculator = new ignoreGaps();
- }else if (globaldata->Estimators[i] == "eachgap") {
- distCalculator = new eachGapDist();
- }else if (globaldata->Estimators[i] == "onegap") {
- distCalculator = new oneGapDist(); }
+ abort = true;
+ //initialize outputTypes
+ vector<string> tempOutNames;
+ outputTypes["phylip"] = tempOutNames;
+ outputTypes["column"] = tempOutNames;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "DistanceCommand", "DistanceCommand");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+vector<string> DistanceCommand::getRequiredParameters(){
+ try {
+ string Array[] = {"fasta"};
+ vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+ return myArray;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "DistanceCommand", "getRequiredParameters");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+vector<string> DistanceCommand::getRequiredFiles(){
+ try {
+ vector<string> myArray;
+ return myArray;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "DistanceCommand", "getRequiredFiles");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+DistanceCommand::DistanceCommand(string option) {
+ try {
+ abort = false;
+ Estimators.clear();
+
+ //allow user to run help
+ if(option == "help") { help(); abort = true; }
+
+ else {
+ //valid paramters for this command
+ string Array[] = {"fasta","oldfasta","column", "output", "calc", "countends", "cutoff", "processors", "outputdir","inputdir","compress"};
+
+ vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+
+ OptionParser parser(option);
+ map<string, string> parameters = parser.getParameters();
+
+ ValidParameters validParameter("dist.seqs");
+ map<string, string>::iterator it2;
+
+ //check to make sure all parameters are valid for command
+ for (it2 = parameters.begin(); it2 != parameters.end(); it2++) {
+ if (validParameter.isValidParameter(it2->first, myArray, it2->second) != true) { abort = true; }
+ }
+
+ //initialize outputTypes
+ vector<string> tempOutNames;
+ outputTypes["phylip"] = tempOutNames;
+ outputTypes["column"] = 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 = ""; }
+ else {
+ string path;
+ it2 = parameters.find("fasta");
+ //user has given a template file
+ if(it2 != parameters.end()){
+ path = m->hasPath(it2->second);
+ //if the user has not given a path then, add inputdir. else leave path alone.
+ if (path == "") { parameters["fasta"] = inputDir + it2->second; }
+ }
+
+ it2 = parameters.find("oldfasta");
+ //user has given a template file
+ if(it2 != parameters.end()){
+ path = m->hasPath(it2->second);
+ //if the user has not given a path then, add inputdir. else leave path alone.
+ if (path == "") { parameters["oldfasta"] = inputDir + it2->second; }
+ }
+
+ it2 = parameters.find("column");
+ //user has given a template file
+ if(it2 != parameters.end()){
+ path = m->hasPath(it2->second);
+ //if the user has not given a path then, add inputdir. else leave path alone.
+ if (path == "") { parameters["column"] = inputDir + it2->second; }