Class: SequencingPipeline

Inherits:
Pipeline show all
Defined in:
app/models/sequencing_pipeline.rb

Overview

SequencingPipeline represents the loading of multiplexed library tubes onto lanes of flowcells for running on the Sequencing machines.

Instance Method Summary collapse

Methods inherited from Pipeline

#all_requests_from_submissions_selected?, #completed_request_as_part_of_release_batch, #extract_requests_from_input_params, #input_labware, #output_labware, #pick_information?, #post_finish_batch, #request_count_in_inbox, #request_types_including_controls, #requests_in_inbox, #robot_verified!

Methods included from SharedBehaviour::Named

included

Methods included from Pipeline::BatchValidation

#validation_of_batch

Methods included from Uuid::Uuidable

included, #unsaved_uuid!, #uuid

Methods inherited from ApplicationRecord

alias_association, convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!

Methods included from Squishify

extended

Instance Method Details

#detach_request_from_batch(batch, request) ⇒ Object

The guys in sequencing want to be able to re-run a request in another batch. What we’ve agreed is that the request will be failed and then an identical request will be resubmitted to their inbox. The “failed” request should not be charged for.



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'app/models/sequencing_pipeline.rb', line 55

def detach_request_from_batch(batch, request)
  request.fail!

  # Note that the request metadata also needs to be cloned for this to work.
  ActiveRecord::Base.transaction do
    request.dup.tap do |request_clone|
      rma = request..attributes.merge(request: request_clone)
      request_clone.update!(state: 'pending', target_asset_id: nil, request_metadata_attributes: rma)
      request_clone.comments.create!(
        description:
          # rubocop:todo Layout/LineLength
          "Automatically created clone of request #{request.id} which was removed from Batch #{batch.id} at #{DateTime.now}"
        # rubocop:enable Layout/LineLength
      )
      request.comments.create!(
        description: "The request #{request_clone.id} is an automatically created clone of this one"
      )
    end
  end
end

#is_flowcell_type_consistent_for_batch?(batch) ⇒ Boolean

rubocop:todo Metrics/AbcSize

Returns:

  • (Boolean)


35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/models/sequencing_pipeline.rb', line 35

def is_flowcell_type_consistent_for_batch?(batch) # rubocop:todo Metrics/AbcSize
  if (batch.requests.size == 0) || batch.requests.first..nil?
    # No requests selected or the pipeline doesn't contain metadata to check
    return true
  end

  flowcell_type_list = batch.requests.filter_map { |request| request..requested_flowcell_type }

  # The pipeline doen't contain the requested_flowcell_type attribute
  return true if flowcell_type_list.size == 0

  # There are some requests that don't have the requested_flowcell_type
  return false if flowcell_type_list.size != batch.requests.size

  (flowcell_type_list.uniq.size == 1)
end

#is_read_length_consistent_for_batch?(batch) ⇒ Boolean

rubocop:todo Metrics/AbcSize

Returns:

  • (Boolean)


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/models/sequencing_pipeline.rb', line 18

def is_read_length_consistent_for_batch?(batch) # rubocop:todo Metrics/AbcSize
  if (batch.requests.size == 0) || batch.requests.first..nil?
    # No requests selected or the pipeline doesn't contain metadata to check
    return true
  end

  read_length_list = batch.requests.filter_map { |request| request..read_length }

  # The pipeline doen't contain the read_length attribute
  return true if read_length_list.size == 0

  # There are some requests that don't have the read_length_attribute
  return false if read_length_list.size != batch.requests.size

  (read_length_list.uniq.size == 1)
end

#on_start_batch(batch, user) ⇒ Object



76
77
78
# File 'app/models/sequencing_pipeline.rb', line 76

def on_start_batch(batch, user)
  BroadcastEvent::SequencingStart.create!(seed: batch, user: user, properties: {}, created_at: DateTime.now)
end

#post_release_batch(batch, _user) ⇒ Object



80
81
82
83
84
85
86
87
# File 'app/models/sequencing_pipeline.rb', line 80

def post_release_batch(batch, _user)
  # We call compact to handle ControlRequests which may have no target asset.
  # In practice this isn't required, as we don't use control lanes any more.
  # However some old feature tests still use them, and until this behaviour is completely
  # deprecated we should leave it here.
  batch.assets.compact.uniq.each(&:index_aliquots)
  Messenger.create!(target: batch, template: 'FlowcellIo', root: 'flowcell')
end

#request_actionsObject



14
15
16
# File 'app/models/sequencing_pipeline.rb', line 14

def request_actions
  [:remove]
end