miga-base 0.7.7.0 → 0.7.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3682f50e3efe936ce751cd83cc7945edddb8e1c3ea6e654c4d54f8ea79efbfcb
4
- data.tar.gz: a5bc821d8f1b6f55baf495eea28e8783c86c61ffaca2d486e4589b818a60038f
3
+ metadata.gz: 5cce1edf29f5f41ad7a53225978513597f2234abd781c5f179c9f45f9d6f1ec2
4
+ data.tar.gz: 846a570b68efe9dba8acbc1434c55752373d9864df2cea2ff467330bf7e8b1ac
5
5
  SHA512:
6
- metadata.gz: 23e986949f97ae31498b7310eba666f0fc4b5f3e4ab9d38a135b2934db901449dca70ce74830e4353bb60f2196ce2c195b1bfb20400f884494e9766e58ea5214
7
- data.tar.gz: 3857008111b8a65b1fbf09442eb3a657789ebf964769c7805485be57298141c363296b7d2491ef3379726344f07892211d10d4c72fc74a8095bc0eaf00d4e873
6
+ metadata.gz: 123117d43c4ef4200ebe4a51cb14d19e48b89d249e66fa27b6e0834cf1c3b738535c3f514856e373259428c42543a25886744b4a8a6775f75b587d0a557e4d48
7
+ data.tar.gz: fa178d1e899da25212983bf7640cc391f3922e560d5d5ee4ff072781b6301013d928212868c9db1590dfcd1f41449e07b5019765dc866d02295226c9ed8a3e2d
@@ -89,6 +89,10 @@ module MiGA::Cli::Action::Wf
89
89
  end
90
90
 
91
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
92
96
  opt.on('--fast', 'Alias to: --aai-p diamond --ani-p fastani') do
93
97
  cli[:aai_p] = 'diamond'
94
98
  cli[:ani_p] = 'fastani'
@@ -45,10 +45,6 @@ class MiGA::Result < MiGA::MiGA
45
45
  # Hash with the result metadata
46
46
  attr_reader :data
47
47
 
48
- ##
49
- # Array of MiGA::Result objects nested within the result (if any)
50
- attr_reader :results
51
-
52
48
  ##
53
49
  # Load or create the MiGA::Result described by the JSON file +path+
54
50
  def initialize(path)
@@ -78,9 +74,9 @@ class MiGA::Result < MiGA::MiGA
78
74
  when :json
79
75
  @path
80
76
  when :start
81
- @path.sub(/\.json$/, ".start")
77
+ @path.sub(/\.json$/, '.start')
82
78
  when :done
83
- @path.sub(/\.json$/, ".done")
79
+ @path.sub(/\.json$/, '.done')
84
80
  end
85
81
  end
86
82
 
@@ -134,7 +130,7 @@ class MiGA::Result < MiGA::MiGA
134
130
  ##
135
131
  # Initialize and #save empty result
136
132
  def create
137
- @data = { created: Time.now.to_s, results: [], stats: {}, files: {} }
133
+ @data = { created: Time.now.to_s, stats: {}, files: {} }
138
134
  save
139
135
  end
140
136
 
@@ -156,20 +152,19 @@ class MiGA::Result < MiGA::MiGA
156
152
  def load
157
153
  @data = MiGA::Json.parse(path)
158
154
  @data[:files] ||= {}
159
- @results = (self[:results] || []).map { |rs| MiGA::Result.new rs }
160
155
  end
161
156
 
162
157
  ##
163
158
  # Remove result, including all associated files
164
159
  def remove!
165
- each_file do |file|
166
- f = File.expand_path(file, dir)
167
- FileUtils.rm_rf(f)
168
- end
169
- %w(.start .done).each do |ext|
170
- f = path.sub(/\.json$/, ext)
171
- File.unlink f if File.exist? f
172
- end
160
+ each_file { |file| FileUtils.rm_rf(File.join(dir, file)) }
161
+ unlink
162
+ end
163
+
164
+ # Unlink result by removing the .done and .start timestamps and the
165
+ # .json descriptor, but don't remove any other associated files
166
+ def unlink
167
+ %i(start done).each { |i| f = path(i) and File.unlink(f) }
173
168
  File.unlink path
174
169
  end
175
170
 
@@ -182,28 +177,19 @@ class MiGA::Result < MiGA::MiGA
182
177
  # Note that multiple files may have the same symbol (file_sym), since
183
178
  # arrays of files are supported.
184
179
  def each_file(&blk)
180
+ return to_enum(:each_file) unless block_given?
181
+
185
182
  @data[:files] ||= {}
186
183
  self[:files].each do |k, files|
187
184
  files = [files] unless files.kind_of? Array
188
185
  files.each do |file|
189
186
  case blk.arity
190
- when 1
191
- blk.call(file)
192
- when 2
193
- blk.call(k, file)
194
- when 3
195
- blk.call(k, file, File.expand_path(file, dir))
196
- else
197
- raise "Wrong number of arguments: #{blk.arity} for 1..3"
187
+ when 1; blk.call(file)
188
+ when 2; blk.call(k, file)
189
+ when 3; blk.call(k, file, File.expand_path(file, dir))
190
+ else; raise "Wrong number of arguments: #{blk.arity} for 1..3"
198
191
  end
