Class: MiGA::Cli::Action::TaxIndex
- Inherits:
-
MiGA::Cli::Action
- Object
- MiGA
- MiGA::Cli::Action
- MiGA::Cli::Action::TaxIndex
- Defined in:
- lib/miga/cli/action/tax_index.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
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/miga/cli/action/tax_index.rb', line 8 def parse_cli cli.defaults = { format: :json } cli.parse do |opt| cli.opt_object(opt, [:project]) opt.on( '-i', '--index PATH', '(Mandatory) File to create with the index' ) { |v| cli[:index] = v } opt.on( '-f', '--format STRING', "Format of the index file, by default: #{cli[:format]}", 'Supported: json, tab.' ) { |v| cli[:format] = v.downcase.to_sym } cli.opt_filter_datasets(opt) end end |
#perform ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/miga/cli/action/tax_index.rb', line 25 def perform cli.ensure_par(index: '-i') ds = cli.load_and_filter_datasets cli.say 'Indexing taxonomy' tax_index = MiGA::TaxIndex.new ds.each_with_index do |d, i| cli.advance('Datasets:', i, ds.size, false) tax_index << d unless d.[:tax].nil? end cli.say '' cli.say 'Saving index' File.open(cli[:index], 'w') do |fh| case cli[:format] when :json fh.print tax_index.to_json when :tab fh.print tax_index.to_tab else raise "Unsupported output format: #{cli[:format]}" end end end |