class MiGA::Cli::Action::TaxDist

Public Instance Methods

cannid(a, b) click to toggle source
# File lib/miga/cli/action/tax_dist.rb, line 26
def cannid(a, b)
  (a > b ? [b, a] : [a, b]).join('-')
end
parse_cli() click to toggle source
# 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() click to toggle source
# 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