miga-base 1.3.13.1 → 1.3.13.3

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: e3c8217b95cae01a70b7248f33790b672b18fd4c3c739437f49f37c7520ece66
4
- data.tar.gz: e86e9bb0d8e6beebaf838bc42233ddd9cda5343756853d44ee5873df4d62426d
3
+ metadata.gz: 278d0637c00542b14f71285b198201a37a287aecef2392bcf77d915c0be9bd52
4
+ data.tar.gz: 97012a85b2e4f1baf6e5ded3ec8a454d3dbbf76e556b42eff1b216c0f7735a7a
5
5
  SHA512:
6
- metadata.gz: 1b2550a8b834a611533d079fc5b5a46b770ba321ae4b062a3e451e752eb3b39d50828ac12261e5a446a5626b904a50b69c7b095cc0d89873bb01fba11b6e1d35
7
- data.tar.gz: 4781f1f57b21bf75de2724243751c091f14071ce5a7b3de1505f7cb197175189d6ea11da62b845b5132746bed5fee9250c27cf4c6776875a1d4dfcd0b7751d0b
6
+ metadata.gz: dfae6fff930fcfef0517988855007fb62b65106cc52d6857dc7f384a8f4d967f5c6d0084809607921529649cc5237f6adc1c95a6e0f80604c4201bbc9539666e
7
+ data.tar.gz: 5d825d4f6e0da2a47b4b287b494a4609cadc76bea390b415db9c7a8c18320a442022eaf801384ec43afd8424739d53e86ba2b2dfd67dd775d5f03adc2b8f1699
@@ -12,8 +12,7 @@ module MiGA::Cli::Action::Doctor::Base
12
12
  # list, and therefore the databases need to be cleaned.
13
13
  # This is a subtask of +check_dist+
14
14
  def check_dist_eval(cli, p, res)
15
- notok = {}
16
- fix = {}
15
+ y = { notok: Set.new, fix: Set.new }
17
16
  Zlib::GzipReader.open(res.file_path(:matrix)) do |fh|
18
17
  lineno = 0
19
18
  fh.each_line do |ln|
@@ -23,16 +22,11 @@ module MiGA::Cli::Action::Doctor::Base
23
22
  names = [r[0], r[1]]
24
23
  next unless names.any? { |i| p.dataset(i).nil? }
25
24
 
26
- names.each do |i|
27
- if p.dataset(i).nil? || !p.dataset(i).active?
28
- notok[i] = true
29
- else
30
- fix[i] = true
31
- end
32
- end
25
+ names.each { |i| y[p.dataset(i)&.active? ? :fix : :notok] << i }
33
26
  end
34
27
  end
35
- [notok.keys, fix.keys]
28
+ # The code below is more readable than `y.values.map(&:to_a)`
29
+ [y[:notok].to_a, y[:fix].to_a]
36
30
  end
37
31
 
38
32
  ##
@@ -43,8 +37,8 @@ module MiGA::Cli::Action::Doctor::Base
43
37
  return if fix.empty?
44
38
 
45
39
  cli.say("- Fixing #{fix.size} datasets")
46
- fix.each do |d_n|
47
- cli.say " > Fixing #{d_n}."
40
+ fix.each_with_index do |d_n, k|
41
+ cli.advance(' > Fixing', k + 1, fix.size, false)
48
42
  p.dataset(d_n).cleanup_distances!
49
43
  end
50
44
  end
@@ -97,15 +97,14 @@ module MiGA::Dataset::Result
97
97
 
98
98
  ##
99
99
  # Clean-up all the stored distances, removing values for datasets no longer in
100
- # the project as reference datasets.
101
- def cleanup_distances!
100
+ # the project as reference datasets. All metrics are processed unless +metric+
101
+ # is passed (Array[Symbol], including :haai, :aai, :ani)
102
+ def cleanup_distances!(metrics = %i[haai aai ani])
102
103
  return if get_result(:distances).nil?
103
104
 
104
105
  require 'miga/sqlite'
