module MiGA::Project::Result

Helper module including specific functions to add project results.

Public Instance Methods

add_result(name, save = true, opts = {}) click to toggle source

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.

# 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) click to toggle source

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

# File lib/miga/project/result.rb, line 52
def next_distances(save = true) ; next_task(@@DISTANCE_TASKS, save) ; end
next_inclade(save = true) click to toggle source

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

# File lib/miga/project/result.rb, line 57
def next_inclade(save = true) ; next_task(@@INCLADE_TASKS, save) ; end
next_task(tasks = nil, save = true) click to toggle source

Get the next task from tasks, saving intermediate results if save. If tasks is nil (default), it uses the entire list of tasks. Returns a Symbol.

# File lib/miga/project/result.rb, line 63
def next_task(tasks = nil, save = true)
  tasks ||= @@DISTANCE_TASKS+@@INCLADE_TASKS
  tasks.find do |t|
    if metadata["run_#{t}"] == false or
          (!is_clade? and @@INCLADE_TASKS.include?(t) and
                metadata["run_#{t}"] != true)
      false
    else
      add_result(t, save).nil?
    end
  end
end
result(name) click to toggle source

Get result identified by Symbol name, returns MiGA::Result.

# 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() click to toggle source

Get all results, an Array of MiGA::Result.

# File lib/miga/project/result.rb, line 23
def results
  @@RESULT_DIRS.keys.map{ |k| result(k) }.reject{ |r| r.nil? }
end