Class: MiGA::Cli::Action::TaxDist
- Inherits:
-
MiGA::Cli::Action
- Object
- MiGA
- MiGA::Cli::Action
- MiGA::Cli::Action::TaxDist
- Defined in:
- lib/miga/cli/action/tax_dist.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
#cannid(a, b) ⇒ Object
26 27 28 |
# File 'lib/miga/cli/action/tax_dist.rb', line 26 def cannid(a, b) (a > b ? [b, a] : [a, b]).join('-') end |
#parse_cli ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/miga/cli/action/tax_dist.rb', line 9 def parse_cli cli.parse do |opt| cli.opt_object(opt, [:project]) cli.opt_filter_datasets(opt) opt.on( '-i', '--index FILE', 'Pre-calculated tax-index (in tabular format) to be used', 'If passed, dataset filtering arguments are ignored' ) { |v| cli[:index] = v } opt.on( '-m', '--metric STR', 'Distance metric used to evaluate the distribution', 'By default: AAI for genomes projects, ANI for clade projects' ) { |v| cli[:metric] = v.downcase } end end |
#perform ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/miga/cli/action/tax_dist.rb', line 30 def perform dist = read_distances Dir.mktmpdir do |dir| tab = get_tab_index(dir) dist = traverse_taxonomy(tab, dist) end cli.say 'Generating report' dist.keys.each do |k| dist[k][5] = dist[k][4].reverse.join(' ') dist[k][4] = dist[k][4].first puts (k.split('-') + dist[k]).join("\t") end end |