miga-base 0.7.3.1 → 0.7.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/lib/miga/cli.rb +10 -8
  3. data/lib/miga/cli/action.rb +2 -3
  4. data/lib/miga/cli/action/about.rb +5 -6
  5. data/lib/miga/cli/action/add.rb +18 -12
  6. data/lib/miga/cli/action/add_result.rb +2 -3
  7. data/lib/miga/cli/action/archive.rb +1 -2
  8. data/lib/miga/cli/action/classify_wf.rb +8 -6
  9. data/lib/miga/cli/action/console.rb +0 -1
  10. data/lib/miga/cli/action/daemon.rb +7 -7
  11. data/lib/miga/cli/action/date.rb +0 -1
  12. data/lib/miga/cli/action/derep_wf.rb +5 -4
  13. data/lib/miga/cli/action/doctor.rb +71 -82
  14. data/lib/miga/cli/action/doctor/base.rb +102 -0
  15. data/lib/miga/cli/action/edit.rb +14 -2
  16. data/lib/miga/cli/action/files.rb +8 -8
  17. data/lib/miga/cli/action/find.rb +5 -6
  18. data/lib/miga/cli/action/generic.rb +7 -7
  19. data/lib/miga/cli/action/get.rb +20 -17
  20. data/lib/miga/cli/action/get_db.rb +8 -2
  21. data/lib/miga/cli/action/index_wf.rb +1 -1
  22. data/lib/miga/cli/action/init.rb +53 -41
  23. data/lib/miga/cli/action/init/daemon_helper.rb +65 -43
  24. data/lib/miga/cli/action/lair.rb +7 -7
  25. data/lib/miga/cli/action/ln.rb +6 -6
  26. data/lib/miga/cli/action/ls.rb +1 -2
  27. data/lib/miga/cli/action/ncbi_get.rb +11 -3
  28. data/lib/miga/cli/action/new.rb +4 -4
  29. data/lib/miga/cli/action/next_step.rb +0 -1
  30. data/lib/miga/cli/action/preproc_wf.rb +3 -3
  31. data/lib/miga/cli/action/quality_wf.rb +1 -1
  32. data/lib/miga/cli/action/rm.rb +2 -3
  33. data/lib/miga/cli/action/run.rb +8 -8
  34. data/lib/miga/cli/action/stats.rb +8 -4
  35. data/lib/miga/cli/action/summary.rb +7 -6
  36. data/lib/miga/cli/action/tax_dist.rb +8 -4
  37. data/lib/miga/cli/action/tax_index.rb +3 -4
  38. data/lib/miga/cli/action/tax_set.rb +7 -6
  39. data/lib/miga/cli/action/tax_test.rb +6 -5
  40. data/lib/miga/cli/action/wf.rb +25 -19
  41. data/lib/miga/cli/base.rb +34 -32
  42. data/lib/miga/cli/objects_helper.rb +27 -18
  43. data/lib/miga/cli/opt_helper.rb +3 -2
  44. data/lib/miga/common.rb +2 -5
  45. data/lib/miga/common/base.rb +15 -16
  46. data/lib/miga/common/format.rb +8 -5
  47. data/lib/miga/common/hooks.rb +1 -4
  48. data/lib/miga/common/path.rb +4 -9
  49. data/lib/miga/common/with_daemon.rb +5 -2
  50. data/lib/miga/common/with_daemon_class.rb +1 -1
  51. data/lib/miga/common/with_result.rb +2 -1
  52. data/lib/miga/daemon.rb +93 -44
  53. data/lib/miga/daemon/base.rb +30 -11
  54. data/lib/miga/dataset.rb +47 -37
  55. data/lib/miga/dataset/base.rb +52 -37
  56. data/lib/miga/dataset/hooks.rb +3 -4
  57. data/lib/miga/dataset/result.rb +17 -1
  58. data/lib/miga/dataset/status.rb +6 -5
  59. data/lib/miga/json.rb +5 -7
  60. data/lib/miga/lair.rb +4 -0
  61. data/lib/miga/metadata.rb +4 -3
  62. data/lib/miga/project.rb +29 -20
  63. data/lib/miga/project/base.rb +52 -37
  64. data/lib/miga/project/dataset.rb +33 -26
  65. data/lib/miga/project/hooks.rb +0 -3
  66. data/lib/miga/project/result.rb +14 -5
  67. data/lib/miga/remote_dataset.rb +85 -72
  68. data/lib/miga/remote_dataset/base.rb +11 -13
  69. data/lib/miga/remote_dataset/download.rb +34 -12
  70. data/lib/miga/result.rb +48 -53
  71. data/lib/miga/result/base.rb +0 -2
  72. data/lib/miga/result/dates.rb +1 -3
  73. data/lib/miga/result/source.rb +15 -16
  74. data/lib/miga/result/stats.rb +37 -27
  75. data/lib/miga/tax_dist.rb +6 -3
  76. data/lib/miga/tax_index.rb +17 -17
  77. data/lib/miga/taxonomy.rb +6 -1
  78. data/lib/miga/taxonomy/base.rb +19 -15
  79. data/lib/miga/version.rb +19 -16
  80. data/scripts/project_stats.bash +3 -0
  81. data/scripts/stats.bash +1 -1
  82. data/test/common_test.rb +3 -11
  83. data/test/daemon_helper.rb +38 -0
  84. data/test/daemon_test.rb +91 -99
  85. data/test/dataset_test.rb +63 -59
  86. data/test/format_test.rb +3 -11
  87. data/test/hook_test.rb +50 -55
  88. data/test/json_test.rb +7 -8
  89. data/test/lair_test.rb +22 -28
  90. data/test/metadata_test.rb +6 -14
  91. data/test/project_test.rb +33 -40
  92. data/test/remote_dataset_test.rb +26 -32
  93. data/test/result_stats_test.rb +17 -27
  94. data/test/result_test.rb +41 -34
  95. data/test/tax_dist_test.rb +2 -4
  96. data/test/tax_index_test.rb +4 -10
  97. data/test/taxonomy_test.rb +7 -9
  98. data/test/test_helper.rb +42 -1
  99. data/test/with_daemon_test.rb +14 -22
  100. data/utils/adapters.fa +13 -0
  101. data/utils/cleanup-databases.rb +6 -5
  102. data/utils/distance/base.rb +0 -1
  103. data/utils/distance/commands.rb +19 -12
  104. data/utils/distance/database.rb +24 -21
  105. data/utils/distance/pipeline.rb +23 -10
  106. data/utils/distance/runner.rb +20 -16
  107. data/utils/distance/temporal.rb +1 -3
  108. data/utils/distances.rb +1 -1
  109. data/utils/domain-ess-genes.rb +7 -7
  110. data/utils/index_metadata.rb +5 -4
  111. data/utils/mytaxa_scan.rb +18 -16
  112. data/utils/representatives.rb +5 -4
  113. data/utils/requirements.txt +1 -1
  114. data/utils/subclade/base.rb +0 -1
  115. data/utils/subclade/pipeline.rb +7 -6
  116. data/utils/subclade/runner.rb +9 -9
  117. data/utils/subclade/temporal.rb +0 -2
  118. data/utils/subclades-compile.rb +39 -37
  119. data/utils/subclades.rb +1 -1
  120. metadata +6 -4
