miga-base 0.7.20.1 → 0.7.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 76b06be04db6bb162666752f374da5a3adab38e010acf8a07f20fc2e8f97e75b
4
- data.tar.gz: 6c4f9b9118b21b11921b4c0a70ae99f3b1728d5737175ca5b9f23088ff985063
3
+ metadata.gz: ed3a4b61cfc055c8f305438f304257116b7ec3fe92e10af4d00150d6835cf079
4
+ data.tar.gz: 9cad53f9a308fbb96d0264932348543339a3d03e096695217b2af85f5b2ac89f
5
5
  SHA512:
6
- metadata.gz: d90839141adeb99d0551d0228c7b5806b11a971852bf2ca8040f419af79330be47fc7abe7f1bffec35fe935b3857a1631c860d8e6aa877ba74eb1524d24f8153
7
- data.tar.gz: baeee018956a1877065e2e9b5f689e1dc99af71cecc2705f951ab384b05b5760cffd7d85218068bb674541cb766a585add60c5b23a6209c15e2276b369d0f1b0
6
+ metadata.gz: 1507b05bdc37fe6b8f7dc1b7531042d225dc2e79112b3fb9dcb1e4a558e38321a1a8a1203024cb6f956623be928c676fa3c9c1fb971190e2ef6e26328a97d5e5
7
+ data.tar.gz: 570bd7b58bc0a6262ef77b1be1a797783b423d76f474fa4840eb146fdbc5fefc12dc5d8abd34f72c4dc7a7cc8ad000fe80005c33af8c9dbcb4232a757f01e07a
@@ -20,6 +20,6 @@ class MiGA::Cli::Action::AddResult < MiGA::Cli::Action
20
20
  obj = cli.load_project_or_dataset
21
21
  cli.say "Registering result: #{cli[:result]}"
22
22
  r = obj.add_result(cli[:result], true, force: cli[:force])
23
- raise "Cannot add result, incomplete expected files." if r.nil?
23
+ raise 'Cannot add result, incomplete expected files' if r.nil?
24
24
  end
25
25
  end
@@ -11,16 +11,8 @@ class MiGA::Cli::Action::NextStep < MiGA::Cli::Action
11
11
  end
12
12
 
13
13
  def perform
14
- p = cli.load_project
15
- n = nil
16
- if cli[:dataset].nil?
17
- n = p.next_distances(false)
18
- n ||= p.next_inclade(false)
19
- else
20
- d = cli.load_dataset
21
- n = d.next_preprocessing if d.is_active?
22
- end
23
- n ||= '?'
24
- cli.puts n
14
+ obj = cli.load_project_or_dataset
15
+ n = obj.next_task
16
+ cli.puts(n || '?')
25
17
  end
26
18
  end
@@ -1,6 +1,8 @@
1
1
  ##
2
2
  # Helper module including specific functions to handle objects that
3
- # have results.
3
+ # have results. The class including this module must implement methods
4
+ # +.RESULT_DIRS+, +#ignore_task?+, +#metadata+, +#project+,
5
+ # and +#inactivate!+.
4
6
  module MiGA::Common::WithResult
5
7
  ##
6
8
  # Result directories as a Hash
@@ -68,4 +70,40 @@ module MiGA::Common::WithResult
68
70
  def get_result(task)
69
71
  add_result(task, false)
70
72
  end
73
+
74
+ ##
75
+ # Get the next task from +tasks+, saving intermediate results if +save+.
76
+ # If +tasks+ is +nil+ (default), it uses the entire list of tasks.
77
+ # Returns a Symbol.
78
+ def next_task(tasks = nil, save = false)
79
+ tasks ||= result_dirs.keys
80
+ tasks.find do |t|
81
+ if ignore_task?(t)
82
+ # Do not run if this step is to be ignored
83
+ false
84
+ else
85
+ res = add_result(t, save)
86
+ if res.nil?
87
+ # Run if the step has not been calculated,
88
+ # unless too many attempts were already made
89
+ if (metadata["_try_#{t}"] || 0) > (project.metadata[:max_try] || 10)
90
+ inactivate! "Too many errors in step #{t}"
91
+ false
92
+ else
93
+ true
94
+ end
95
+ else
96
+ # Run if the step is ready but has to be recalculated
97
+ res.recalculate? ? true : false
98
+ end
99
+ end
100
+ end
101
+ end
102
+
103
+ ##
104
+ # Mark all results for recalculation
105
+ def recalculate_tasks(reason = nil)
106
+ each_result { |res| res.recalculate!(reason).save }
107
+ end
108
+
71
109
  end
