miga-base 1.3.13.7 → 1.3.13.8

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: 3f8c9af9a418331c84c3ca35ff6c3cbe1792ae9489e317744571b6f26d8118c6
4
- data.tar.gz: 26c53b61236bb268538a557a66b6d041eaf1270d2b9c780351b543ccb9db61b7
3
+ metadata.gz: e3bafd65eb344dccfd8a2b1601a2fc28282c17f8826565c6d0393161ad407b6b
4
+ data.tar.gz: cf47cca552f8651fe821af0431f579ef8958fb81371974fe5233391077a6405d
5
5
  SHA512:
6
- metadata.gz: 86766ebdd795caa961213185294b8846a8507bee68a917a56d35177cc55ad25a775fe82ea2223360e9c60e7717cd3ea9b4371fafa54ec31bd631f47079af59ab
7
- data.tar.gz: b22f25ee6c25554ab79b9ba048f4a6bf3555eeb8cd058c2addbea0e5fd74b7a4a8a907cba88fb9f8b688c81ce8020c070174a8d28dbc823d744ff59169f73dd0
6
+ metadata.gz: 9d8bebf5ac6267645fcaf2129d61dc516552a63790ef329310631c8db6e55f14d5ebcbe486eccef8898cd0a3036e6a448810ffe41a44810f351e2217a1f31817
7
+ data.tar.gz: 252d4fa1a39137358ce381bcdecebc9f1b5a40321c99b3ed059755555dbee3fd931fd77209d14d3b59ed236e51c53fa97d4668f9ad153ec7bdc2f02d205a1161
@@ -73,7 +73,9 @@ module MiGA::Cli::Action::Doctor::Base
73
73
 
74
74
  ##
75
75
  # Reads all the distance estimates in +a+ -> * for +metric+ and
76
- # returns them as a hash +{"b_name" => [val, sd, ...], ...}+
76
+ # returns them as a hash +{"b_name" => [val, sd, ...], ...}+ for
77
+ # rows with values other than the metric, or +{"b_name" => val}+ for
78
+ # rows with the metric only
77
79
  def read_bidirectional(a, metric)
78
80
  db_file = a.result(:distances)&.file_path("#{metric}_db") or return {}
79
81
  sql = "select seq2, #{metric}, sd, n, omega from #{metric}"
@@ -70,10 +70,10 @@ module MiGA::Cli::Action::Doctor::Distances
70
70
  #---- Auxuliary functions -----
71
71
 
72
72
  ##
73
- # Make a temporal directory holding partial bidirectionality reports (one per thread)
74
- # in a custom multi-JSON format. Requires a MiGA::Project +project+ and the iterator of
75
- # the reference datasets +ref_ds+. Returns the path to the temporal directory created.
76
- # Used by +check_bidir+
73
+ # Make a temporal directory holding partial bidirectionality reports (one per
74
+ # thread) in a custom multi-JSON format. Requires a MiGA::Project +project+
75
+ # and the iterator of the reference datasets +ref_ds+. Returns the path to the
76
+ # temporal directory created. Used by +check_bidir+
77
77
  def partial_bidir_tmp(project, ref_ds)
78
78
  n = ref_ds.size
79
79
 
@@ -106,9 +106,9 @@ module MiGA::Cli::Action::Doctor::Distances
106
106
  end
107
107
 
108
108
  ##
109
- # Read partial temporal reports of bidirectionality (located in +tmp+), and return
110
- # a two-deep hash with the final missingness report by metric (first key) and
111
- # dataset name (second key). Used by +check_bidir+
109
+ # Read partial temporal reports of bidirectionality (located in +tmp+), and
110
+ # return a two-deep hash with the final missingness report by metric (first
111
+ # key) and dataset name (second key). Used by +check_bidir+
112
112
  def merge_bidir_tmp(tmp)
113
113
  dist = { aai: {}, ani: {} }
114
114
  cli[:threads].times do |i|
@@ -58,7 +58,7 @@ module MiGA::Cli::Action::Doctor::Operations
58
58
  unless ok
59
59
  cli.say " > Registering again #{d.name}:#{r_k} "
60
60
  d.add_result(r_k, true, force: true)
61
- sr = d.result(:stats) and sr.remove!
61
+ d.result(:stats)&.remove!
62
62
  end
63
63
  end
64
64
  end
data/lib/miga/result.rb CHANGED
@@ -33,14 +33,26 @@ class MiGA::Result < MiGA::MiGA
33
33
  ##
34
34
  # Check if +path+ describes a result and otherwise create
35
35
  # it using the passed block. If +force+, ignore existing
36
- # JSON in +path+ if any.
36
+ # JSON in +path+ if any, but it can rescue the versions
37
+ # field from the old one if it exists and the new one doesn't
38
+ # contain such field.
37
39
  def create(path, force = false)
38
- FileUtils.rm(path) if force && File.exist?(path)
39
- r_pre = load(path)
40
- return r_pre unless r_pre.nil?
40
+ # Deal with old results first
41
+ r_old = load(path)
42
+ return r_old if r_old && !force
41
43
 
44
+ # Create the new result using the block passed
45
+ FileUtils.rm(path) if r_old
42
46
  yield
43
- load(path)
47
+
48
+ # Load and return
49
+ load(path).tap do |r_new|
50
+ # Rescue versions and start (if any and if necessary)
51
+ if r_old
52
+ %i[versions started].each { |i| r_new[i] ||= r_old[i] }
53
+ r_new[:versions] = (r_old[:versions] || {}).merge(r_new[:versions])
54
+ end
55
+ end
44
56
  end