@@ -5,7 +5,6 @@ require 'miga/cli/action'
5
5
  require 'shellwords'
6
6
 
7
7
  class MiGA::Cli::Action::Run < MiGA::Cli::Action
8
-
9
8
  def parse_cli
10
9
  cli.defaults = { try_load: false, thr: 1, env: false }
11
10
  cli.parse do |opt|
@@ -38,20 +37,20 @@ class MiGA::Cli::Action::Run < MiGA::Cli::Action
38
37
  cli[:thr] ||= ENV['CORES'].to_i unless ENV['CORES'].nil?
39
38
  cli[:result] = File.basename(cli[:result].to_s, '.bash').to_sym
40
39
  end
41
-
40
+
42
41
  # Unset dataset if the requested result is for projects
43
42
  if (MiGA::Project.RESULT_DIRS.keys + [:p]).include? cli[:result]
44
43
  cli[:dataset] = nil
45
44
  end
46
-
45
+
47
46
  # Load project
48
47
  p = cli.load_project
49
-
48
+
50
49
  # Prepare command
51
50
  miga = MiGA.root_path
52
51
  cmd = ["PROJECT=#{p.path.shellescape}",
53
- "RUNTYPE=#{cli[:remote] ? 'ssh' : 'bash'}",
54
- "MIGA=#{miga.shellescape}", "CORES=#{cli[:thr]}"]
52
+ "RUNTYPE=#{cli[:remote] ? 'ssh' : 'bash'}",
53
+ "MIGA=#{miga.shellescape}", "CORES=#{cli[:thr]}"]
55
54
  obj = cli.load_project_or_dataset
