X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=heatmapsimcommand.cpp;h=7ab178c528f40b6c5b9456880545c104701debf8;hb=191ae1be0679d5cf4eda950b3b1bf26fb7dd503d;hp=dc67a8d4374ae90aebf182ce80d5474b17431f95;hpb=aa9238c0a9e6e7aa0ed8b8b606b08ad4fd7dcfe3;p=mothur.git diff --git a/heatmapsimcommand.cpp b/heatmapsimcommand.cpp index dc67a8d..7ab178c 100644 --- a/heatmapsimcommand.cpp +++ b/heatmapsimcommand.cpp @@ -19,7 +19,53 @@ #include "sharedmorisitahorn.h" #include "sharedbraycurtis.h" - +//********************************************************************************************************************** +vector HeatMapSimCommand::getValidParameters(){ + try { + string Array[] = {"groups","label", "calc","phylip","column","name","outputdir","inputdir"}; + vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); + return myArray; + } + catch(exception& e) { + m->errorOut(e, "HeatMapSimCommand", "getValidParameters"); + exit(1); + } +} +//********************************************************************************************************************** +HeatMapSimCommand::HeatMapSimCommand(){ + try { + abort = true; + //initialize outputTypes + vector tempOutNames; + outputTypes["svg"] = tempOutNames; + } + catch(exception& e) { + m->errorOut(e, "HeatMapSimCommand", "HeatMapSimCommand"); + exit(1); + } +} +//********************************************************************************************************************** +vector HeatMapSimCommand::getRequiredParameters(){ + try { + vector myArray; + return myArray; + } + catch(exception& e) { + m->errorOut(e, "HeatMapSimCommand", "getRequiredParameters"); + exit(1); + } +} +//********************************************************************************************************************** +vector HeatMapSimCommand::getRequiredFiles(){ + try { + vector myArray; + return myArray; + } + catch(exception& e) { + m->errorOut(e, "HeatMapSimCommand", "getRequiredFiles"); + exit(1); + } +} //********************************************************************************************************************** HeatMapSimCommand::HeatMapSimCommand(string option) { @@ -50,6 +96,10 @@ HeatMapSimCommand::HeatMapSimCommand(string option) { if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; } } + //initialize outputTypes + vector tempOutNames; + outputTypes["svg"] = tempOutNames; + format = ""; //if the user changes the output directory command factory will send this info to us in the output parameter outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){ outputDir = ""; } @@ -62,7 +112,7 @@ HeatMapSimCommand::HeatMapSimCommand(string option) { 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; } } @@ -70,7 +120,7 @@ HeatMapSimCommand::HeatMapSimCommand(string option) { 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; } } @@ -78,7 +128,7 @@ HeatMapSimCommand::HeatMapSimCommand(string option) { 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; } } @@ -88,12 +138,12 @@ HeatMapSimCommand::HeatMapSimCommand(string option) { phylipfile = validParameter.validFile(parameters, "phylip", true); if (phylipfile == "not open") { abort = true; } else if (phylipfile == "not found") { phylipfile = ""; } - else { format = "phylip"; if (outputDir == "") { outputDir += hasPath(phylipfile); } } + else { format = "phylip"; if (outputDir == "") { outputDir += m->hasPath(phylipfile); } } columnfile = validParameter.validFile(parameters, "column", true); if (columnfile == "not open") { abort = true; } else if (columnfile == "not found") { columnfile = ""; } - else { format = "column"; if (outputDir == "") { outputDir += hasPath(columnfile); } } + else { format = "column"; if (outputDir == "") { outputDir += m->hasPath(columnfile); } } namefile = validParameter.validFile(parameters, "name", true); if (namefile == "not open") { abort = true; } @@ -113,12 +163,12 @@ HeatMapSimCommand::HeatMapSimCommand(string option) { //check for optional parameter and set defaults // ...at some point should added some additional type checking... if (format == "shared") { - if (outputDir == "") { outputDir += hasPath(globaldata->getSharedFile()); } + if (outputDir == "") { outputDir += m->hasPath(globaldata->getSharedFile()); } label = validParameter.validFile(parameters, "label", false); if (label == "not found") { label = ""; } else { - if(label != "all") { splitAtDash(label, labels); allLines = 0; } + if(label != "all") { m->splitAtDash(label, labels); allLines = 0; } else { allLines = 1; } } @@ -133,12 +183,12 @@ HeatMapSimCommand::HeatMapSimCommand(string option) { else { if (calc == "default") { calc = "jest-thetayc"; } } - splitAtDash(calc, Estimators); + m->splitAtDash(calc, Estimators); groups = validParameter.validFile(parameters, "groups", false); if (groups == "not found") { groups = ""; } else { - splitAtDash(groups, Groups); + m->splitAtDash(groups, Groups); globaldata->Groups = Groups; } } @@ -240,7 +290,7 @@ int HeatMapSimCommand::execute(){ delete heatmap; delete validCalculator; - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); return 0; } m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); @@ -264,11 +314,11 @@ int HeatMapSimCommand::runCommandShared() { //you have groups read = new ReadOTUFile(globaldata->inputFileName); read->read(&*globaldata); - + input = globaldata->ginput; lookup = input->getSharedRAbundVectors(); string lastLabel = lookup[0]->getLabel(); - + if (lookup.size() < 2) { m->mothurOut("You have not provided enough valid groups. I cannot run the command."); m->mothurOutEndLine(); return 0;} //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label. @@ -286,13 +336,13 @@ int HeatMapSimCommand::runCommandShared() { m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine(); vector outfilenames = heatmap->getPic(lookup, heatCalculators); - for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]); } + for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]); outputTypes["svg"].push_back(outfilenames[i]); } processedLabels.insert(lookup[0]->getLabel()); userLabels.erase(lookup[0]->getLabel()); } - if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) { + if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) { string saveLabel = lookup[0]->getLabel(); for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } @@ -300,7 +350,7 @@ int HeatMapSimCommand::runCommandShared() { m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine(); vector outfilenames = heatmap->getPic(lookup, heatCalculators); - for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]); } + for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]); outputTypes["svg"].push_back(outfilenames[i]); } processedLabels.insert(lookup[0]->getLabel()); userLabels.erase(lookup[0]->getLabel()); @@ -315,7 +365,8 @@ int HeatMapSimCommand::runCommandShared() { //get next line to process for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } - lookup = input->getSharedRAbundVectors(); + lookup = input->getSharedRAbundVectors(); + } @@ -343,7 +394,7 @@ int HeatMapSimCommand::runCommandShared() { m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine(); vector outfilenames = heatmap->getPic(lookup, heatCalculators); - for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]); } + for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]); outputTypes["svg"].push_back(outfilenames[i]); } for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } } @@ -352,10 +403,10 @@ int HeatMapSimCommand::runCommandShared() { //reset groups parameter globaldata->Groups.clear(); - + delete input; globaldata->ginput = NULL; delete read; - + return 0; } catch(exception& e) { @@ -374,7 +425,7 @@ int HeatMapSimCommand::runCommandDist() { //read distance file and create distance vector and names vector if (format == "phylip") { //read phylip file - openInputFile(phylipfile, in); + m->openInputFile(phylipfile, in); string name; int numSeqs; @@ -422,7 +473,7 @@ int HeatMapSimCommand::runCommandDist() { if (m->control_pressed) { return 0; } for(int j=0;j> matrix[i][j]; } - gobble(in); + m->gobble(in); } }else { double dist; @@ -436,7 +487,7 @@ int HeatMapSimCommand::runCommandDist() { in >> dist; matrix[i][j] = dist; matrix[j][i] = dist; } - gobble(in); + m->gobble(in); } } in.close(); @@ -459,10 +510,10 @@ int HeatMapSimCommand::runCommandDist() { //read column file string first, second; double dist; - openInputFile(columnfile, in); + m->openInputFile(columnfile, in); while (!in.eof()) { - in >> first >> second >> dist; gobble(in); + in >> first >> second >> dist; m->gobble(in); if (m->control_pressed) { return 0; } @@ -481,8 +532,10 @@ int HeatMapSimCommand::runCommandDist() { delete nameMap; } - - outputNames.push_back(heatmap->getPic(matrix, names)); //vector>, vector + + string outputFileName = heatmap->getPic(matrix, names); + outputNames.push_back(outputFileName); //vector>, vector + outputTypes["svg"].push_back(outputFileName); return 0; }