miga-base 0.7.4.0 → 0.7.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/miga/cli.rb +10 -8
- data/lib/miga/cli/action.rb +2 -3
- data/lib/miga/cli/action/about.rb +5 -6
- data/lib/miga/cli/action/add.rb +18 -12
- data/lib/miga/cli/action/add_result.rb +2 -3
- data/lib/miga/cli/action/archive.rb +1 -2
- data/lib/miga/cli/action/classify_wf.rb +8 -6
- data/lib/miga/cli/action/console.rb +0 -1
- data/lib/miga/cli/action/daemon.rb +7 -7
- data/lib/miga/cli/action/date.rb +0 -1
- data/lib/miga/cli/action/derep_wf.rb +5 -4
- data/lib/miga/cli/action/doctor.rb +28 -20
- data/lib/miga/cli/action/doctor/base.rb +29 -6
- data/lib/miga/cli/action/edit.rb +1 -2
- data/lib/miga/cli/action/files.rb +8 -8
- data/lib/miga/cli/action/find.rb +5 -6
- data/lib/miga/cli/action/generic.rb +7 -7
- data/lib/miga/cli/action/get.rb +20 -17
- data/lib/miga/cli/action/get_db.rb +8 -2
- data/lib/miga/cli/action/index_wf.rb +1 -1
- data/lib/miga/cli/action/init.rb +53 -41
- data/lib/miga/cli/action/init/daemon_helper.rb +65 -43
- data/lib/miga/cli/action/lair.rb +7 -7
- data/lib/miga/cli/action/ln.rb +6 -6
- data/lib/miga/cli/action/ls.rb +1 -2
- data/lib/miga/cli/action/ncbi_get.rb +11 -3
- data/lib/miga/cli/action/new.rb +4 -4
- data/lib/miga/cli/action/next_step.rb +0 -1
- data/lib/miga/cli/action/preproc_wf.rb +3 -3
- data/lib/miga/cli/action/quality_wf.rb +1 -1
- data/lib/miga/cli/action/rm.rb +2 -3
- data/lib/miga/cli/action/run.rb +8 -8
- data/lib/miga/cli/action/stats.rb +9 -5
- data/lib/miga/cli/action/summary.rb +13 -7
- data/lib/miga/cli/action/tax_dist.rb +8 -4
- data/lib/miga/cli/action/tax_index.rb +3 -4
- data/lib/miga/cli/action/tax_set.rb +7 -6
- data/lib/miga/cli/action/tax_test.rb +6 -5
- data/lib/miga/cli/action/wf.rb +25 -19
- data/lib/miga/cli/base.rb +34 -32
- data/lib/miga/cli/objects_helper.rb +27 -18
- data/lib/miga/cli/opt_helper.rb +3 -2
- data/lib/miga/common.rb +2 -5
- data/lib/miga/common/base.rb +15 -16
- data/lib/miga/common/format.rb +11 -6
- data/lib/miga/common/hooks.rb +1 -4
- data/lib/miga/common/path.rb +4 -9
- data/lib/miga/common/with_daemon.rb +5 -2
- data/lib/miga/common/with_daemon_class.rb +1 -1
- data/lib/miga/common/with_result.rb +2 -1
- data/lib/miga/daemon.rb +51 -35
- data/lib/miga/daemon/base.rb +0 -2
- data/lib/miga/dataset.rb +47 -37
- data/lib/miga/dataset/base.rb +52 -37
- data/lib/miga/dataset/hooks.rb +3 -4
- data/lib/miga/dataset/result.rb +17 -1
- data/lib/miga/json.rb +5 -7
- data/lib/miga/lair.rb +4 -0
- data/lib/miga/metadata.rb +4 -3
- data/lib/miga/project.rb +29 -20
- data/lib/miga/project/base.rb +52 -37
- data/lib/miga/project/dataset.rb +27 -13
- data/lib/miga/project/hooks.rb +0 -3
- data/lib/miga/project/result.rb +14 -5
- data/lib/miga/remote_dataset.rb +85 -72
- data/lib/miga/remote_dataset/base.rb +11 -13
- data/lib/miga/remote_dataset/download.rb +34 -12
- data/lib/miga/result.rb +48 -53
- data/lib/miga/result/base.rb +0 -2
- data/lib/miga/result/dates.rb +1 -3
- data/lib/miga/result/source.rb +15 -16
- data/lib/miga/result/stats.rb +37 -27
- data/lib/miga/tax_dist.rb +6 -3
- data/lib/miga/tax_index.rb +17 -17
- data/lib/miga/taxonomy.rb +6 -1
- data/lib/miga/taxonomy/base.rb +19 -15
- data/lib/miga/version.rb +19 -16
- data/scripts/project_stats.bash +3 -0
- data/scripts/stats.bash +1 -1
- data/test/common_test.rb +3 -11
- data/test/daemon_helper.rb +38 -0
- data/test/daemon_test.rb +73 -101
- data/test/dataset_test.rb +63 -59
- data/test/format_test.rb +3 -11
- data/test/hook_test.rb +50 -55
- data/test/json_test.rb +7 -8
- data/test/lair_test.rb +22 -28
- data/test/metadata_test.rb +6 -14
- data/test/project_test.rb +33 -39
- data/test/remote_dataset_test.rb +26 -32
- data/test/result_stats_test.rb +17 -27
- data/test/result_test.rb +41 -34
- data/test/tax_dist_test.rb +0 -2
- data/test/tax_index_test.rb +4 -10
- data/test/taxonomy_test.rb +7 -9
- data/test/test_helper.rb +42 -1
- data/test/with_daemon_test.rb +14 -22
- data/utils/adapters.fa +13 -0
- data/utils/cleanup-databases.rb +6 -5
- data/utils/distance/base.rb +0 -1
- data/utils/distance/commands.rb +19 -12
- data/utils/distance/database.rb +24 -21
- data/utils/distance/pipeline.rb +23 -10
- data/utils/distance/runner.rb +20 -16
- data/utils/distance/temporal.rb +1 -3
- data/utils/distances.rb +1 -1
- data/utils/domain-ess-genes.rb +7 -7
- data/utils/index_metadata.rb +4 -2
- data/utils/mytaxa_scan.rb +18 -16
- data/utils/representatives.rb +5 -4
- data/utils/requirements.txt +1 -1
- data/utils/subclade/base.rb +0 -1
- data/utils/subclade/pipeline.rb +7 -6
- data/utils/subclade/runner.rb +9 -9
- data/utils/subclade/temporal.rb +0 -2
- data/utils/subclades-compile.rb +39 -37
- data/utils/subclades.rb +1 -1
- metadata +5 -4
data/lib/miga/cli/action/run.rb
CHANGED
@@ -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
|
-
|
54
|
-
|
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
|
-
|
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|
|
@@ -15,19 +14,24 @@ class MiGA::Cli::Action::Stats < MiGA::Cli::Action
|
|
15
14
|
) { |v| cli[:key] = v }
|
16
15
|
opt.on(
|
17
16
|
'--compute-and-save',
|
18
|
-
'Compute and
|
17
|
+
'Compute and save the statistics'
|
19
18
|
) { |v| cli[:compute] = v }
|
20
19
|
opt.on(
|
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[:
|
29
|
-
|
30
|
-
|
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)
|
@@ -27,6 +26,10 @@ class MiGA::Cli::Action::Summary < MiGA::Cli::Action
|
|
27
26
|
'--with-units',
|
28
27
|
'Include units in each cell'
|
29
28
|
) { |v| cli[:units] = v }
|
29
|
+
opt.on(
|
30
|
+
'--compute-and-save',
|
31
|
+
'Compute and save the statistics if not yet available'
|
32
|
+
) { |v| cli[:compute] = v }
|
30
33
|
end
|
31
34
|
end
|
32
35
|
|
@@ -35,9 +38,10 @@ class MiGA::Cli::Action::Summary < MiGA::Cli::Action
|
|
35
38
|
ds = cli.load_and_filter_datasets
|
36
39
|
cli.say 'Loading results'
|
37
40
|
stats = ds.map do |d|
|
38
|
-
r = d.
|
41
|
+
r = d.result(cli[:result])
|
42
|
+
r.compute_stats if cli[:compute] && !r.nil? && r[:stats].empty?
|
39
43
|
s = r.nil? ? {} : r[:stats]
|
40
|
-
s.tap{ |i| i[:dataset] = d.name }
|
44
|
+
s.tap { |i| i[:dataset] = d.name }
|
41
45
|
end
|
42
46
|
keys = cli[:key_md].nil? ? stats.map(&:keys).flatten.uniq :
|
43
47
|
[:dataset, cli[:key_md].downcase.miga_name.to_sym]
|
@@ -45,9 +49,11 @@ class MiGA::Cli::Action::Summary < MiGA::Cli::Action
|
|
45
49
|
keys.unshift :dataset
|
46
50
|
|
47
51
|
table = cli[:units] ?
|
48
|
-
stats.map{ |s|
|
49
|
-
|
50
|
-
|
52
|
+
stats.map { |s|
|
53
|
+
keys
|
54
|
+
.map { |k| s[k].is_a?(Array) ? s[k].map(&:to_s).join('') : s[k] }
|
55
|
+
} :
|
56
|
+
stats.map { |s| keys.map { |k| s[k].is_a?(Array) ? s[k].first : s[k] } }
|
51
57
|
io = cli[:output].nil? ? $stdout : File.open(cli[:output], 'w')
|
52
58
|
cli.puts(io, MiGA.tabulate(keys, table, cli[:tabular]))
|
53
59
|
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
|
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
|
-
|
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
|
-
|
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
|
-
|
16
|
-
opt.on(
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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]
|
data/lib/miga/cli/action/wf.rb
CHANGED
@@ -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
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
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
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
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
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
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
|
data/lib/miga/cli/base.rb
CHANGED
@@ -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:
|
6
|
+
generic: 'MiGA: The Microbial Genomes Atlas',
|
8
7
|
# Workflows
|
9
|
-
quality_wf:
|
10
|
-
derep_wf:
|
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:
|
13
|
-
index_wf:
|
11
|
+
preproc_wf: 'Preprocess input genomes or metagenomes',
|
12
|
+
index_wf: 'Generate distance indexing of input genomes',
|
14
13
|
# Projects
|
15
|
-
new:
|
16
|
-
about:
|
17
|
-
doctor:
|
18
|
-
get_db:
|
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:
|
21
|
-
get:
|
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:
|
24
|
-
find:
|
25
|
-
ln:
|
26
|
-
ls:
|
27
|
-
archive:
|
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:
|
31
|
-
files:
|
32
|
-
run:
|
33
|
-
summary:
|
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:
|
35
|
+
edit: 'Edits the metadata of a dataset or project',
|
37
36
|
# System
|
38
|
-
init:
|
39
|
-
daemon:
|
40
|
-
lair:
|
41
|
-
date:
|
42
|
-
console:
|
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:
|
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] = (
|
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 =
|
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
|