56
55
  klass = obj.class
57
56
  virtual_task = [:p, :d].include?(cli[:result])
@@ -59,13 +58,14 @@ class MiGA::Cli::Action::Run < MiGA::Cli::Action
59
58
  if klass.RESULT_DIRS[cli[:result]].nil? and not virtual_task
60
59
  raise "Unsupported #{klass.to_s.sub(/.*::/, '')} result: #{cli[:result]}."
61
60
  end
61
+
62
62
  cmd << MiGA.script_path(cli[:result], miga: miga, project: p).shellescape
63
63
  if cli[:remote]
64
64
  cmd = ['ssh', '-t', '-t', cli[:remote].shellescape,
65
- cmd.join(' ').shellescape]
65
+ cmd.join(' ').shellescape]
66
66
  end
67
67
  cmd << ['>', cli[:log].shellescape, '2>&1'] if cli[:log]
68
-
68
+
69
69
  # Launch
70
70
  pid = spawn cmd.join(' ')
71
71
  Process.wait pid
@@ -4,7 +4,6 @@
4
4
  require 'miga/cli/action'
5
5
 
6
6
  class MiGA::Cli::Action::Stats < MiGA::Cli::Action
7
-
8
7
  def parse_cli
9
8
  cli.defaults = { try_load: false }
10
9
  cli.parse do |opt|
@@ -21,13 +20,18 @@ class MiGA::Cli::Action::Stats < MiGA::Cli::Action
21
20
  '--try-load',
22
21
  'Check if stat exists instead of computing on --compute-and-save'
23
22
  ) { |v| cli[:try_load] = v }
23
+ opt.on(
24
+ '--ignore-empty',
25
+ 'If the result does not exist, exit without throwing exceptions'
26
+ ) { |v| cli[:ignore_result_empty] = v }
24
27
  end
25
28
  end
26
29
 
27
30
  def perform
28
- cli[:compute] = false if cli[:try_load] and
29
- (not r[:stats].nil?) and (not r[:stats].empty?)
30
- r = cli.load_result
31
+ if cli[:try_load] && !r[:stats].nil? && !r[:stats].empty?
32
+ cli[:compute] = false
33
+ end
34
+ r = cli.load_result or return
31
35
  if cli[:compute]
32
36
  cli.say 'Computing statistics'
33
37
  r.compute_stats
@@ -4,9 +4,8 @@
4
4
  require 'miga/cli/action'
5
5
 
6
6
  class MiGA::Cli::Action::Summary < MiGA::Cli::Action
7
-
8
7
  def parse_cli
9
- cli.defaults = {units: false, tabular: false}
8
+ cli.defaults = { units: false, tabular: false }
10
9
  cli.parse do |opt|
11
10
  cli.opt_object(opt, [:project, :dataset_opt])
12
11
  cli.opt_filter_datasets(opt)
@@ -37,7 +36,7 @@ class MiGA::Cli::Action::Summary < MiGA::Cli::Action
37
36
  stats = ds.map do |d|
38
37
  r = d.add_result(cli[:result].to_sym, false)
39
38
  s = r.nil? ? {} : r[:stats]
40
- s.tap{ |i| i[:dataset] = d.name }
39
+ s.tap { |i| i[:dataset] = d.name }
41
40
  end
42
41
  keys = cli[:key_md].nil? ? stats.map(&:keys).flatten.uniq :
43
42
  [:dataset, cli[:key_md].downcase.miga_name.to_sym]
