Module: MiGA::Dataset::Result

Includes:
Common::WithResult, Base, Add, Ignore
Included in:
MiGA::Dataset
Defined in:
lib/miga/dataset/result.rb

Overview

Helper module including specific functions to add dataset results

Defined Under Namespace

Modules: Add, Ignore

Instance Method Summary collapse

Methods included from Add

#add_result_assembly, #add_result_cds, #add_result_distances, #add_result_essential_genes, #add_result_mytaxa, #add_result_mytaxa_scan, #add_result_raw_reads, #add_result_read_quality, #add_result_ssu, #add_result_stats, #add_result_taxonomy, #add_result_trimmed_fasta, #add_result_trimmed_reads

Methods included from Ignore

#force_task?, #ignore_by_type?, #ignore_complete?, #ignore_empty?, #ignore_force?, #ignore_inactive?, #ignore_multi?, #ignore_nomarkers?, #ignore_nonmulti?, #ignore_noref?, #ignore_project?, #ignore_reasons, #ignore_task?, #ignore_upstream?, #why_ignore

Methods included from Common::WithResult

#add_result, #each_result, #get_result, #next_task, #recalculate_tasks, #result, #result_dirs, #results

Instance Method Details

#cleanup_distances!(metrics = %i[haai aai ani]) ⇒ Object

Clean-up all the stored distances, removing values for datasets no longer in the project as reference datasets. All metrics are processed unless metric is passed (Array, including :haai, :aai, :ani)



102
103
104
105
106
107
108
# File 'lib/miga/dataset/result.rb', line 102

def cleanup_distances!(metrics = %i[haai aai ani])
  return if get_result(:distances).nil?

  require 'miga/sqlite'
  ref = project.dataset_ref_active.map(&:name)
  metrics.each { |metric| cleanup_distances_by_metric!(ref, metric) }
end

#done_preprocessing?(save = false) ⇒ Boolean

Are all the dataset-specific tasks done? Passes save to #add_result

Returns:

  • (Boolean)


49
50
51
# File 'lib/miga/dataset/result.rb', line 49

def done_preprocessing?(save = false)
  !first_preprocessing(save).nil? && next_preprocessing(save).nil?
end

#first_preprocessing(save = false) ⇒ Object

Returns the key symbol of the first registered result (sorted by the execution order). This typically corresponds to the result used as the initial input. Passes save to #add_result.



33
34
35
36
37
# File 'lib/miga/dataset/result.rb', line 33

def first_preprocessing(save = false)
  @first_processing ||= @@PREPROCESSING_TASKS.find do |t|
    !add_result(t, save).nil?
  end
end

#next_preprocessing(save = false) ⇒ Object

Returns the key symbol of the next task that needs to be executed or nil. Passes save to #add_result.



42
43
44
45
# File 'lib/miga/dataset/result.rb', line 42

def next_preprocessing(save = false)
  first_preprocessing(save) if save
  next_task(nil, save)
end

#profile_advance(save = false) ⇒ Object

Returns an array indicating the stage of each task (sorted by execution order). The values are integers:

  • 0 for an undefined result (a task before the initial input).

  • 1 for a registered result (a completed task).

  • 2 for a queued result (a task yet to be executed).

It passes save to #add_result



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

def profile_advance(save = false)
  # Determine the start point
  first_task = first_preprocessing(save) or
    return Array.new(self.class.PREPROCESSING_TASKS.size, 0)

  # Traverse all tasks and determine the corresponding state
  state = 0
  next_task = next_preprocessing(save)
  self.class.PREPROCESSING_TASKS.map do |task|
    state = 1 if first_task == task
    state = 2 if !next_task.nil? && next_task == task
    state
  end
end

#result_baseObject

Return the basename for results



25
26
27
# File 'lib/miga/dataset/result.rb', line 25

def result_base
  name
end

#result_status(task) ⇒ Object

Returns the status of task. The status values are symbols:

  • -: the task is upstream from the initial input

  • ignore_*: the task is to be ignored, see codes in #why_ignore

  • complete: a task with registered results

  • pending: a task queued to be performed



88
89
90
91
92
93
94
95
96
# File 'lib/miga/dataset/result.rb', line 88

def result_status(task)
  reason = why_ignore(task)
  case reason
  when :upstream then :-
  when :execute  then :pending
  when :complete then :complete
  else; :"ignore_#{reason}"
  end
end

#results_statusObject

Returns a Hash with tasks as key and status as value. See result_status for possible values



78
79
80
# File 'lib/miga/dataset/result.rb', line 78

def results_status
  Hash[@@PREPROCESSING_TASKS.map { |task| [task, result_status(task)] }]
end