Skip to content

Commit

Permalink
node sparsification factor must be in the [0,1] range
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreaGuarracino committed Feb 10, 2024
1 parent 2aba37b commit 6336c63
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/subcommand/draw_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ int main_draw(int argc, char **argv) {
"Colors are derived from the 4th column, if present, else from the path name."
"If the 4th column value is in the format 'string#RRGGBB', the RRGGBB color (in hex notation) will be used.",
{'b', "bed-file"});
args::ValueFlag<float> node_sparsification(parser, "N", "Remove this fraction of nodes from the SVG output (to output smaller files) (default: 0.0, keep all nodes).", {'f', "sparse-factor-svg"});
args::ValueFlag<float> node_sparsification(parser, "N", "Remove this fraction of nodes from the SVG output (to output smaller files) (default: 0.0, keep all nodes).", {'f', "svg-sparse-factor"});
args::Group threading(parser, "[ Threading ]");
args::ValueFlag<uint64_t> nthreads(threading, "N", "Number of threads to use for parallel operations.", {'t', "threads"});
args::Group processing_info_opts(parser, "[ Processing Information ]");
Expand Down Expand Up @@ -95,6 +95,12 @@ int main_draw(int argc, char **argv) {
return 1;
}

const float sparse_nodes = node_sparsification ? args::get(node_sparsification) : 0.0;
if (sparse_nodes < 0.0 || sparse_nodes > 1.0) {
std::cerr << "[odgi::draw] error: -f/--svg-sparse-factor must be in the range [0.0, 1.0]." << std::endl;
return 1;
}

const uint64_t num_threads = args::get(nthreads) ? args::get(nthreads) : 1;

graph_t graph;
Expand Down Expand Up @@ -220,7 +226,6 @@ int main_draw(int argc, char **argv) {

if (svg_out_file) {
const double svg_scale = !svg_render_scale ? 0.01 : args::get(svg_render_scale);
const float sparse_nodes = node_sparsification ? args::get(node_sparsification) : 0.0;
auto& outfile = args::get(svg_out_file);
ofstream f(outfile.c_str());
// todo could be done with callbacks
Expand Down

0 comments on commit 6336c63

Please sign in to comment.