@@ -45,9 +44,11 @@ class MiGA::Cli::Action::Summary < MiGA::Cli::Action
45
44
  keys.unshift :dataset
46
45
 
47
46
  table = cli[:units] ?
48
- stats.map{ |s| keys.
49
- map{ |k| s[k].is_a?(Array) ? s[k].map(&:to_s).join('') : s[k] } } :
50
- stats.map{ |s| keys.map{ |k| s[k].is_a?(Array) ? s[k].first : s[k] } }
47
+ stats.map { |s|
48
+ keys
49
+ .map { |k| s[k].is_a?(Array) ? s[k].map(&:to_s).join('') : s[k] }
50
+ } :
51
+ stats.map { |s| keys.map { |k| s[k].is_a?(Array) ? s[k].first : s[k] } }
51
52
  io = cli[:output].nil? ? $stdout : File.open(cli[:output], 'w')
52
53
  cli.puts(io, MiGA.tabulate(keys, table, cli[:tabular]))
53
54
  io.close unless cli[:output].nil?
@@ -7,7 +7,6 @@ require 'zlib'
7
7
  require 'tmpdir'
8
8
 
9
9
  class MiGA::Cli::Action::TaxDist < MiGA::Cli::Action
10
-
11
10
  def parse_cli
12
11
  cli.parse do |opt|
13
12
  cli.opt_object(opt, [:project])
@@ -49,17 +48,20 @@ class MiGA::Cli::Action::TaxDist < MiGA::Cli::Action
49
48
  def read_distances
50
49
  p = cli.load_project
51
50
  cli[:metric] ||= p.is_clade? ? 'ani' : 'aai'
52
- res_n = "#{cli[:metric]}_distances"
51
+ res_n = "#{cli[:metric]}_distances"
53
52
  cli.say "Reading distances: 1-#{cli[:metric].upcase}"
54
53
  res = p.result(res_n)
55
54
  raise "#{res_n} not yet calculated" if res.nil?
55
+
56
56
  matrix = res.file_path(:matrix)
57
57
  raise "#{res_n} has no matrix" if matrix.nil?
58
+
58
59
  dist = {}
59
60
  mfh = (matrix =~ /\.gz$/) ?
60
61
  Zlib::GzipReader.open(matrix) : File.open(matrix, 'r')
61
62
  mfh.each_line do |ln|
62
63
  next if mfh.lineno == 1
64
+
63
65
  row = ln.chomp.split("\t")
64
66
  dist[cannid(row[1], row[2])] = [row[3], row[5], row[6], 0, ['root:biota']]
65
67
  cli.advance('Lines:', mfh.lineno, nil, false) if (mfh.lineno % 1_000) == 0
@@ -90,16 +92,17 @@ class MiGA::Cli::Action::TaxDist < MiGA::Cli::Action
90
92
  rank_i = 0
91
93
  Taxonomy.KNOWN_RANKS.each do |rank|
92
94
  next if rank == :ns
95
+
93
96
  rank_n = 0
94
97
  rank_i += 1
95
98
  in_rank = nil
96
99
  ds_name = []
97
100
  File.open(tab, 'r') do |fh|
98
101
  fh.each_line do |ln|
