Module: MiGA::Project::Result

Includes:
Base
Included in:
MiGA::Project
Defined in:
lib/miga/project/result.rb

Overview

Helper module including specific functions to add project results.

Instance Method Summary collapse

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
# 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"
  unless opts[:force]
    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.


50
# File 'lib/miga/project/result.rb', line 50

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.


55
# File 'lib/miga/project/result.rb', line 55

def next_inclade(save=true) ; next_task(@@INCLADE_TASKS, save) ; end

#next_task(tasks = @@[email protected]@INCLADE_TASKS, save = true) ⇒ Object

Get the next task from tasks, saving intermediate results if save. Returns a Symbol.


60
61
62
63
64
65
66
67
68
69
70
# File 'lib/miga/project/result.rb', line 60

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

#resultsObject

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