199
192
  end
200
193
  end
201
194
  end
202
-
203
- ##
204
- # Add the MiGA::Result +result+ as part of the current result
205
- def add_result(result)
206
- @data[:results] << result.path
207
- save
208
- end
209
195
  end
@@ -8,7 +8,7 @@ module MiGA
8
8
  # - Float representing the major.minor version.
9
9
  # - Integer representing gem releases of the current version.
10
10
  # - Integer representing minor changes that require new version number.
11
- VERSION = [0.7, 7, 0]
11
+ VERSION = [0.7, 8, 0]
12
12
 
13
13
  ##
14
14
  # Nickname for the current major.minor version.
@@ -16,7 +16,7 @@ module MiGA
16
16
 
17
17
  ##
18
18
  # Date of the current gem release.
19
- VERSION_DATE = Date.new(2020, 6, 4)
19
+ VERSION_DATE = Date.new(2020, 6, 7)
20
20
 
21
21
  ##
22
22
  # Reference of MiGA.
@@ -29,6 +29,16 @@ module MiGA::DistanceRunner::Pipeline
29
29
  classify(clades, classif, metric, result_fh, val_cls)
30
30
  end
31
31
 
32
+ # Run distances against datasets listed in metadata's +:dist_req+
33
+ def distances_by_request(metric)
34
+ return unless dataset.metadata[:dist_req]
35
+
36
+ $stderr.puts 'Running distances by request'
37
+ dataset.metadata[:dist_req].each do |target|
38
+ ds = ref_project.dataset(target) and send(metric, ds)
39
+ end
40
+ end
41
+
32
42
  # Builds a tree with all visited medoids from any classification level
33
43
  def build_medoids_tree(metric)
34
44
  $stderr.puts "Building medoids tree (metric = #{metric})"
@@ -99,7 +109,7 @@ module MiGA::DistanceRunner::Pipeline
99
109
 
100
110
  # Transfer the taxonomy to the current dataset
101
111
  def transfer_taxonomy(tax)
102
- $stderr.puts "Transferring taxonomy"
112
+ $stderr.puts 'Transferring taxonomy'
103
113
  return if tax.nil?
104
114
 
105
115
  pval = (project.metadata[:tax_pvalue] || 0.05).to_f
@@ -67,7 +67,7 @@ class MiGA::DistanceRunner
67
67
 
68
68
  # Launch analysis for reference datasets
69
69
  def go_ref!
70
- $stderr.puts "Launching analysis for reference dataset"
70
+ $stderr.puts 'Launching analysis for reference dataset'
71
71
  # Initialize databases
72
72
  initialize_dbs! true
73
73
 
@@ -80,13 +80,13 @@ class MiGA::DistanceRunner
80
80
  end
81
81
 
82
82
  # Finalize
83
- [:haai, :aai, :ani].each { |m| checkpoint! m if db_counts[m] > 0 }
83
+ %i[haai aai ani].each { |m| checkpoint! m if db_counts[m] > 0 }
84
84
  end
85
85
 
86
86
  ##
87
87
  # Launch analysis for query datasets
88
88
  def go_query!
89
- $stderr.puts "Launching analysis for query dataset"
89
+ $stderr.puts 'Launching analysis for query dataset'
90
90
  # Check if project is ready
91
91
  tsk = ref_project.is_clade? ? [:subclades, :ani] : [:clade_finding, :aai]
92
92
  res = ref_project.result(tsk[0])
@@ -94,6 +94,7 @@ class MiGA::DistanceRunner
94
94
 
95
95
  # Initialize the databases
96
96
  initialize_dbs! false
97
+ distances_by_request(tsk[1])
97
98
  # Calculate the classification-informed AAI/ANI traverse
98
99
  results = File.expand_path("#{dataset.name}.#{tsk[1]}-medoids.tsv", home)
99
100
  fh = File.open(results, 'w')
@@ -111,7 +112,9 @@ class MiGA::DistanceRunner
111
112
  next unless r[1].to_i == val_cls
112
113
 
113
114
  ani = ani_after_aai(ref_project.dataset(r[0]), 80.0)
114
- closest = { ds: r[0], ani: ani } unless ani.nil? or ani < closest[:ani]
115
+ unless ani.nil? || ani < closest[:ani]
116
+ closest = { ds: r[0], ani: ani }
117
+ end
115
118
  end
116
119
  end
117
120
  end
@@ -133,7 +136,7 @@ class MiGA::DistanceRunner
133
136
 
134
137
  # Launch analysis for taxonomy jobs
135
138
  def go_taxonomy!
136
- $stderr.puts "Launching taxonomy analysis"
139
+ $stderr.puts 'Launching taxonomy analysis'
137
140
  return unless project.metadata[:ref_project]
138
141
 
139
142
  go_query! # <- yeah, it's actually the same, just different ref_project
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.7.0
4
+ version: 0.7.8.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: 2020-06-04 00:00:00.000000000 Z
11
+ date: 2020-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: daemons