99
- if ln =~ /^ {#{(rank_i-1)*2}}\S+:\S+:/
102
+ if ln =~ /^ {#{(rank_i - 1) * 2}}\S+:\S+:/
100
103
  in_rank = nil
101
104
  ds_name = []
102
- elsif ln =~ /^ {#{rank_i*2}}(#{rank}:(\S+)):/
105
+ elsif ln =~ /^ {#{rank_i * 2}}(#{rank}:(\S+)):/
103
106
  in_rank = $2 == '?' ? nil : $1
104
107
  ds_name = []
105
108
  elsif ln =~ /^ *# (\S+)/ and not in_rank.nil?
@@ -108,6 +111,7 @@ class MiGA::Cli::Action::TaxDist < MiGA::Cli::Action
108
111
  ds_name.each do |ds_j|
109
112
  k = cannid(ds_i, ds_j)
110
113
  next if dist[k].nil?
114
+
111
115
  rank_n += 1
112
116
  dist[k][3] = rank_i
113
117
  dist[k][4].unshift in_rank
@@ -5,20 +5,19 @@ require 'miga/cli/action'
5
5
  require 'miga/tax_index'
6
6
 
7
7
  class MiGA::Cli::Action::TaxIndex < MiGA::Cli::Action
8
-
9
8
  def parse_cli
10
- cli.defaults = {format: :json}
9
+ cli.defaults = { format: :json }
11
10
  cli.parse do |opt|
12
11
  cli.opt_object(opt, [:project])
13
12
  opt.on(
14
13
  '-i', '--index PATH',
15
14
  '(Mandatory) File to create with the index'
16
- ){ |v| cli[:index] = v }
15
+ ) { |v| cli[:index] = v }
17
16
  opt.on(
18
17
  '-f', '--format STRING',
19
18
  "Format of the index file, by default: #{cli[:format]}",
20
19
  'Supported: json, tab.'
21
- ){ |v| cli[:format] = v.downcase.to_sym }
20
+ ) { |v| cli[:format] = v.downcase.to_sym }
22
21
  cli.opt_filter_datasets(opt)
23
22
  end
24
23
  end
@@ -4,7 +4,6 @@
4
4
  require 'miga/cli/action'
5
5
 
6
6
  class MiGA::Cli::Action::TaxSet < MiGA::Cli::Action
7
-
8
7
  def parse_cli
9
8
  cli.parse do |opt|
10
9
  cli.opt_object(opt, [:project, :dataset_opt])
@@ -12,14 +11,15 @@ class MiGA::Cli::Action::TaxSet < MiGA::Cli::Action
12
11
  '-s', '--tax-string STRING',
13
12
  'String corresponding to the taxonomy of the dataset',
14
13
  'A space-delimited set of \'rank:name\' pairs'
15
- ){ |v| cli[:taxstring] = v }
16
- opt.on('-t', '--tax-file PATH',
14
+ ) { |v| cli[:taxstring] = v }
15
+ opt.on(
16
+ '-t', '--tax-file PATH',
17
17
  '(Mandatory unless -D and -s are provided)',
18
18
  'Tab-delimited file containing datasets taxonomy',
19
19
  'Each row corresponds to a datasets and each column to a rank',
20
20
  'The first row must be a header with the rank names,',
21
21
  'and the first column must contain dataset names'
22
- ){ |v| cli[:taxfile] = v }
22
+ ) { |v| cli[:taxfile] = v }
23
23
  end
24
24
  end
25
25
 
@@ -31,6 +31,7 @@ class MiGA::Cli::Action::TaxSet < MiGA::Cli::Action
31
31
  header = nil
32
32
  tfh.each_line do |ln|
33
33
  next if ln =~ /^\s*?$/
34
+
34
35
  r = ln.chomp.split(/\t/, -1)
35
36
  dn = r.shift
36
37
  if header.nil?
@@ -48,8 +49,8 @@ class MiGA::Cli::Action::TaxSet < MiGA::Cli::Action
48
49
  end
49
50
  tfh.close
50
51
  else
51
- cli.ensure_par({dataset: '-D', taxstring: '-s'},
52
- '%<flag>s is mandatory unless -t is provided')
52
+ cli.ensure_par({ dataset: '-D', taxstring: '-s' },
53
+ '%<flag>s is mandatory unless -t is provided')
53
54
  cli.say 'Registering taxonomy'
54
55
  d = cli.load_dataset
55
56
  d.metadata[:tax] = Taxonomy.new(cli[:taxstring])
@@ -5,19 +5,18 @@ require 'miga/cli/action'
5
5
  require 'miga/tax_dist'
6
6
 
7
7
  class MiGA::Cli::Action::TaxTest < MiGA::Cli::Action
8
-
9
8
  def parse_cli
10
- cli.defaults = {test: 'both', ref_project: false}
9
+ cli.defaults = { test: 'both', ref_project: false }
11
10
  cli.parse do |opt|
12
11
  cli.opt_object(opt, [:project, :dataset])
