Module: SequencingQcBatch
- Included in:
- Batch
- Defined in:
- lib/sequencing_qc_batch.rb
Overview
Place to put Illumina QC code to be refactored
Constant Summary collapse
- VALID_QC_STATES =
NOTE: Be careful that the length of these do not exceed 25 characters, otherwise you will have to alter the batches.qc_state field in the DB to accommodate. FYI, 25 characters is: <———————–>
%w[qc_pending qc_submitted qc_manual qc_manual_in_progress qc_completed].freeze
Class Method Summary collapse
-
.adjacent_state_helper(direction, offset, delimiter) ⇒ Object
rubocop:todo Metrics/AbcSize.
- .included(base) ⇒ Object
- .state_transition_helper(name) ⇒ Object
Instance Method Summary collapse
- #processing_in_manual_qc? ⇒ Boolean
- #qc_manual_in_progress ⇒ Object
- #qc_previous_state!(current_user) ⇒ Object
-
#qc_states ⇒ Object
Returns qc_states used.
Class Method Details
.adjacent_state_helper(direction, offset, delimiter) ⇒ Object
rubocop:todo Metrics/AbcSize
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/sequencing_qc_batch.rb', line 47 def self.adjacent_state_helper(direction, offset, delimiter) # rubocop:todo Metrics/AbcSize define_method(:"qc_#{direction}_state") do unless qc_states.include?(qc_state.to_s) raise StandardError, "Current QC state appears to be invalid: '#{qc_state}'" end return nil if qc_state.to_s == qc_states.send(delimiter) qc_states[qc_states.index(qc_state.to_s) + offset] end end |
.included(base) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/sequencing_qc_batch.rb', line 9 def self.included(base) base.instance_eval do # TODO[xxx]: Isn't qc_state supposed to be initialised to 'qc_pending' rather than blank? validates_inclusion_of :qc_state, in: VALID_QC_STATES, allow_blank: true belongs_to :qc_pipeline, class_name: 'Pipeline' before_create :qc_pipeline_update end end |
.state_transition_helper(name) ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/sequencing_qc_batch.rb', line 63 def self.state_transition_helper(name) # TODO[xxx]: Really we should restrict the state transitions define_method(:"qc_#{name}") do # Maintaining legacy behaviour here as not sure if it was intentional. # Allows QC decisions to be made on invalid assets. update_attribute(:qc_state, qc_next_state) unless qc_next_state.nil? # rubocop:disable Rails/SkipsModelValidations end end |
Instance Method Details
#processing_in_manual_qc? ⇒ Boolean
77 78 79 |
# File 'lib/sequencing_qc_batch.rb', line 77 def processing_in_manual_qc? %w[qc_manual_in_progress qc_manual].include?(qc_state) end |
#qc_manual_in_progress ⇒ Object
81 82 83 84 |
# File 'lib/sequencing_qc_batch.rb', line 81 def qc_manual_in_progress self.qc_state = 'qc_manual_in_progress' save end |
#qc_previous_state!(current_user) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/sequencing_qc_batch.rb', line 33 def qc_previous_state!(current_user) previous_state = qc_previous_state if previous_state lab_events.create( description: 'QC Rollback', message: "Manual QC moved from #{qc_state} to #{previous_state}", user_id: current_user.id ) self.qc_state = previous_state end self.state = 'started' save end |
#qc_states ⇒ Object
Returns qc_states used
29 30 31 |
# File 'lib/sequencing_qc_batch.rb', line 29 def qc_states VALID_QC_STATES end |