45
57
  end
46
58
 
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, 7].freeze
15
+ VERSION = [1.3, 13, 8].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, 22)
23
+ VERSION_DATE = Date.new(2024, 3, 23)
24
24
 
25
25
  ##
26
26
  # References of MiGA
@@ -23,12 +23,12 @@ class ResultStatsTest < Test::Unit::TestCase
23
23
  File.open(fq, 'w') { |fh| fh.puts '@1', 'ACTAC', '+', '####' }
24
24
  touch_done(dir)
25
25
  r = dataset.add_result(:raw_reads)
26
- assert_equal({}, r[:stats])
26
+ assert_equal({}, r.stats)
27
27
  r.compute_stats
28
- assert_not_empty(r[:stats])
29
- assert_equal(Hash, r[:stats].class)
30
- assert_equal(1, r[:stats][:reads])
31
- assert_equal([40.0, '%'], r[:stats][:g_c_content])
28
+ assert_not_empty(r.stats)
29
+ assert_equal(Hash, r.stats.class)
30
+ assert_equal(1, r.stats[:reads])
31
+ assert_equal([40.0, '%'], r.stats[:g_c_content])
32
32
  end
33
33
 
34
34
  def test_coupled_raw_reads
@@ -40,10 +40,10 @@ class ResultStatsTest < Test::Unit::TestCase
40
40
  touch_done(dir)
41
41
  r = dataset.add_result(:raw_reads)
42
42
  r.compute_stats
43
- assert_not_empty(r[:stats])
44
- assert_nil(r[:stats][:reads])
45
- assert_equal(1, r[:stats][:read_pairs])
46
- assert_equal([40.0, '%'], r[:stats][:reverse_g_c_content])
43
+ assert_not_empty(r.stats)
44
+ assert_nil(r.stats[:reads])
45
+ assert_equal(1, r.stats[:read_pairs])
46
+ assert_equal([40.0, '%'], r.stats[:reverse_g_c_content])
47
47
  end
48
48
 
49
49
  def test_trimmed_reads
@@ -51,9 +51,9 @@ class ResultStatsTest < Test::Unit::TestCase
51
51
  FileUtils.touch(file_path(dir, '.1.clipped.fastq'))
52
52
  touch_done(dir)
53
53
  r = dataset.add_result(:trimmed_reads)
54
- assert_equal({}, r[:stats])
54
+ assert_equal({}, r.stats)
55
55
  r.compute_stats
56
- assert_equal({}, r[:stats])
56
+ assert_equal({}, r.stats)
57
57
  end
58
58
 
59
59
  def test_read_quality
@@ -62,9 +62,9 @@ class ResultStatsTest < Test::Unit::TestCase
62
62
  Dir.mkdir(file_path(dir, '.fastqc'))
63
63
  touch_done(dir)
64
64
  r = dataset.add_result(:read_quality)
65
- assert_equal({}, r[:stats])
65
+ assert_equal({}, r.stats)
66
66
  r.compute_stats
67
- assert_equal({}, r[:stats])
67
+ assert_equal({}, r.stats)
68
68
  end
69
69
 
70
70
  def test_trimmed_fasta
@@ -133,10 +133,10 @@ class ResultStatsTest < Test::Unit::TestCase
133
133
  r = dataset.add_result(:taxonomy)
134
134
 
135
135
  # Test assertions
136
- assert_nil(r[:stats][:closest_relative])
136
+ assert_nil(r.stats[:closest_relative])
137
137
  r.compute_stats
138
- assert_equal('dad', r[:stats][:closest_relative])
139
- assert_equal([100.0, '%'], r[:stats][:aai])
140
- assert_equal(0.0, r[:stats][:phylum_pvalue])
138
+ assert_equal('dad', r.stats[:closest_relative])
139
+ assert_equal([100.0, '%'], r.stats[:aai])
140
+ assert_equal(0.0, r.stats[:phylum_pvalue])
141
141
  end
142
142
  end
data/test/result_test.rb CHANGED
@@ -26,6 +26,30 @@ class ResultTest < Test::Unit::TestCase
26
26
  assert_instance_of(MiGA::Result, r)
27
27
  end
28
28
 
29
+ def test_overwrite_result
30
+ r = dataset.add_result(:trimmed_reads)
31
+ r[:ephemeral] = '@'
32
+ r[:versions] = { you: 'best' }
33
+ r.save
34
+
35
+ # Before reloading
36
+ assert_equal('@', r[:ephemeral])
37
+ assert_equal('best', r[:versions][:you])
38
+ assert_nil(r[:versions][:MiGA])
39
+
40
+ # After reloading (without forcing)
41
+ r = dataset.add_result(:trimmed_reads, true, force: false)
42
+ assert_equal('@', r[:ephemeral])
43
+ assert_equal('best', r[:versions][:you])
44
+ assert_nil(r[:versions][:MiGA])
45
+
46
+ # After reloading (with forcing)
47
+ r = dataset.add_result(:trimmed_reads, true, force: true)
48
+ assert_nil(r[:ephemeral])
49
+ assert_equal('best', r[:versions][:you])
50
+ assert_not_nil(r[:versions][:MiGA])
51
+ end
52
+
29
53
  def test_unlink
30
54
  r = project.add_result(:clade_finding)
31
55
  path = r.path
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.7
4
+ version: 1.3.13.8
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-22 00:00:00.000000000 Z
11
+ date: 2024-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: daemons