@@ -107,6 +107,7 @@ class MiGA::Dataset < MiGA::MiGA
107
107
  metadata[:warn] = "Inactive: #{reason}" unless reason.nil?
108
108
  metadata[:inactive] = true
109
109
  metadata.save
110
+ project.recalculate_tasks('Reference dataset inactivated') if ref?
110
111
  pull_hook :on_inactivate
111
112
  end
112
113
 
@@ -116,6 +117,7 @@ class MiGA::Dataset < MiGA::MiGA
116
117
  metadata[:inactive] = nil
117
118
  metadata[:warn] = nil if metadata[:warn] && metadata[:warn] =~ /^Inactive: /
118
119
  metadata.save
120
+ project.recalculate_tasks('Reference dataset activated') if ref?
119
121
  pull_hook :on_activate
120
122
  end
121
123
 
@@ -77,19 +77,8 @@ module MiGA::Dataset::Result
77
77
  # Returns the key symbol of the next task that needs to be executed or nil.
78
78
  # Passes +save+ to #add_result.
79
79
  def next_preprocessing(save = false)
80
- first = first_preprocessing(save) or return nil
81
- @@PREPROCESSING_TASKS[@@PREPROCESSING_TASKS.index(first)..-1].find do |t|
82
- if ignore_task? t
83
- false
84
- elsif add_result(t, save).nil?
85
- if (metadata["_try_#{t}"] || 0) > (project.metadata[:max_try] || 10)
86
- inactivate! "Too many errors in step #{t}"
87
- false
88
- else
89
- true
90
- end
91
- end
92
- end
80
+ first_preprocessing(save) if save
81
+ next_task(nil, save)
93
82
  end
94
83
 
95
84
  ##
@@ -97,13 +97,28 @@ class MiGA::Project < MiGA::MiGA
97
97
 
98
98
  ##
99
99
  # Is this a clade project?
100
- def is_clade?
100
+ def clade?
101
101
  type == :clade
102
102
  end
103
103
 
104
+ ##
105
+ # Same as active? For backward compatibility
106
+ alias is_clade? clade?
107
+
104
108
  ##
105
109
  # Is this a project for multi-organism datasets?
106
- def is_multi?
110
+ def multi?
107
111
  @@KNOWN_TYPES[type][:multi]
108
112
  end
113
+
114
+ ##
115
+ # Same as multi? For backward compatibility
116
+ alias is_multi? multi?
117
+
118
+ ##
119
+ # Is this project active? Currently a dummy function, returns
120
+ # always true.
121
+ def active?
122
+ true
123
+ end
109
124
  end
@@ -50,14 +50,11 @@ module MiGA::Project::Base
50
50
  07.annotation/01.function/01.essential
51
51
  07.annotation/01.function/02.ssu
52
52
  07.annotation/02.taxonomy/01.mytaxa
53
- 07.annotation/03.qa 07.annotation/03.qa/01.checkm
54
- 07.annotation/03.qa/02.mytaxa_scan
53
+ 07.annotation/03.qa 07.annotation/03.qa/02.mytaxa_scan
55
54
  08.mapping 08.mapping/01.read-ctg 08.mapping/02.read-gene
56
55
  09.distances 09.distances/01.haai 09.distances/02.aai
57
56
  09.distances/03.ani 09.distances/04.ssu 09.distances/05.taxonomy
58
57
  10.clades 10.clades/01.find 10.clades/02.ani 10.clades/03.ogs
59
- 10.clades/04.phylogeny 10.clades/04.phylogeny/01.essential
60
- 10.clades/04.phylogeny/02.core 10.clades/05.metadata
61
58
  90.stats
62
59
  ]
