Module: MiGA::Cli::Action::Doctor::Operations
- Included in:
- MiGA::Cli::Action::Doctor
- Defined in:
- lib/miga/cli/action/doctor/operations.rb
Instance Method Summary collapse
-
#check_cds(cli) ⇒ Object
Perform cds operation with MiGA::Cli
cli
. -
#check_ess(cli) ⇒ Object
Perform essential-genes operation with MiGA::Cli
cli
. -
#check_files(cli) ⇒ Object
Perform files operation with MiGA::Cli
cli
. -
#check_mts(cli) ⇒ Object
Perform mytaxa-scan operation with MiGA::Cli
cli
. -
#check_start(cli) ⇒ Object
Perform start operation with MiGA::Cli
cli
. -
#check_status(cli) ⇒ Object
Perform status operation with MiGA::Cli
cli
. -
#check_tax(cli) ⇒ Object
Perform taxonomy operation with MiGA::Cli
cli
.
Instance Method Details
#check_cds(cli) ⇒ Object
Perform cds operation with MiGA::Cli cli
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/miga/cli/action/doctor/operations.rb', line 56 def check_cds(cli) cli.say 'Looking for unzipped genes or proteins' n, k = cli.load_project.dataset_names.size, 0 cli.load_project.each_dataset do |d| cli.advance('Datasets:', k += 1, n, false) res = d.result(:cds) or next changed = false %i[genes proteins gff3 gff2 tab].each do |f| file = res.file_path(f) or next if file !~ /\.gz/ cli.say " > Gzipping #{d.name} #{f} " run_cmd(['gzip', '-9', file]) changed = true end end if changed d.add_result(:cds, true, force: true) sr = d.result(:stats) and sr.remove! end end cli.say end |
#check_ess(cli) ⇒ Object
Perform essential-genes operation with MiGA::Cli cli
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/miga/cli/action/doctor/operations.rb', line 81 def check_ess(cli) cli.say 'Looking for outdated essential genes' cli.load_project.each_dataset do |d| res = d.result(:essential_genes) next if res.nil? dir = res.file_path(:collection) if dir.nil? || outdated_fastaai_ess(res) cli.say " > Removing #{d.name}:essential_genes" res.remove! d.result(:stats)&.remove! next end next if Dir["#{dir}/*.faa"].empty? cli.say " > Fixing #{d.name}" run_cmd <<~CMD cd #{dir.shellescape} && tar -zcf proteins.tar.gz *.faa && rm *.faa CMD end end |
#check_files(cli) ⇒ Object
Perform files operation with MiGA::Cli cli
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/miga/cli/action/doctor/operations.rb', line 31 def check_files(cli) cli.say 'Looking for outdated files in results' n, k = cli.load_project.dataset_names.size, 0 cli.load_project.each_dataset do |d| cli.advance('Datasets:', k += 1, n, false) d.each_result do |r_k, r| ok = true r.each_file do |_f_sym, _f_rel, f_abs| unless File.exist? f_abs ok = false break end end unless ok cli.say " > Registering again #{d.name}:#{r_k} " d.add_result(r_k, true, force: true) sr = d.result(:stats) and sr.remove! end end end cli.say end |
#check_mts(cli) ⇒ Object
Perform mytaxa-scan operation with MiGA::Cli cli
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/miga/cli/action/doctor/operations.rb', line 105 def check_mts(cli) cli.say 'Looking for unarchived MyTaxa Scan runs' cli.load_project.each_dataset do |d| res = d.result(:mytaxa_scan) next if res.nil? dir = res.file_path(:regions) fix = false unless dir.nil? if Dir.exist? dir run_cmd <<~CMD cd #{dir.shellescape}/.. \ && tar -zcf '#{d.name}.reg.tar.gz' '#{d.name}.reg' \ && rm -r '#{d.name}.reg' CMD end fix = true end %i[blast mytaxain wintax gene_ids region_ids].each do |ext| file = res.file_path(ext) unless file.nil? FileUtils.rm(file) if File.exist? file fix = true end end if fix cli.say " > Fixing #{d.name}" d.add_result(:mytaxa_scan, true, force: true) end end end |
#check_start(cli) ⇒ Object
Perform start operation with MiGA::Cli cli
139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/miga/cli/action/doctor/operations.rb', line 139 def check_start(cli) cli.say 'Looking for legacy .start files lingering' cli.load_project.each_dataset do |d| d.each_result do |r_k, r| if File.exist? r.path(:start) cli.say " > Registering again #{d.name}:#{r_k}" r.save end end end end |
#check_status(cli) ⇒ Object
Perform status operation with MiGA::Cli cli
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/miga/cli/action/doctor/operations.rb', line 5 def check_status(cli) cli.say 'Updating metadata status' p = cli.load_project n = p.dataset_names.size (0 .. cli[:threads] - 1).map do |i| Process.fork do k = 0 cli.load_project.each_dataset do |d| k += 1 cli.advance('Datasets:', k, n, false) if i == 0 d.recalculate_status if k % cli[:threads] == i end end end Process.waitall cli.say end |
#check_tax(cli) ⇒ Object
Perform taxonomy operation with MiGA::Cli cli
153 154 155 156 157 158 |
# File 'lib/miga/cli/action/doctor/operations.rb', line 153 def check_tax(cli) # cli.say 'o Checking for taxonomy/distances consistency' # TODO: Find 95%ANI clusters with entries from different species # TODO: Find different 95%ANI clusters with genomes from the same species # TODO: Find AAI values too high or too low for each LCA rank end |