Module: MiGA::Project::Result
Overview
Helper module including specific functions to add project results.
Instance Method Summary collapse
-
#add_result(name, save = true, opts = {}) ⇒ Object
Add the result identified by Symbol
name
, and return MiGA::Result. -
#next_distances(save = true) ⇒ Object
Get the next distances task, saving intermediate results if
save
. -
#next_inclade(save = true) ⇒ Object
Get the next inclade task, saving intermediate results if
save
. -
#next_task(tasks = @@DISTANCE_TASKS+@@INCLADE_TASKS, save = true) ⇒ Object
Get the next task from
tasks
, saving intermediate results ifsave
. -
#result(name) ⇒ Object
Get result identified by Symbol
name
, returns MiGA::Result. -
#results ⇒ Object
Get all results, an Array of MiGA::Result.
Instance Method Details
#add_result(name, save = true, opts = {}) ⇒ Object
Add the result identified by Symbol name
, and return MiGA::Result. Save the result if save
. The opts
hash controls result creation (if necessary). Supported values include:
-
force
: A Boolean indicating if the result must be re-indexed. If true, it implies save=true.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/miga/project/result.rb', line 34 def add_result(name, save = true, opts = {}) return nil if @@RESULT_DIRS[name].nil? base = "#{path}/data/#{@@RESULT_DIRS[name]}/miga-project" if opts[:force] FileUtils.rm("#{base}.json") if File.exist?("#{base}.json") else r_pre = MiGA::Result.load("#{base}.json") return r_pre if (r_pre.nil? and not save) or not r_pre.nil? end r = result_files_exist?(base, ".done") ? send("add_result_#{name}", base) : nil r.save unless r.nil? r end |
#next_distances(save = true) ⇒ Object
Get the next distances task, saving intermediate results if save
. Returns a Symbol.
52 |
# File 'lib/miga/project/result.rb', line 52 def next_distances(save = true) ; next_task(@@DISTANCE_TASKS, save) ; end |
#next_inclade(save = true) ⇒ Object
Get the next inclade task, saving intermediate results if save
. Returns a Symbol.
57 |
# File 'lib/miga/project/result.rb', line 57 def next_inclade(save = true) ; next_task(@@INCLADE_TASKS, save) ; end |
#next_task(tasks = @@DISTANCE_TASKS+@@INCLADE_TASKS, save = true) ⇒ Object
Get the next task from tasks
, saving intermediate results if save
. Returns a Symbol.
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/miga/project/result.rb', line 62 def next_task(tasks = @@DISTANCE_TASKS+@@INCLADE_TASKS, save = true) tasks.find do |t| if ["run_#{t}"] == false or (!is_clade? and @@INCLADE_TASKS.include?(t) and ["run_#{t}"] != true) false else add_result(t, save).nil? end end end |
#result(name) ⇒ Object
Get result identified by Symbol name
, returns MiGA::Result.
15 16 17 18 19 |
# File 'lib/miga/project/result.rb', line 15 def result(name) dir = @@RESULT_DIRS[name.to_sym] return nil if dir.nil? MiGA::Result.load("#{path}/data/#{dir}/miga-project.json") end |
#results ⇒ Object
Get all results, an Array of MiGA::Result.
23 24 25 |
# File 'lib/miga/project/result.rb', line 23 def results @@RESULT_DIRS.keys.map{ |k| result(k) }.reject{ |r| r.nil? } end |