Skip to content

Commit

Permalink
Silent mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jnalanko committed Nov 24, 2021
1 parent d738b2b commit f18aa8f
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 4 deletions.
15 changes: 13 additions & 2 deletions src/build_index_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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();
}
};
Expand Down Expand Up @@ -97,6 +104,7 @@ int build_index_main(int argc, char** argv){
("no-colors", "Build only the de Bruijn graph without colors.", cxxopts::value<bool>()->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<bool>()->default_value("false"))
("v,verbose", "More verbose progress reporting into stderr.", cxxopts::value<bool>()->default_value("false"))
("silent", "Print as little as possible to stderr (only errors).", cxxopts::value<bool>()->default_value("false"))
("h,help", "Print usage")
;

Expand Down Expand Up @@ -131,15 +139,18 @@ int build_index_main(int argc, char** argv){
C.colorset_sampling_distance = opts["colorset-pointer-tradeoff"].as<LL>();
C.del_non_ACGT = !(opts["randomize-non-ACGT"].as<bool>());
C.verbose = opts["verbose"].as<bool>();
C.silent = opts["silent"].as<bool>();

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"){
Expand Down
5 changes: 5 additions & 0 deletions src/extract_unitigs_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ int extract_unitigs_main(int argc, char** argv){
("gfa-out", "Output the unitig graph in GFA1 format (optional).", cxxopts::value<string>()->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<string>()->default_value(""))
("v,verbose", "More verbose progress reporting into stderr.", cxxopts::value<bool>()->default_value("false"))
("silent", "Print as little as possible to stderr (only errors).", cxxopts::value<bool>()->default_value("false"))
("h,help", "Print usage")
;

Expand All @@ -30,7 +31,11 @@ int extract_unitigs_main(int argc, char** argv){
return 1;
}

if(opts["verbose"].as<bool>() && opts["silent"].as<bool>())
throw runtime_error("Can not give both --verbose and --silent");
if(opts["verbose"].as<bool>()) set_log_level(LogLevel::MINOR);
if(opts["silent"].as<bool>()) set_log_level(LogLevel::OFF);

string index_dbg_file = opts["index-prefix"].as<string>() + ".tdbg";
string index_color_file = opts["index-prefix"].as<string>() + ".tcolors";
check_readable(index_dbg_file);
Expand Down
6 changes: 6 additions & 0 deletions src/pseudoalign_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down Expand Up @@ -88,6 +89,7 @@ int pseudoalign_main(int argc, char** argv){
("gzip-output", "Compress the output files with gzip.", cxxopts::value<bool>()->default_value("false"))
("sort-output", "Sort the lines of the out files by sequence rank in the input files.", cxxopts::value<bool>()->default_value("false"))
("v,verbose", "More verbose progress reporting into stderr.", cxxopts::value<bool>()->default_value("false"))
("silent", "Print as little as possible to stderr (only errors).", cxxopts::value<bool>()->default_value("false"))
("h,help", "Print usage")
;

Expand Down Expand Up @@ -123,7 +125,11 @@ int pseudoalign_main(int argc, char** argv){
C.gzipped_output = opts["gzip-output"].as<bool>();
C.sort_output = opts["sort-output"].as<bool>();
C.verbose = opts["verbose"].as<bool>();
C.silent = opts["silent"].as<bool>();

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);

Expand Down
6 changes: 6 additions & 0 deletions src/stats_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>()->default_value("false"))
("temp-dir", "Directory for temporary files.", cxxopts::value<string>())
("v,verbose", "More verbose progress reporting into stderr.", cxxopts::value<bool>()->default_value("false"))
("silent", "Print as little as possible to stderr (only errors).", cxxopts::value<bool>()->default_value("false"))
("h,help", "Print usage")
;

Expand All @@ -32,7 +33,12 @@ int stats_main(int argc, char** argv){
string index_dbg_file = opts["index-prefix"].as<string>() + ".tdbg";
string index_color_file = opts["index-prefix"].as<string>() + ".tcolors";
bool do_unitigs = opts["unitigs"].as<bool>();

if(opts["verbose"].as<bool>() && opts["silent"].as<bool>())
throw runtime_error("Can not give both --verbose and --silent");
if(opts["verbose"].as<bool>()) set_log_level(LogLevel::MINOR);
if(opts["silent"].as<bool>()) set_log_level(LogLevel::OFF);

check_readable(index_dbg_file);
check_readable(index_color_file);

Expand Down
11 changes: 9 additions & 2 deletions src/themisto_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f18aa8f

Please sign in to comment.