Class: MiGA::Cli::Action::ClassifyWf

Inherits:
MiGA::Cli::Action show all
Includes:
Wf
Defined in:
lib/miga/cli/action/classify_wf.rb

Constant Summary

Constants included from MiGA

MiGA::CITATION, VERSION, VERSION_DATE, VERSION_NAME

Instance Attribute Summary

Attributes inherited from MiGA::Cli::Action

#cli

Attributes included from MiGA::Common::Net

#remote_connection_uri

Instance Method Summary collapse

Methods included from Wf

#call_cli, #cleanup, #create_project, #default_opts_for_wf, #download_datasets, #import_datasets, #initialize_empty_project, #opts_for_wf, #opts_for_wf_distances, #run_daemon, #summarize, #transfer_metadata

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

#root_path, #script_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

#run_cmd, #run_cmd_opts

Constructor Details

This class inherits a constructor from MiGA::Cli::Action

Instance Method Details

#parse_cliObject



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
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/miga/cli/action/classify_wf.rb', line 10

def parse_cli
  default_opts_for_wf
  cli.defaults = {
    download: false, summaries: true, pvalue: 0.1,
    local: File.expand_path('.miga_db', ENV['MIGA_HOME'])
  }
  cli.parse do |opt|
    opt.on(
      '--download-db',
      'Attempt to download the reference database (all default options)',
      'It is recommended to use "miga get_db" separately instead'
    ) { |v| cli[:download] = v }
    opt.on(
      '-n', '--database STRING',
      'Name of the reference database to use',
      'By default, the first locally listed database is used'
    ) { |v| cli[:database] = v.to_sym }
    opt.on(
      '-p', '--p-value FLOAT', Float,
      'Maximum p-value to transfer taxonomy',
      "By default: #{cli[:pvalue]}"
    ) { |v| cli[:pvalue] = v }
    opt.on(
      '-l', '--local-dir PATH',
      "Local directory to store the database. By default: #{cli[:local]}"
    ) { |v| cli[:local] = v }
    opt.on(
      '--db-path STRING',
      'Path to the reference database to use, a fully indexed MiGA project',
      'If defined, --local-dir and --database are ignored'
    ) { |v| cli[:db_path] = v }
    opt.on(
      '--no-summaries',
      'Do not generate intermediate step summaries'
    ) { |v| cli[:summaries] = v }
    opts_for_wf(opt, 'Input genome assemblies (nucleotides, FastA)')
  end
end

#performObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/miga/cli/action/classify_wf.rb', line 49

def perform
  # Input data
  ref_db = reference_db
  norun = %w[
    haai_distances aai_distances ani_distances clade_finding
  ]
   = Hash[norun.map { |i| ["run_#{i}", false] }]
  p = create_project(
    :assembly,
    ,
    run_mytaxa_scan: false, run_distances: false
  )
  p.set_option(:ref_project, ref_db.path)
  p.set_option(:tax_pvalue, cli[:pvalue])

  # Run
  run_daemon
  summarize(%w[cds assembly essential_genes]) if cli[:summaries]
  summarize(%w[taxonomy])
  unless cli[:prepare_and_exit]
    cli.say "Summary: classification"
    ofile = File.expand_path('classification.tsv', cli[:outdir])
    call_cli(['ls', '-P', cli[:outdir], '-m', 'tax', '--tab', '-o', ofile])
  end
  cleanup
end