63
60
 
@@ -48,11 +48,11 @@ module MiGA::Project::Dataset
48
48
  # Add dataset identified by +name+ and return MiGA::Dataset.
49
49
  def add_dataset(name)
50
50
  unless metadata[:datasets].include? name
51
- ds = MiGA::Dataset.new(self, name)
51
+ d = MiGA::Dataset.new(self, name)
52
52
  @metadata[:datasets] << name
53
53
  @dataset_names_hash = nil # Ensure loading even if +do_not_save+ is true
54
54
  save
55
- # TODO redo_project_steps if ds.ref?
55
+ recalculate_tasks('New reference dataset added') if d.ref? && d.active?
56
56
  pull_hook(:on_add_dataset, name)
57
57
  end
58
58
  dataset(name)
@@ -66,6 +66,7 @@ module MiGA::Project::Dataset
66
66
 
67
67
  self.metadata[:datasets].delete(name)
68
68
  save
69
+ recalculate_tasks('Reference dataset unlinked') if d.ref? && d.active?
69
70
  pull_hook(:on_unlink_dataset, name)
70
71
  d
71
72
  end
@@ -23,6 +23,11 @@ module MiGA::Project::Result
23
23
  self
24
24
  end
25
25
 
26
+ ##
27
+ # Do nothing, only to comply with MiGA::Common::WithResult
28
+ def inactivate!(reason = nil)
29
+ end
30
+
26
31
  ##
27
32
  # Is this +task+ to be bypassed?
28
33
  def ignore_task?(task)
@@ -45,17 +50,6 @@ module MiGA::Project::Result
45
50
  next_task(@@INCLADE_TASKS, save)
46
51
  end
47
52
 
48
- ##
49
- # Get the next task from +tasks+, saving intermediate results if +save+.
50
- # If +tasks+ is +nil+ (default), it uses the entire list of tasks.
51
- # Returns a Symbol.
52
- def next_task(tasks = nil, save = true)
53
- tasks ||= @@DISTANCE_TASKS + @@INCLADE_TASKS
54
- tasks.find do |t|
55
- ignore_task?(t) ? false : add_result(t, save).nil?
56
- end
57
- end
58
-
59
53
  private
60
54
 
61
55
  ##
@@ -59,9 +59,25 @@ class MiGA::Result < MiGA::MiGA
59
59
  end
60
60
 
61
61
  ##
62
- # Register the result as cleaned
62
+ # Register the result as cleaned, returns self
63
63
  def clean!
64
64
  self[:clean] = true
65
+ self
66
+ end
67
+
68
+ ##
69
+ # Is the result marked to be recalculated? Returns Boolean
70
+ def recalculate?
71
+ !!self[:recalculate]
72
+ end
73
+
74
+ ##
75
+ # Mark the result to be recalculated, returns self
76
+ def recalculate!(reason = nil)
77
+ self[:recalculate] = true
78
+ self[:recalculate_why] = reason
79
+ self[:recalculate_when] = Time.now.to_s
80
+ self
65
81
  end
66
82
 
67
83
  ##
@@ -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, 20, 1]
11
+ VERSION = [0.7, 21, 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(2021, 1, 10)
19
+ VERSION_DATE = Date.new(2021, 1, 13)
20
20
 
21
21
  ##
22
22
  # Reference of MiGA.
@@ -107,10 +107,10 @@ class HookTest < Test::Unit::TestCase
107
107
  File.join(project.path, 'data', '90.stats', "miga-project.#{ext}")
108
108
  )
109
109
  end
110
- assert_equal(:project_stats, project.next_task(nil, false))
110
+ assert_equal(:project_stats, project.next_task)
111
111
  assert_equal(:test, $res)
112
112
  assert_equal(1, $counter)
113
- assert_equal(:haai_distances, project.next_task)
113
+ assert_equal(:haai_distances, project.next_task(nil, true))
114
114
  assert_equal(:project_stats, $res)
115
115
  assert_equal(2, $counter)
116
116
  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.20.1
4
+ version: 0.7.21.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-01-10 00:00:00.000000000 Z
11
+ date: 2021-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: daemons