Class: MiGA::Cli::Action::Doctor

Inherits:
MiGA::Cli::Action show all
Includes:
Base, Databases, Distances, Operations
Defined in:
lib/miga/cli/action/doctor.rb

Defined Under Namespace

Modules: Base, Databases, Distances, Operations

Constant Summary collapse

@@OPERATIONS =
{
  # TODO Implement this check:
  # refdb:  ['ref-db', 'Check index format of reference databases'],
  status: ['status', 'Update metadata status of all datasets'],
  db:     ['databases', 'Check integrity of database files'],
  dist:   ['distances', 'Check distance summary tables'],
  bidir:  ['bidirectional', 'Check distances are bidirectional'],
  files:  ['files', 'Check for outdated files'],
  cds:    ['cds', 'Check for gzipped genes and proteins'],
  ess:    ['essential-genes', 'Check for outdated essential genes'],
  mts:    ['mytaxa-scan', 'Check for unarchived MyTaxa scan'],
  start:  ['start', 'Check for lingering .start files'],
  tax:    ['taxonomy', 'Check for taxonomy consistency (not yet implemented)']
}

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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Operations

#check_cds, #check_ess, #check_files, #check_mts, #check_refdb, #check_start, #check_status, #check_tax

Methods included from Distances

#check_bidir, #check_db, #check_dist, #merge_bidir_tmp, #partial_bidir_tmp

Methods included from Databases

#check_sqlite3_database, #each_database_file

Methods included from Base

#check_dist_eval, #check_dist_fix, #check_dist_recompute, #outdated_fastaai_ess, #read_bidirectional, #run_cmd, #save_bidirectional, #saved_targets

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

Class Method Details

.OPERATIONSObject

All supported operations



66
67
68
# File 'lib/miga/cli/action/doctor.rb', line 66

def OPERATIONS
  @@OPERATIONS
end

Instance Method Details

#parse_cliObject



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
# File 'lib/miga/cli/action/doctor.rb', line 14

def parse_cli
  cli.defaults = { threads: 1 }
  cli.defaults = Hash[@@OPERATIONS.keys.map { |i| [i, true] }]
  cli.parse do |opt|
    operation_n = Hash[@@OPERATIONS.map { |k, v| [v[0], k] }]
    cli.opt_object(opt, [:project])
    opt.on(
      '--ignore TASK1,TASK2', Array,
      'Do not perform the task(s) listed. Available tasks are:',
      * @@OPERATIONS.values.map { |v| "~ #{v[0]}: #{v[1]}" }
    ) { |v| v.map { |i| cli[operation_n[i]] = false } }
    opt.on(
      '--only TASK',
      'Perform only the specified task (see --ignore)'
    ) do |v|
      op_k = @@OPERATIONS.find { |_, i| i[0] == v.downcase }&.first
      op_k or raise "Unknown task: #{v}"
      @@OPERATIONS.each_key { |i| cli[i] = false }
      cli[op_k] = true
    end
    opt.on(
      '-t', '--threads INT', Integer,
      "Concurrent threads to use. By default: #{cli[:threads]}"
    ) { |v| cli[:threads] = v }
  end
end

#performObject



41
42
43
44
45
46
# File 'lib/miga/cli/action/doctor.rb', line 41

def perform
  p = cli.load_project
  @@OPERATIONS.keys.each do |k|
    send("check_#{k}", cli) if cli[k]
  end
end