class MiGA::Cli::Action::DerepWf

Public Instance Methods

parse_cli() click to toggle source
# File lib/miga/cli/action/derep_wf.rb, line 10
def parse_cli
  default_opts_for_wf
  cli.defaults = {
    metric: :ani, threshold: 95.0, criterion: :quality,
    summaries: true, collection: true
  }
  cli.parse do |opt|
    opt.on(
      '--aai',
      'Use Average Amino Acid Identity (AAI) as genome similarity metric',
      'By default: Use Average Nucleotide Identity (ANI)'
    ) { cli[:metric] = :aai }
    opt.on(
      '--ani',
      'Use Average Nucleotide Identity (ANI) as similarity metric (default)'
    ) { cli[:metric] = :ani }
    opt.on(
      '--threshold FLOAT', Float,
      "Metric threshold (%) to dereplicate. By default: #{cli[:threshold]}"
    ) { |v| cli[:threshold] = v }
    opt.on(
      '--medoids',
      'Use medoids as clade representatives',
      'By default: Use genome with the highest quality'
    ) { |v| cli[:criterion] = :medoids }
    opt.on(
      '--no-collection',
      'Do not generate a dereplicated collection of assemblies'
    ) { |v| cli[:collection] = v }
    opt.on(
      '--no-summaries',
      'Do not generate intermediate step summaries'
    ) { |v| cli[:summaries] = v }
    opts_for_wf_distances(opt)
    opts_for_wf(opt, 'Input genome assemblies (nucleotides, FastA)')
  end
end
perform() click to toggle source
# File lib/miga/cli/action/derep_wf.rb, line 48
def perform
  # Input data
  p = create_project(:assembly,
                     { run_project_stats: false, run_clades: false,
                       gsp_metric: cli[:metric], :"gsp_#{cli[:metric]}" => cli[:threshold] },
                     { run_mytaxa_scan: false, run_ssu: false })
  unless cli[:threshold] >= 0.0 && cli[:threshold] <= 100.0
    raise "The threshold of identity must be in the range [0,100]"
  end

  # Run
  run_daemon
  dereplicate(p)
  summarize(%w[cds assembly essential_genes]) if cli[:summaries]
  cleanup
end