13
12
  opt.on(
14
13
  '--ref-project',
15
14
  'Use the taxonomy from the reference project, not the current project'
16
- ){ |v| cli[:ref_project] = v }
15
+ ) { |v| cli[:ref_project] = v }
17
16
  opt.on(
18
17
  '-t', '--test STRING',
19
18
  'Test to perform. Supported values: intax, novel, both'
20
- ){ |v| cli[:test] = v.downcase }
19
+ ) { |v| cli[:test] = v.downcase }
21
20
  end
22
21
  end
23
22
 
@@ -27,6 +26,7 @@ class MiGA::Cli::Action::TaxTest < MiGA::Cli::Action
27
26
  cr = d.closest_relatives(1, cli[:ref_project])
28
27
  if cr.nil? or cr.empty?
29
28
  raise 'Action not supported for the project or dataset' if cr.nil?
29
+
30
30
  raise 'No close relatives found'
31
31
  else
32
32
  query_probability_distributions(d, cr[0])
@@ -65,6 +65,7 @@ class MiGA::Cli::Action::TaxTest < MiGA::Cli::Action
65
65
  if (q = MiGA::Project.load(ref)).nil?
66
66
  raise '--ref-project requested but reference project doesn\'t exist'
67
67
  end
68
+
68
69
  cr_d = q.dataset(cr[0])
69
70
  else
70
71
  cr_d = p.dataset(cr[0])
@@ -75,7 +76,7 @@ class MiGA::Cli::Action::TaxTest < MiGA::Cli::Action
75
76
  end
76
77
 
77
78
  def test_closest_relative(cr, tax, test)
78
- TaxDist.aai_pvalues(cr[1], test).map do |k,v|
79
+ TaxDist.aai_pvalues(cr[1], test).map do |k, v|
79
80
  sig = ''
80
81
  [0.5, 0.1, 0.05, 0.01].each { |i| sig << '*' if v < i }
81
82
  [Taxonomy.LONG_RANKS[k], (tax[k] || '?'), v, sig]
@@ -9,7 +9,8 @@ module MiGA::Cli::Action::Wf
9
9
  cli.defaults = {
10
10
  clean: false, regexp: MiGA::Cli.FILE_REGEXP,
11
11
  project_type: :genomes, dataset_type: :popgenome,
12
- ncbi_draft: true }
12
+ ncbi_draft: true
13
+ }
13
14
  end
14
15
 
15
16
  def opts_for_wf(opt, files_desc, params = {})
@@ -88,6 +89,10 @@ module MiGA::Cli::Action::Wf
88
89
  end
89
90
 
90
91
  def opts_for_wf_distances(opt)
92
+ opt.on('--sensitive', 'Alias to: --aai-p blast+ --ani-p blast+') do
93
+ cli[:aai_p] = 'blast+'
94
+ cli[:ani_p] = 'blast+'
95
+ end
91
96
  opt.on('--fast', 'Alias to: --aai-p diamond --ani-p fastani') do
92
97
  cli[:aai_p] = 'diamond'
93
98
  cli[:ani_p] = 'fastani'
@@ -110,13 +115,14 @@ module MiGA::Cli::Action::Wf
110
115
  cli.ensure_par(
111
116
  outdir: '-o',
112
117
  project_type: '--project-type',
113
- dataset_type: '--dataset-type')
118
+ dataset_type: '--dataset-type'
119
+ )
114
120
  # Create empty project
115
121
  call_cli([
116
- 'new',
117
- '-P', cli[:outdir],
118
- '-t', cli[:project_type]
119
- ]) unless MiGA::Project.exist? cli[:outdir]
122
+ 'new',
123
+ '-P', cli[:outdir],
124
+ '-t', cli[:project_type]
125
+ ]) unless MiGA::Project.exist? cli[:outdir]
120
126
  # Define project metadata
121
127
  p = cli.load_project(:outdir, '-o')
122
128
  [:haai_p, :aai_p, :ani_p, :ess_coll].each { |i| p_metadata[i] = cli[i] }
@@ -124,11 +130,11 @@ module MiGA::Cli::Action::Wf
124
130
  transfer_metadata(p, p_metadata)
125
131
  # Download datasets
