@@ -201,11 +201,11 @@ int do_map(FulgorIndex const& index, fastx_parser::FastxParser<fastx_parser::Rea
201201template <typename FulgorIndex>
202202int pseudoalign (std::string const & index_filename, std::string const & query_filename,
203203 std::string const & output_filename, uint64_t num_threads, double threshold,
204- pseudoalignment_algorithm algo) {
204+ pseudoalignment_algorithm algo, const bool quiet ) {
205205 FulgorIndex index;
206- essentials::logger (" loading index from disk..." );
206+ if (!quiet) essentials::logger (" loading index from disk..." );
207207 essentials::load (index, index_filename.c_str ());
208- essentials::logger (" DONE" );
208+ if (!quiet) essentials::logger (" DONE" );
209209
210210 // if not a skipping variant and no threshold set, then set the algorithm
211211 if ((algo == pseudoalignment_algorithm::FULL_INTERSECTION) and
@@ -218,7 +218,7 @@ int pseudoalign(std::string const& index_filename, std::string const& query_file
218218 if (((algo == pseudoalignment_algorithm::SKIPPING) or
219219 (algo == pseudoalignment_algorithm::SKIPPING_KALLISTO)) and
220220 !(index.get_k2u ().canonicalized ())) {
221- std::cout << " ==> Warning: skipping is only supported for canonicalized indexes. <=="
221+ std::cerr << " ==> Warning: skipping is only supported for canonicalized indexes. <=="
222222 << std::endl;
223223 }
224224
@@ -228,7 +228,7 @@ int pseudoalign(std::string const& index_filename, std::string const& query_file
228228 return 1 ;
229229 }
230230
231- essentials::logger (" performing queries from file '" + query_filename + " '..." );
231+ if (!quiet) essentials::logger (" performing queries from file '" + query_filename + " '..." );
232232 essentials::timer<std::chrono::high_resolution_clock, std::chrono::milliseconds> t;
233233 t.start ();
234234
@@ -238,8 +238,9 @@ int pseudoalign(std::string const& index_filename, std::string const& query_file
238238 auto query_filenames = std::vector<std::string>({query_filename});
239239 if (num_threads == 1 ) {
240240 num_threads += 1 ;
241- essentials::logger (
242- " 1 thread was specified, but an additional thread will be allocated for parsing" );
241+ std::cerr
242+ << " 1 thread was specified, but an additional thread will be allocated for parsing"
243+ << std::endl;
243244 }
244245 fastx_parser::FastxParser<fastx_parser::ReadSeq> rparser (query_filenames, num_threads,
245246 num_threads - 1 );
@@ -252,7 +253,7 @@ int pseudoalign(std::string const& index_filename, std::string const& query_file
252253 std::ofstream out_file;
253254 out_file.open (output_filename, std::ios::out | std::ios::trunc);
254255 if (!out_file) {
255- essentials::logger ( " could not open output file " + output_filename) ;
256+ std::cerr << " could not open output file " + output_filename << std::endl ;
256257 return 1 ;
257258 }
258259
@@ -268,26 +269,30 @@ int pseudoalign(std::string const& index_filename, std::string const& query_file
268269 rparser.stop ();
269270
270271 t.stop ();
271- essentials::logger (" DONE" );
272-
273- std::cout << " mapped " << num_reads << " reads" << std::endl;
274- std::cout << " elapsed = " << t.elapsed () << " millisec / " ;
275- std::cout << t.elapsed () / 1000 << " sec / " ;
276- std::cout << t.elapsed () / 1000 / 60 << " min / " ;
277- std::cout << (t.elapsed () * 1000 ) / num_reads << " musec/read" << std::endl;
278- std::cout << " num_mapped_reads " << num_mapped_reads << " /" << num_reads << " ("
279- << (num_mapped_reads * 100.0 ) / num_reads << " %)" << std::endl;
272+ if (!quiet) essentials::logger (" DONE" );
273+
274+ if (!quiet) {
275+ std::cout << " mapped " << num_reads << " reads" << std::endl;
276+ std::cout << " elapsed = " << t.elapsed () << " millisec / " ;
277+ std::cout << t.elapsed () / 1000 << " sec / " ;
278+ std::cout << t.elapsed () / 1000 / 60 << " min / " ;
279+ std::cout << (t.elapsed () * 1000 ) / num_reads << " musec/read" << std::endl;
280+ std::cout << " num_mapped_reads " << num_mapped_reads << " /" << num_reads << " ("
281+ << (num_mapped_reads * 100.0 ) / num_reads << " %)" << std::endl;
282+ }
280283
281284 return 0 ;
282285}
283286
284287int pseudoalign (int argc, char ** argv) {
288+ /* params */
285289 std::string index_filename;
286290 std::string query_filename;
287291 std::string output_filename;
288292 uint64_t num_threads = 1 ;
289293 double threshold = constants::invalid_threshold;
290294 pseudoalignment_algorithm algo = pseudoalignment_algorithm::FULL_INTERSECTION;
295+ bool quiet = false ;
291296
292297 CLI::App app{" Perform (color-only) pseudoalignment to a Fulgor index." };
293298 app.add_option (" -i,--index" , index_filename, " The Fulgor index filename," )
@@ -296,7 +301,10 @@ int pseudoalign(int argc, char** argv) {
296301 app.add_option (" -q,--query" , query_filename,
297302 " Query filename in FASTA/FASTQ format (optionally gzipped)." )
298303 ->required ();
299- app.add_option (" -o,--output" , output_filename, " File where output will be written." )
304+ app.add_option (" -o,--output" , output_filename,
305+ " File where output will be written. You can specify \" /dev/stdout\" to write "
306+ " output to stdout. In this case, it is also recommended to use the --quiet flag "
307+ " to avoid printing status messages to stdout." )
300308 ->required ();
301309 app.add_option (" -t,--threads" , num_threads, " Number of threads." )->default_val (1 );
302310 app.add_option (" --threshold" , threshold, " Threshold for threshold_union algorithm." )
@@ -309,25 +317,26 @@ int pseudoalign(int argc, char** argv) {
309317 [&algo]() { algo = pseudoalignment_algorithm::SKIPPING_KALLISTO; },
310318 " Enable the kallisto skipping heuristic in pseudoalignment." )
311319 ->excludes (skip_opt);
320+ app.add_flag (" --quiet" , quiet, " Quiet mode: do not print status messages to stdout." );
312321 CLI11_PARSE (app, argc, argv);
313322
314- util::print_cmd (argc, argv);
323+ if (!quiet) util::print_cmd (argc, argv);
315324
316325 if (sshash::util::ends_with (index_filename,
317326 constants::meta_diff_colored_fulgor_filename_extension)) {
318327 return pseudoalign<meta_differential_index_type>(
319- index_filename, query_filename, output_filename, num_threads, threshold, algo);
328+ index_filename, query_filename, output_filename, num_threads, threshold, algo, quiet );
320329 } else if (sshash::util::ends_with (index_filename,
321330 constants::meta_colored_fulgor_filename_extension)) {
322331 return pseudoalign<meta_index_type>(index_filename, query_filename, output_filename,
323- num_threads, threshold, algo);
332+ num_threads, threshold, algo, quiet );
324333 } else if (sshash::util::ends_with (index_filename,
325334 constants::diff_colored_fulgor_filename_extension)) {
326335 return pseudoalign<differential_index_type>(index_filename, query_filename, output_filename,
327- num_threads, threshold, algo);
336+ num_threads, threshold, algo, quiet );
328337 } else if (sshash::util::ends_with (index_filename, constants::fulgor_filename_extension)) {
329338 return pseudoalign<index_type>(index_filename, query_filename, output_filename, num_threads,
330- threshold, algo);
339+ threshold, algo, quiet );
331340 }
332341
333342 std::cerr << " Wrong filename supplied." << std::endl;
0 commit comments