diff --git a/src/build_index_main.cpp b/src/build_index_main.cpp index 08866c1..2a967a5 100644 --- a/src/build_index_main.cpp +++ b/src/build_index_main.cpp @@ -23,6 +23,7 @@ struct Build_Config{ bool del_non_ACGT = false; LL colorset_sampling_distance = 1; bool verbose = false; + bool silent = false; void check_valid(){ check_true(inputfile != "", "Input file not set"); @@ -65,7 +66,13 @@ struct Build_Config{ ss << "User-specified colors = " << (colorfile == "" ? "false" : "true") << "\n"; ss << "Load DBG = " << (load_dbg ? "true" : "false") << "\n"; ss << "Handling of non-ACGT characters = " << (del_non_ACGT ? "delete" : "randomize") << "\n"; - ss << "Verbose mode = " << (verbose ? "true" : "false"); // Last has no endline + + string verbose_level = "normal"; + if(verbose) verbose_level = "versose"; + if(silent) verbose_level = "silent"; + + ss << "Verbosity = " << verbose_level; // Last has no endline + return ss.str(); } }; @@ -97,6 +104,7 @@ int build_index_main(int argc, char** argv){ ("no-colors", "Build only the de Bruijn graph without colors.", cxxopts::value()->default_value("false")) ("load-dbg", "If given, loads a precomputed de Bruijn graph from the index prefix. If this is given, the parameter -k must not be given because the order k is defined by the precomputed de Bruijn graph.", cxxopts::value()->default_value("false")) ("v,verbose", "More verbose progress reporting into stderr.", cxxopts::value()->default_value("false")) + ("silent", "Print as little as possible to stderr (only errors).", cxxopts::value()->default_value("false")) ("h,help", "Print usage") ; @@ -131,15 +139,18 @@ int build_index_main(int argc, char** argv){ C.colorset_sampling_distance = opts["colorset-pointer-tradeoff"].as(); C.del_non_ACGT = !(opts["randomize-non-ACGT"].as()); C.verbose = opts["verbose"].as(); + C.silent = opts["silent"].as(); + if(C.verbose && C.silent) throw runtime_error("Can not give both --verbose and --silent"); if(C.verbose) set_log_level(LogLevel::MINOR); + if(C.silent) set_log_level(LogLevel::OFF); create_directory_if_does_not_exist(C.temp_dir); C.check_valid(); get_temp_file_manager().set_dir(C.temp_dir); - cerr << C.to_string() << endl; + write_log("Build configuration:\n" + C.to_string(), LogLevel::MAJOR); write_log("Starting", LogLevel::MAJOR); if(C.input_format == "gzip"){ diff --git a/src/extract_unitigs_main.cpp b/src/extract_unitigs_main.cpp index b4af471..746b805 100644 --- a/src/extract_unitigs_main.cpp +++ b/src/extract_unitigs_main.cpp @@ -19,6 +19,7 @@ int extract_unitigs_main(int argc, char** argv){ ("gfa-out", "Output the unitig graph in GFA1 format (optional).", cxxopts::value()->default_value("")) ("colors-out", "Output filename for the unitig colors (optional). If this option is not given, the colors are not computed. Note that giving this option affects the unitigs written to unitigs-out: if a unitig has nodes with different color sets, the unitig is split into maximal segments of nodes that have equal color sets. The file format of the color file is as follows: there is one line for each unitig. The lines contain space-separated strings. The first string on a line is the FASTA header of a unitig (without the '>'), and the following strings on the line are the integer color labels of the colors of that unitig. The unitigs appear in the same order as in the FASTA file.", cxxopts::value()->default_value("")) ("v,verbose", "More verbose progress reporting into stderr.", cxxopts::value()->default_value("false")) + ("silent", "Print as little as possible to stderr (only errors).", cxxopts::value()->default_value("false")) ("h,help", "Print usage") ; @@ -30,7 +31,11 @@ int extract_unitigs_main(int argc, char** argv){ return 1; } + if(opts["verbose"].as() && opts["silent"].as()) + throw runtime_error("Can not give both --verbose and --silent"); if(opts["verbose"].as()) set_log_level(LogLevel::MINOR); + if(opts["silent"].as()) set_log_level(LogLevel::OFF); + string index_dbg_file = opts["index-prefix"].as() + ".tdbg"; string index_color_file = opts["index-prefix"].as() + ".tcolors"; check_readable(index_dbg_file); diff --git a/src/pseudoalign_main.cpp b/src/pseudoalign_main.cpp index 6210d4b..5d5a4a6 100644 --- a/src/pseudoalign_main.cpp +++ b/src/pseudoalign_main.cpp @@ -20,6 +20,7 @@ struct Pseudoalign_Config{ bool sort_output = false; LL n_threads = 1; bool verbose = false; + bool silent = false; void check_valid(){ for(string query_file : query_files){ @@ -88,6 +89,7 @@ int pseudoalign_main(int argc, char** argv){ ("gzip-output", "Compress the output files with gzip.", cxxopts::value()->default_value("false")) ("sort-output", "Sort the lines of the out files by sequence rank in the input files.", cxxopts::value()->default_value("false")) ("v,verbose", "More verbose progress reporting into stderr.", cxxopts::value()->default_value("false")) + ("silent", "Print as little as possible to stderr (only errors).", cxxopts::value()->default_value("false")) ("h,help", "Print usage") ; @@ -123,7 +125,11 @@ int pseudoalign_main(int argc, char** argv){ C.gzipped_output = opts["gzip-output"].as(); C.sort_output = opts["sort-output"].as(); C.verbose = opts["verbose"].as(); + C.silent = opts["silent"].as(); + + if(C.verbose && C.silent) throw runtime_error("Can not give both --verbose and --silent"); if(C.verbose) set_log_level(LogLevel::MINOR); + if(C.silent) set_log_level(LogLevel::OFF); create_directory_if_does_not_exist(C.temp_dir); diff --git a/src/stats_main.cpp b/src/stats_main.cpp index abf41a5..6ee1bc9 100644 --- a/src/stats_main.cpp +++ b/src/stats_main.cpp @@ -18,6 +18,7 @@ int stats_main(int argc, char** argv){ ("unitigs", "Also compute statistics on unitigs. This takes a while and requires the temporary directory to be set.", cxxopts::value()->default_value("false")) ("temp-dir", "Directory for temporary files.", cxxopts::value()) ("v,verbose", "More verbose progress reporting into stderr.", cxxopts::value()->default_value("false")) + ("silent", "Print as little as possible to stderr (only errors).", cxxopts::value()->default_value("false")) ("h,help", "Print usage") ; @@ -32,7 +33,12 @@ int stats_main(int argc, char** argv){ string index_dbg_file = opts["index-prefix"].as() + ".tdbg"; string index_color_file = opts["index-prefix"].as() + ".tcolors"; bool do_unitigs = opts["unitigs"].as(); + + if(opts["verbose"].as() && opts["silent"].as()) + throw runtime_error("Can not give both --verbose and --silent"); if(opts["verbose"].as()) set_log_level(LogLevel::MINOR); + if(opts["silent"].as()) set_log_level(LogLevel::OFF); + check_readable(index_dbg_file); check_readable(index_color_file); diff --git a/src/themisto_main.cpp b/src/themisto_main.cpp index 98ec1e7..335b390 100644 --- a/src/themisto_main.cpp +++ b/src/themisto_main.cpp @@ -19,8 +19,15 @@ void print_help(int argc, char** argv){ int main(int argc, char** argv){ - write_log("Themisto-" + std::string(THEMISTO_BUILD_VERSION), LogLevel::MAJOR); - write_log("Maximum k-mer length (size of the de Bruijn graph node labels): " + std::to_string(KMER_MAX_LENGTH-1), LogLevel::MAJOR); + bool silent_in_argv = false; + for(LL i = 1; i < argc; i++) + if(string(argv[i]) == string("--silent")) + silent_in_argv = true; + + if(!silent_in_argv){ + write_log("Themisto-" + std::string(THEMISTO_BUILD_VERSION), LogLevel::MAJOR); + write_log("Maximum k-mer length (size of the de Bruijn graph node labels): " + std::to_string(KMER_MAX_LENGTH-1), LogLevel::MAJOR); + } if(argc == 1){ print_help(argc, argv);