126
132
  call_cli([
127
- 'ncbi_get',
128
- '-P', cli[:outdir],
129
- '-T', cli[:ncbi_taxon],
130
- (cli[:ncbi_draft] ? '--all' : '--complete')
131
- ]) unless cli[:ncbi_taxon].nil?
133
+ 'ncbi_get',
134
+ '-P', cli[:outdir],
135
+ '-T', cli[:ncbi_taxon],
136
+ (cli[:ncbi_draft] ? '--all' : '--complete')
137
+ ]) unless cli[:ncbi_taxon].nil?
132
138
  # Add datasets
133
139
  call_cli([
134
140
  'add',
@@ -149,17 +155,18 @@ module MiGA::Cli::Action::Wf
149
155
  which.each do |r|
150
156
  cli.say "Summary: #{r}"
151
157
  call_cli([
152
- 'summary',
153
- '-P', cli[:outdir],
154
- '-r', r,
155
- '-o', File.expand_path("#{r}.tsv", cli[:outdir]),
156
- '--tab'
157
- ])
158
+ 'summary',
159
+ '-P', cli[:outdir],
160
+ '-r', r,
161
+ '-o', File.expand_path("#{r}.tsv", cli[:outdir]),
162
+ '--tab'
163
+ ])
158
164
  end
159
165
  end
160
166
 
161
167
  def cleanup
162
168
  return unless cli[:clean]
169
+
163
170
  cli.say 'Cleaning up intermediate files'
164
171
  %w[data daemon metadata miga.project.json].each do |f|
165
172
  FileUtils.rm_rf(File.expand_path(f, cli[:outdir]))
@@ -184,12 +191,11 @@ module MiGA::Cli::Action::Wf
184
191
 
185
192
  def transfer_metadata(obj, md)
186
193
  # Clear old metadata
187
- obj.metadata.each do |k,v|
194
+ obj.metadata.each do |k, v|
188
195
  obj.metadata[k] = nil if k.to_s =~ /^run_/ || k == :ref_project
189
196
  end
190
197
  # Transfer and save
191
198
  md.each { |k, v| obj.metadata[k] = v }
192
199
  obj.save
193
200
  end
194
-
195
201
  end
@@ -2,46 +2,45 @@
2
2
  # @license Artistic-2.0
3
3
 
4
4
  module MiGA::Cli::Base
