miga-base 0.7.23.0 → 0.7.24.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -0
- data/Rakefile +1 -0
- data/lib/miga/cli/action/add.rb +1 -2
- data/lib/miga/cli/action/classify_wf.rb +12 -11
- data/lib/miga/cli/action/derep_wf.rb +3 -9
- data/lib/miga/cli/action/edit.rb +0 -1
- data/lib/miga/cli/action/find.rb +1 -1
- data/lib/miga/cli/action/generic.rb +1 -1
- data/lib/miga/cli/action/get.rb +7 -2
- data/lib/miga/cli/action/ncbi_get.rb +1 -1
- data/lib/miga/cli/action/new.rb +15 -9
- data/lib/miga/cli/action/option.rb +44 -0
- data/lib/miga/cli/action/quality_wf.rb +3 -3
- data/lib/miga/cli/action/tax_dist.rb +1 -1
- data/lib/miga/cli/action/tax_test.rb +1 -1
- data/lib/miga/cli/action/wf.rb +32 -30
- data/lib/miga/cli/base.rb +1 -0
- data/lib/miga/cli/objects_helper.rb +23 -18
- data/lib/miga/common.rb +1 -1
- data/lib/miga/common/with_option.rb +83 -0
- data/lib/miga/common/with_result.rb +2 -1
- data/lib/miga/dataset/base.rb +20 -2
- data/lib/miga/dataset/result.rb +1 -1
- data/lib/miga/metadata.rb +25 -13
- data/lib/miga/project/base.rb +82 -2
- data/lib/miga/project/result.rb +4 -4
- data/lib/miga/result/stats.rb +2 -2
- data/lib/miga/version.rb +2 -2
- data/scripts/essential_genes.bash +1 -2
- data/scripts/ogs.bash +2 -3
- data/test/dataset_test.rb +5 -5
- data/test/with_option_test.rb +115 -0
- data/utils/cleanup-databases.rb +1 -2
- data/utils/distance/commands.rb +2 -2
- data/utils/distance/database.rb +1 -1
- data/utils/distance/pipeline.rb +2 -4
- data/utils/distance/runner.rb +15 -23
- data/utils/index_metadata.rb +1 -2
- data/utils/subclade/runner.rb +9 -10
- metadata +6 -3
data/utils/cleanup-databases.rb
CHANGED
@@ -19,7 +19,7 @@ m.say 'Cleaning Databases'
|
|
19
19
|
next unless (idx % thr) == t
|
20
20
|
|
21
21
|
d = p.dataset(i)
|
22
|
-
next unless d.
|
22
|
+
next unless d.ref? && d.active?
|
23
23
|
|
24
24
|
d.cleanup_distances!
|
25
25
|
end
|
@@ -28,4 +28,3 @@ end
|
|
28
28
|
Process.waitall
|
29
29
|
m.advance('Dataset:', dsn.size, dsn.size)
|
30
30
|
m.say
|
31
|
-
|
data/utils/distance/commands.rb
CHANGED
@@ -9,7 +9,7 @@ module MiGA::DistanceRunner::Commands
|
|
9
9
|
return y unless y.nil? || y.zero?
|
10
10
|
|
11
11
|
# Try hAAI (except in clade projects)
|
12
|
-
unless @ref_project.
|
12
|
+
unless @ref_project.clade?
|
13
13
|
y = haai(target)
|
14
14
|
return y unless y.nil? || y.zero?
|
15
15
|
end
|
@@ -75,7 +75,7 @@ module MiGA::DistanceRunner::Commands
|
|
75
75
|
v = `aai.rb -1 "#{f1}" -2 "#{f2}" -S "#{db}" \
|
76
76
|
--name1 "#{n1}" --name2 "#{n2}" \
|
77
77
|
-t "#{o[:thr]}" -a --lookup-first "--#{o[:aai_save_rbm]}" \
|
78
|
-
-p "#{o[:aai_p]
|
78
|
+
-p "#{o[:aai_p]}"`.chomp
|
79
79
|
(v.nil? || v.empty?) ? 0 : v.to_f
|
80
80
|
end
|
81
81
|
|
data/utils/distance/database.rb
CHANGED
@@ -66,7 +66,7 @@ module MiGA::DistanceRunner::Database
|
|
66
66
|
return y unless y.nil? || y.zero?
|
67
67
|
|
68
68
|
# Check if self.dataset <- target is done (another thread)
|
69
|
-
if dataset.
|
69
|
+
if dataset.ref? && project.path == ref_project.path
|
70
70
|
y = data_from_db(
|
71
71
|
target.name, dataset.name, ref_db(metric, target.name), metric
|
72
72
|
)
|
data/utils/distance/pipeline.rb
CHANGED
@@ -31,10 +31,8 @@ module MiGA::DistanceRunner::Pipeline
|
|
31
31
|
|
32
32
|
# Run distances against datasets listed in metadata's +:dist_req+
|
33
33
|
def distances_by_request(metric)
|
34
|
-
return unless dataset.metadata[:dist_req]
|
35
|
-
|
36
34
|
$stderr.puts 'Running distances by request'
|
37
|
-
dataset.
|
35
|
+
dataset.option(:dist_req).each do |target|
|
38
36
|
ds = ref_project.dataset(target) and send(metric, ds)
|
39
37
|
end
|
40
38
|
end
|
@@ -112,7 +110,7 @@ module MiGA::DistanceRunner::Pipeline
|
|
112
110
|
$stderr.puts 'Transferring taxonomy'
|
113
111
|
return if tax.nil?
|
114
112
|
|
115
|
-
pval =
|
113
|
+
pval = project.option(:tax_pvalue)
|
116
114
|
tax_a = tax
|
117
115
|
.select { |i| i[1] != '?' && i[2] <= pval }
|
118
116
|
.map { |i| i[0, 2].join(':') }
|
data/utils/distance/runner.rb
CHANGED
@@ -21,47 +21,39 @@ class MiGA::DistanceRunner
|
|
21
21
|
@home = File.expand_path('data/09.distances', project.path)
|
22
22
|
|
23
23
|
# Default opts
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
-
@opts[:aai_save_rbm] ||= ENV.fetch('MIGA_AAI_SAVE_RBM') do
|
28
|
-
project.is_clade? ? 'save-rbm' : 'no-save-rbm'
|
29
|
-
end
|
24
|
+
@opts[:aai_save_rbm] =
|
25
|
+
project.option(:aai_save_rbm) ? 'save-rbm' : 'no-save-rbm'
|
30
26
|
@opts[:thr] ||= ENV.fetch('CORES') { 2 }.to_i
|
31
|
-
if opts[:run_taxonomy]
|
32
|
-
ref_path = project.
|
27
|
+
if opts[:run_taxonomy] && project.option(:ref_project)
|
28
|
+
ref_path = project.option(:ref_project)
|
33
29
|
@home = File.expand_path('05.taxonomy', @home)
|
34
30
|
@ref_project = MiGA::Project.load(ref_path)
|
35
31
|
raise "Cannot load reference project: #{ref_path}" if @ref_project.nil?
|
36
|
-
elsif !opts[:run_taxonomy]
|
37
|
-
ref_path = dataset.
|
38
|
-
if project.
|
39
|
-
ref_path = File.expand_path(ref_path, project.
|
32
|
+
elsif !opts[:run_taxonomy] && dataset.option(:db_project)
|
33
|
+
ref_path = dataset.option(:db_project)
|
34
|
+
if project.option(:db_proj_dir)
|
35
|
+
ref_path = File.expand_path(ref_path, project.option(:db_proj_dir))
|
40
36
|
end
|
41
37
|
@ref_project = MiGA::Project.load(ref_path)
|
42
38
|
raise "Cannot load reference project: #{ref_path}" if @ref_project.nil?
|
43
39
|
else
|
44
40
|
@ref_project = project
|
45
41
|
end
|
46
|
-
[
|
47
|
-
@opts[m] ||= ref_project.
|
42
|
+
%i[haai_p aai_p ani_p distances_checkpoint].each do |m|
|
43
|
+
@opts[m] ||= ref_project.option(m)
|
48
44
|
end
|
49
|
-
@opts[:aai_p] ||= 'blast+'
|
50
|
-
@opts[:ani_p] ||= 'blast+'
|
51
|
-
@opts[:distances_checkpoint] ||= 10
|
52
|
-
@opts[:distances_checkpoint] = @opts[:distances_checkpoint].to_i
|
53
45
|
$stderr.puts "Options: #{opts}"
|
54
46
|
end
|
55
47
|
|
56
48
|
# Launch the appropriate analysis
|
57
49
|
def go!
|
58
50
|
$stderr.puts "Launching analysis"
|
59
|
-
return if dataset.
|
51
|
+
return if dataset.multi?
|
60
52
|
|
61
53
|
Dir.mktmpdir do |tmp_dir|
|
62
54
|
@tmp = tmp_dir
|
63
55
|
create_temporals
|
64
|
-
opts[:run_taxonomy] ? go_taxonomy! : dataset.
|
56
|
+
opts[:run_taxonomy] ? go_taxonomy! : dataset.ref? ? go_ref! : go_query!
|
65
57
|
end
|
66
58
|
end
|
67
59
|
|
@@ -73,7 +65,7 @@ class MiGA::DistanceRunner
|
|
73
65
|
|
74
66
|
# first-come-first-serve traverse
|
75
67
|
ref_project.each_dataset do |ds|
|
76
|
-
next if !ds.
|
68
|
+
next if !ds.ref? or ds.multi? or ds.result(:essential_genes).nil?
|
77
69
|
|
78
70
|
puts "[ #{Time.now} ] #{ds.name}"
|
79
71
|
ani_after_aai(ds)
|
@@ -88,7 +80,7 @@ class MiGA::DistanceRunner
|
|
88
80
|
def go_query!
|
89
81
|
$stderr.puts 'Launching analysis for query dataset'
|
90
82
|
# Check if project is ready
|
91
|
-
tsk = ref_project.
|
83
|
+
tsk = ref_project.clade? ? [:subclades, :ani] : [:clade_finding, :aai]
|
92
84
|
res = ref_project.result(tsk[0])
|
93
85
|
return if res.nil?
|
94
86
|
|
@@ -137,7 +129,7 @@ class MiGA::DistanceRunner
|
|
137
129
|
# Launch analysis for taxonomy jobs
|
138
130
|
def go_taxonomy!
|
139
131
|
$stderr.puts 'Launching taxonomy analysis'
|
140
|
-
return unless project.
|
132
|
+
return unless project.option(:ref_project)
|
141
133
|
|
142
134
|
go_query! # <- yeah, it's actually the same, just different ref_project
|
143
135
|
end
|
data/utils/index_metadata.rb
CHANGED
data/utils/subclade/runner.rb
CHANGED
@@ -18,19 +18,18 @@ class MiGA::SubcladeRunner
|
|
18
18
|
@step == :clade_finding ? '01.find.running' : '02.ani.running'
|
19
19
|
)
|
20
20
|
@opts[:thr] ||= ENV.fetch('CORES') { 2 }.to_i
|
21
|
-
@opts[:run_clades] =
|
22
|
-
@opts[:gsp_ani] = @project.
|
23
|
-
@opts[:gsp_aai] = @project.
|
24
|
-
@opts[:gsp_metric] =
|
25
|
-
@project.metadata.data.fetch(:gsp_metric) { 'ani' }.to_s
|
21
|
+
@opts[:run_clades] = @project.option(:run_clades)
|
22
|
+
@opts[:gsp_ani] = @project.option(:gsp_ani)
|
23
|
+
@opts[:gsp_aai] = @project.option(:gsp_aai)
|
24
|
+
@opts[:gsp_metric] = @project.option(:gsp_metric)
|
26
25
|
end
|
27
26
|
|
28
27
|
# Launch the appropriate analysis
|
29
28
|
def go!
|
30
29
|
return if project.type == :metagenomes
|
31
30
|
|
32
|
-
unless @project.dataset_names.any? { |i| @project.dataset(i).
|
33
|
-
FileUtils.touch(File.
|
31
|
+
unless @project.dataset_names.any? { |i| @project.dataset(i).ref? }
|
32
|
+
FileUtils.touch(File.join(@home, 'miga-project.empty'))
|
34
33
|
return
|
35
34
|
end
|
36
35
|
Dir.chdir home
|
@@ -44,15 +43,15 @@ class MiGA::SubcladeRunner
|
|
44
43
|
# Launch analysis for clade_finding
|
45
44
|
def go_clade_finding!
|
46
45
|
cluster_species
|
47
|
-
unless project.
|
48
|
-
subclades
|
46
|
+
unless project.clade?
|
47
|
+
subclades(:aai)
|
49
48
|
compile
|
50
49
|
end
|
51
50
|
end
|
52
51
|
|
53
52
|
# Launch analysis for subclades
|
54
53
|
def go_subclades!
|
55
|
-
subclades
|
54
|
+
subclades(:ani)
|
56
55
|
compile
|
57
56
|
end
|
58
57
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: miga-base
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.24.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luis M. Rodriguez-R
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: daemons
|
@@ -152,6 +152,7 @@ files:
|
|
152
152
|
- lib/miga/cli/action/ncbi_get.rb
|
153
153
|
- lib/miga/cli/action/new.rb
|
154
154
|
- lib/miga/cli/action/next_step.rb
|
155
|
+
- lib/miga/cli/action/option.rb
|
155
156
|
- lib/miga/cli/action/preproc_wf.rb
|
156
157
|
- lib/miga/cli/action/quality_wf.rb
|
157
158
|
- lib/miga/cli/action/rm.rb
|
@@ -174,6 +175,7 @@ files:
|
|
174
175
|
- lib/miga/common/path.rb
|
175
176
|
- lib/miga/common/with_daemon.rb
|
176
177
|
- lib/miga/common/with_daemon_class.rb
|
178
|
+
- lib/miga/common/with_option.rb
|
177
179
|
- lib/miga/common/with_result.rb
|
178
180
|
- lib/miga/daemon.rb
|
179
181
|
- lib/miga/daemon/base.rb
|
@@ -247,6 +249,7 @@ files:
|
|
247
249
|
- test/taxonomy_test.rb
|
248
250
|
- test/test_helper.rb
|
249
251
|
- test/with_daemon_test.rb
|
252
|
+
- test/with_option_test.rb
|
250
253
|
- utils/adapters.fa
|
251
254
|
- utils/cleanup-databases.rb
|
252
255
|
- utils/core-pan-plot.R
|
@@ -566,7 +569,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
566
569
|
- !ruby/object:Gem::Version
|
567
570
|
version: '0'
|
568
571
|
requirements: []
|
569
|
-
rubygems_version: 3.1.
|
572
|
+
rubygems_version: 3.1.4
|
570
573
|
signing_key:
|
571
574
|
specification_version: 4
|
572
575
|
summary: MiGA
|