X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=heatmapsimcommand.cpp;h=7e77980659681cd6aa4bbafbc6d502e4e0064bc7;hb=4745a956b3116a719f52f341d2a2db84df4817da;hp=1b4b9d79010b22391ed29e148c8b3f9137ac1b3f;hpb=74844a60d80c6dd06e3fb02ee9b928424f9019b0;p=mothur.git diff --git a/heatmapsimcommand.cpp b/heatmapsimcommand.cpp index 1b4b9d7..7e77980 100644 --- a/heatmapsimcommand.cpp +++ b/heatmapsimcommand.cpp @@ -62,7 +62,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 +70,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 +78,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 +88,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 +113,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 +133,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,6 +240,8 @@ 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; } + m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } @@ -262,20 +264,24 @@ 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. set processedLabels; set userLabels = labels; + if (m->control_pressed) { delete read; delete input; globaldata->ginput = NULL; for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } globaldata->Groups.clear(); return 0; } + //as long as you are not at the end of the file or done wih the lines you want while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) { - + + if (m->control_pressed) { delete read; delete input; globaldata->ginput = NULL; for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } globaldata->Groups.clear(); return 0; } + if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){ m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine(); @@ -286,7 +292,7 @@ int HeatMapSimCommand::runCommandShared() { 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]; } @@ -309,9 +315,13 @@ 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(); + } + + if (m->control_pressed) { delete read; delete input; globaldata->ginput = NULL; globaldata->Groups.clear(); return 0; } + //output error messages about any remaining user labels set::iterator it; bool needToRun = false; @@ -325,6 +335,8 @@ int HeatMapSimCommand::runCommandShared() { } } + if (m->control_pressed) { delete read; delete input; globaldata->ginput = NULL; globaldata->Groups.clear(); return 0; } + //run last label if you need to if (needToRun == true) { for (int i = 0; i < lookup.size(); i++) { if (lookup[i] != NULL) { delete lookup[i]; } } @@ -337,13 +349,14 @@ int HeatMapSimCommand::runCommandShared() { for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } } + if (m->control_pressed) { delete read; delete input; globaldata->ginput = NULL; globaldata->Groups.clear(); return 0; } //reset groups parameter globaldata->Groups.clear(); - + delete input; globaldata->ginput = NULL; delete read; - + return 0; } catch(exception& e) { @@ -362,7 +375,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; @@ -407,8 +420,10 @@ int HeatMapSimCommand::runCommandDist() { in >> name; names.push_back(name); - for(int j=0;j> matrix[i][j]; } - gobble(in); + if (m->control_pressed) { return 0; } + + for(int j=0;j> matrix[i][j]; } + m->gobble(in); } }else { double dist; @@ -416,11 +431,13 @@ int HeatMapSimCommand::runCommandDist() { in >> name; names.push_back(name); + if (m->control_pressed) { return 0; } + for(int j=0;j> dist; matrix[i][j] = dist; matrix[j][i] = dist; } - gobble(in); + m->gobble(in); } } in.close(); @@ -443,10 +460,12 @@ 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; } map::iterator itA = nameMap->find(first); map::iterator itB = nameMap->find(second);