Class: MiGA::Cli::Action::Relatives
- Inherits:
-
MiGA::Cli::Action
- Object
- MiGA
- MiGA::Cli::Action
- MiGA::Cli::Action::Relatives
- Defined in:
- lib/miga/cli/action/relatives.rb
Constant Summary
Constants included from MiGA
MiGA::CITATION, VERSION, VERSION_DATE, VERSION_NAME
Instance Attribute Summary
Attributes inherited from MiGA::Cli::Action
Attributes included from MiGA::Common::Net
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, #http_request, #known_hosts, #main_server, #net_method, #normalize_encoding, #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 29 30 31 32 33 34 |
# File 'lib/miga/cli/action/relatives.rb', line 7 def parse_cli cli.defaults = { metric: :aai, external: false, how_many: 5 } cli.parse do |opt| cli.opt_object(opt, [:project, :dataset_opt]) cli.opt_filter_datasets(opt) opt.on( '--metric STRING', 'Use this metric of identity, one of ANI or AAI (default)' ) { |v| cli[:metric] = v.downcase.to_sym } opt.on( '--ref-project', 'Report distances to the external reference project used for taxonomy', 'By default: report distances to other datasets in the project' ) { |v| cli[:external] = v } opt.on( '-n', '--how-many INT', Integer, 'Number of top values to report' ) { |v| cli[:how_many] = v } opt.on( '--tab', 'Return a tab-delimited table' ) { |v| cli[:tabular] = v } opt.on( '-o', '--output PATH', 'Create output file instead of returning to STDOUT' ) { |v| cli[:output] = v } end end |
#perform ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/miga/cli/action/relatives.rb', line 36 def perform cr = [] cli.load_and_filter_datasets.each do |d| d_cr = d.closest_relatives(cli[:how_many], cli[:external], cli[:metric]) d_cr ||= [] cr += d_cr.map { |i| [d.name] + i } end io = cli[:output].nil? ? $stdout : File.open(cli[:output], 'w') cli.table(['dataset_A', 'dataset_B', cli[:metric]], cr, io) end |