class MiGA::Cli::Action::TaxDist

Public Instance Methods

cannid(a, b) click to toggle source
# File lib/miga/cli/action/tax_dist.rb, line 23
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 11
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 }
  end
end
perform() click to toggle source
# File lib/miga/cli/action/tax_dist.rb, line 27
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