miga-base 1.0.5.5 → 1.1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -226,7 +226,7 @@ def kmer_extract(input_files):
226
226
  line = line.strip().split()
227
227
  protein_name = line[0]
228
228
  model_name = line[3]
229
- score = line[8]
229
+ score = float(line[8])
230
230
  if model_name in positive_matches:
231
231
  if score > positive_matches[model_name][1]:
232
232
  positive_matches[model_name] = [protein_name, score]
@@ -141,32 +141,43 @@ module MiGA::DistanceRunner::Commands
141
141
  ##
142
142
  # Execute a FastAAI command
143
143
  def fastaai_cmd(targets)
144
- qry_idx = dataset.result(:essential_genes).file_path(:fastaai_index)
144
+ qry_idx = dataset.result(:essential_genes).file_path(:fastaai_index_2)
145
145
  return nil unless qry_idx
146
146
 
147
- # Run FastAAI
148
- File.open(f1 = tmp_file, 'w') { |fh| fh.puts qry_idx }
149
- File.open(f2 = tmp_file, 'w') do |fh|
150
- targets.each do |target|
151
- target_idx = target&.result(:essential_genes)&.file_path(:fastaai_index)
152
- fh.puts target_idx if target_idx
153
- end
147
+ # Merge databases
148
+ donors = []
149
+ targets.each do |target|
150
+ tgt_idx = target&.result(:essential_genes)&.file_path(:fastaai_index_2)
151
+ donors << tgt_idx if tgt_idx
154
152
  end
153
+ return nil if donors.empty?
155
154
  run_cmd <<~CMD
156
- FastAAI --qd "#{f1}" --rd "#{f2}" --output "#{f3 = tmp_file}" \
157
- --threads #{opts[:thr]}
155
+ FastAAI merge_db --donors "#{donors.join(',')}" \
156
+ --recipient "#{f1 = tmp_file}" --threads #{opts[:thr]}
157
+ CMD
158
+
159
+ # Run FastAAI
160
+ run_cmd <<~CMD
161
+ FastAAI db_query --query "#{qry_idx}" --target "#{f1}" \
162
+ --output "#{f2 = tmp_file}" --threads #{opts[:thr]} \
163
+ --do_stdev
158
164
  CMD
159
165
 
160
166
  # Save values in the databases
161
167
  haai_data = {}
162
168
  aai_data = {}
163
- File.open(f3, 'r') do |fh|
169
+ # Ugly workaround to the insistence of FastAAI to not provide the files
170
+ # I ask for ;-)
171
+ qry_results = File.basename(qry_idx, '.faix') + '_results.txt'
172
+ out_file = File.join(f2, 'results', qry_results)
173
+ File.open(out_file, 'r') do |fh|
164
174
  fh.each do |ln|
165
175
  out = ln.chomp.split("\t")
166
176
  haai_data[out[1]] = [
167
177
  out[2].to_f * 100, out[3].to_f * 100, out[4].to_i, out[5].to_i
168
178
  ]
169
- aai_data[out[1]] = [out[6].to_f, 0, 0, 0] if out[6] !~ /^>/
179
+ out[6] = (out[6] =~ /^>/) ? 95.0 : out[6].to_f
180
+ aai_data[out[1]] = [out[6], 0, 0, 0]
170
181
  end
171
182
  end
172
183
  puts "Results: #{haai_data.size} | Inferences: #{aai_data.size}"
@@ -174,7 +185,7 @@ module MiGA::DistanceRunner::Commands
174
185
  batch_data_to_db(:aai, aai_data)
175
186
 
176
187
  # Cleanup
177
- [f1, f2, f3].each { |i| File.unlink(i) }
188
+ [f1, f2].each { |i| FileUtils.rm_r(i) }
178
189
  end
179
190
 
180
191
  ##
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: 1.0.5.5
4
+ version: 1.1.2.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-09-14 00:00:00.000000000 Z
11
+ date: 2021-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: daemons
@@ -156,6 +156,7 @@ files:
156
156
  - lib/miga/cli/action/ln.rb
157
157
  - lib/miga/cli/action/ls.rb
158
158
  - lib/miga/cli/action/ncbi_get.rb
159
+ - lib/miga/cli/action/ncbi_get/downloads.rb
159
160
  - lib/miga/cli/action/new.rb
160
161
  - lib/miga/cli/action/next_step.rb
161
162
  - lib/miga/cli/action/option.rb
@@ -261,9 +262,10 @@ files:
261
262
  - utils/FastAAI/00.Libraries/01.SCG_HMMs/Archaea_SCG.hmm
262
263
  - utils/FastAAI/00.Libraries/01.SCG_HMMs/Bacteria_SCG.hmm
263
264
  - utils/FastAAI/00.Libraries/01.SCG_HMMs/Complete_SCG_DB.hmm
264
- - utils/FastAAI/FastAAI/FastAAI
265
+ - utils/FastAAI/FastAAI
266
+ - utils/FastAAI/FastAAI-legacy/FastAAI
267
+ - utils/FastAAI/FastAAI-legacy/kAAI_v1.0_virus.py
265
268
  - utils/FastAAI/README.md
266
- - utils/FastAAI/kAAI_v1.0_virus.py
267
269
  - utils/adapters.fa
268
270
  - utils/cleanup-databases.rb
269
271
  - utils/core-pan-plot.R