Class: MiGA::Cli::Action::Stats
- Inherits:
-
MiGA::Cli::Action
- Object
- MiGA
- MiGA::Cli::Action
- MiGA::Cli::Action::Stats
- Defined in:
- lib/miga/cli/action/stats.rb
Constant Summary
Constants included from MiGA
MiGA::CITATION, VERSION, VERSION_DATE, VERSION_NAME
Instance Attribute Summary
Attributes inherited from MiGA::Cli::Action
Instance Method Summary collapse
Methods inherited from MiGA::Cli::Action
#complete, #empty_action, #initialize, #launch, load, #name
Methods inherited from MiGA
CITATION, CITATION_ARRAY, DEBUG, DEBUG_OFF, DEBUG_ON, DEBUG_TRACE_OFF, DEBUG_TRACE_ON, FULL_VERSION, LONG_VERSION, VERSION, VERSION_DATE, #advance, debug?, debug_trace?, initialized?, #like_io?, #num_suffix, rc_path, #result_files_exist?, #say
Methods included from MiGA::Common::Path
Methods included from MiGA::Common::Format
#clean_fasta_file, #seqs_length, #tabulate
Methods included from MiGA::Common::Net
#download_file_ftp, #known_hosts, #remote_connection
Methods included from MiGA::Common::SystemCall
Constructor Details
This class inherits a constructor from MiGA::Cli::Action
Instance Method Details
#parse_cli ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/miga/cli/action/stats.rb', line 7 def parse_cli cli.defaults = { try_load: false } cli.parse do |opt| cli.opt_object(opt, [:project, :dataset_opt, :result]) opt.on( '--key STRING', 'Return only the value of the requested key' ) { |v| cli[:key] = v } opt.on( '--compute-and-save', 'Compute and save the statistics' ) { |v| cli[:compute] = v } opt.on( '--try-load', 'Check if stat exists instead of computing on --compute-and-save' ) { |v| cli[:try_load] = v } opt.on( '--ignore-empty', 'If the result does not exist, exit without throwing exceptions' ) { |v| cli[:ignore_result_empty] = v } end end |
#perform ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/miga/cli/action/stats.rb', line 30 def perform r = cli.load_result or return cli[:compute] = false if cli[:try_load] && !r[:stats]&.empty? if cli[:compute] cli.say 'Computing statistics' r.compute_stats end if cli[:key].nil? r[:stats].each do |k, v| k_n = k.to_s.unmiga_name.sub(/^./, &:upcase) cli.puts "#{k_n}: #{v.is_a?(Array) ? v.join(' ') : v}" end else v = r[:stats][cli[:key].downcase.miga_name.to_sym] puts v.is_a?(Array) ? v.first : v end end |