From 6336c63cc67ad7649aadb643b371d5a610fa3b1f Mon Sep 17 00:00:00 2001 From: AndreaGuarracino Date: Sat, 10 Feb 2024 14:41:44 +0100 Subject: [PATCH] node sparsification factor must be in the [0,1] range --- src/subcommand/draw_main.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/subcommand/draw_main.cpp b/src/subcommand/draw_main.cpp index 178c8196..07f2c379 100644 --- a/src/subcommand/draw_main.cpp +++ b/src/subcommand/draw_main.cpp @@ -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 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 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 nthreads(threading, "N", "Number of threads to use for parallel operations.", {'t', "threads"}); args::Group processing_info_opts(parser, "[ Processing Information ]"); @@ -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; @@ -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