105
- ref = project.datasets.select(&:ref?).select(&:active?).map(&:name)
106
- %i[haai aai ani].each do |metric|
107
- cleanup_distances_by_metric!(ref, metric)
108
- end
106
+ ref = project.dataset_ref_active.map(&:name)
107
+ metrics.each { |metric| cleanup_distances_by_metric!(ref, metric) }
109
108
  end
110
109
 
111
110
  private
@@ -31,6 +31,22 @@ module MiGA::Project::Dataset
31
31
  @dataset_names_set ||= Set.new(dataset_names)
32
32
  end
33
33
 
34
+ ##
35
+ # Cache for the special set of datasets which are both reference and
36
+ # active, returned as an Array. Use carefully, as it doesn't get
37
+ # recalculated upon dataset (in)activation once loaded. To force
38
+ # recalculating, use +dataset_ref_active!+
39
+ def dataset_ref_active
40
+ @dataset_ref_active ||= dataset_ref_active!
41
+ end
42
+
43
+ ##
44
+ # Force recalculation of +dataset_ref_active+ and returns the Array
45
+ # of MiGA::Dataset objects
46
+ def dataset_ref_active!
47
+ @dataset_ref_active = datasets.select(&:ref?).select(&:active?)
48
+ end
49
+
34
50
  ##
35
51
  # Returns MiGA::Dataset
36
52
  def dataset(name)
@@ -60,6 +76,7 @@ module MiGA::Project::Dataset
60
76
  @metadata[:datasets] << name
61
77
  @dataset_names_hash[name] = true if @dataset_names_hash
62
78
  @dataset_names_set << name if @dataset_names_set
79
+ @dataset_ref_active = nil
63
80
  save
64
81
  if d.ref? && d.active?
65
82
  recalculate_tasks("Reference dataset added: #{d.name}")
@@ -75,6 +92,9 @@ module MiGA::Project::Dataset
75
92
  d = dataset(name)
76
93
  return nil if d.nil?
77
94
 
95
+ @dataset_names_hash = nil
96
+ @dataset_names_set = nil
97
+ @dataset_ref_active = nil
78
98
  self.metadata[:datasets].delete(name)
79
99
  save
80
100
  if d.ref? && d.active?
@@ -186,7 +186,6 @@ class MiGA::RemoteDataset
186
186
  # Looks for the entry +id+ in +dbfrom+, and returns the linked
187
187
  # identifier in +db+ (or nil).
188
188
  def ncbi_map(id, dbfrom, db)
189
- attempts = 0
190
189
  doc = download(:ncbi_map, dbfrom, id, :json, nil, db: db)
191
190
  return if doc.empty?
192
191
 
data/lib/miga/version.rb CHANGED
@@ -12,7 +12,7 @@ module MiGA
12
12
  # - String indicating release status:
13
13
  # - rc* release candidate, not released as gem
14
14
  # - [0-9]+ stable release, released as gem
15
- VERSION = [1.3, 13, 1].freeze
15
+ VERSION = [1.3, 13, 3].freeze
16
16
 
17
17
  ##
18
18
  # Nickname for the current major.minor version.
@@ -20,7 +20,7 @@ module MiGA
20
20
 
21
21
  ##
22
22
  # Date of the current gem relese.
23
- VERSION_DATE = Date.new(2024, 3, 11)
23
+ VERSION_DATE = Date.new(2024, 3, 18)
24
24
 
25
25
  ##
26
26
  # References of MiGA
@@ -27,7 +27,7 @@ module MiGA::DistanceRunner::Commands
27
27
  # Launch comparisons
28
28
  pending_targets(targets, :aai).each do |target|
29
29
  # Full AAI
30
- target_cds = target.result(:cds).file_path(:proteins) or next
30
+ target_cds = target.result(:cds)&.file_path(:proteins) or next
31
31
  aairb_cmd(
32
32
  tmp_file('proteins.fa'), target_cds,
33
33
  dataset.name, target.name, tmp_dbs[:aai], checkpoint: :aai
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.3.13.1
4
+ version: 1.3.13.3
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: 2024-03-11 00:00:00.000000000 Z
11
+ date: 2024-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: daemons