5
-
6
5
  @@TASK_DESC = {
7
- generic: 'MiGA: The Microbial Genomes Atlas',
6
+ generic: 'MiGA: The Microbial Genomes Atlas',
8
7
  # Workflows
9
- quality_wf: 'Evaluate the quality of input genomes',
10
- derep_wf: 'Dereplicate a collection of input genomes',
8
+ quality_wf: 'Evaluate the quality of input genomes',
9
+ derep_wf: 'Dereplicate a collection of input genomes',
11
10
  classify_wf: 'Classify input genomes against a reference database',
12
- preproc_wf: 'Preprocess input genomes or metagenomes',
13
- index_wf: 'Generate distance indexing of input genomes',
11
+ preproc_wf: 'Preprocess input genomes or metagenomes',
12
+ index_wf: 'Generate distance indexing of input genomes',
14
13
  # Projects
15
- new: 'Creates an empty MiGA project',
16
- about: 'Displays information about a MiGA project',
17
- doctor: 'Performs consistency checks on a MiGA project',
18
- get_db: 'Downloads a pre-indexed database',
14
+ new: 'Creates an empty MiGA project',
15
+ about: 'Displays information about a MiGA project',
16
+ doctor: 'Performs consistency checks on a MiGA project',
17
+ get_db: 'Downloads a pre-indexed database',
19
18
  # Datasets
20
- add: 'Creates a dataset in a MiGA project',
21
- get: 'Downloads a dataset from public databases into a MiGA project',
19
+ add: 'Creates a dataset in a MiGA project',
20
+ get: 'Downloads a dataset from public databases into a MiGA project',
22
21
  ncbi_get: 'Downloads all genomes in a taxon from NCBI into a MiGA project',
23
- rm: 'Removes a dataset from an MiGA project',
24
- find: 'Finds unregistered datasets based on result files',
25
- ln: 'Link datasets (including results) from one project to another',
26
- ls: 'Lists all registered datasets in an MiGA project',
27
- archive: 'Generates a tar-ball with all files from select datasets',
22
+ rm: 'Removes a dataset from an MiGA project',
23
+ find: 'Finds unregistered datasets based on result files',
24
+ ln: 'Link datasets (including results) from one project to another',
25
+ ls: 'Lists all registered datasets in an MiGA project',
26
+ archive: 'Generates a tar-ball with all files from select datasets',
28
27
  # Results
29
28
  add_result: 'Registers a result',
30
- stats: 'Extracts statistics for the given result',
31
- files: 'Lists registered files from the results of a dataset or project',
32
- run: 'Executes locally one step analysis producing the given result',
33
- summary: 'Generates a summary table for the statistics of all datasets',
29
+ stats: 'Extracts statistics for the given result',
30
+ files: 'Lists registered files from the results of a dataset or project',
31
+ run: 'Executes locally one step analysis producing the given result',
32
+ summary: 'Generates a summary table for the statistics of all datasets',
34
33
  next_step: 'Returns the next task to run in a dataset or project',
35
34
  # Objects (Datasets or Projects)
36
- edit: 'Edits the metadata of a dataset or project',
35
+ edit: 'Edits the metadata of a dataset or project',
37
36
  # System
38
- init: 'Initialize MiGA to process new projects',
39
- daemon: 'Controls the daemon of a MiGA project',
40
- lair: 'Controls groups of daemons for several MiGA projects',
41
- date: 'Returns the current date in standard MiGA format',
42
- console: 'Opens an IRB console with MiGA',
37
+ init: 'Initialize MiGA to process new projects',
38
+ daemon: 'Controls the daemon of a MiGA project',
39
+ lair: 'Controls groups of daemons for several MiGA projects',
40
+ date: 'Returns the current date in standard MiGA format',
41
+ console: 'Opens an IRB console with MiGA',
43
42
  # Taxonomy
44
- tax_set: 'Registers taxonomic information for datasets',
43
+ tax_set: 'Registers taxonomic information for datasets',
45
44
  tax_test: 'Returns test of taxonomic distributions for query datasets',
46
45
  tax_index: 'Creates a taxonomy-indexed list of the datasets',
47
46
  tax_dist: 'Estimates distributions of distance by taxonomy',
@@ -77,7 +76,8 @@ module MiGA::Cli::Base
77
76
  }
78
77
 
79
78
  @@TASK_ALIAS.each do |nick, task|
80
- @@TASK_DESC[task] = ((@@TASK_DESC[task] =~ /\(alias: .*\)\./) ?
79
+ @@TASK_DESC[task] = (
80
+ (@@TASK_DESC[task] =~ /\(alias: .*\)\./) ?
81
81
  @@TASK_DESC[task].sub(/\)\.$/, ", #{nick}).") :
82
82
  @@TASK_DESC[task].sub(/\.$/, " (alias: #{nick}).")
83
83
  )
@@ -85,18 +85,20 @@ module MiGA::Cli::Base
85
85
 
86
86
  @@EXECS = @@TASK_DESC.keys
87
87
 
88
- @@FILE_REGEXP = %r{^(?:.*/)?(.+?)(\.[A-Z]*([12]|Reads|Contigs))?(\.f[nastq]+)?$}i
89
-
88
+ @@FILE_REGEXP =
89
+ %r{^(?:.*/)?(.+?)(\.[A-Z]*([12]|Reads|Contigs))?(\.f[nastq]+)?$}i
90
90
  end
91
91
 
92
92
  class MiGA::Cli < MiGA::MiGA
93
-
94
93
  include MiGA::Cli::Base
95
94
 
96
95
  class << self
97
96
  def TASK_DESC; @@TASK_DESC end
97
+
98
98
  def TASK_ALIAS; @@TASK_ALIAS end
99
+
99
100
  def EXECS; @@EXECS end
101
+
100
102
  def FILE_REGEXP; @@FILE_REGEXP end
101
103
  end
102
104
  end