Class: IlluminaHtp::InitialDownstreamPlatePurpose

Inherits:
DownstreamPlatePurpose
  • Object
show all
Defined in:
app/models/illumina_htp/initial_downstream_plate_purpose.rb

Direct Known Subclasses

Pulldown::InitialDownstreamPlatePurpose

Instance Method Summary collapse

Instance Method Details

#stock_wells(plate, contents) ⇒ Object


25
26
27
28
29
# File 'app/models/illumina_htp/initial_downstream_plate_purpose.rb', line 25

def stock_wells(plate, contents)
  return plate.parent.wells unless contents.present?

  plate.parent.wells.located_at(contents)
end

#transition_to(plate, state, user, contents = nil, customer_accepts_responsibility = false) ⇒ Object

Initial plates in the pulldown pipelines change the state of the pulldown requests they are being created for to exactly the same state.


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/models/illumina_htp/initial_downstream_plate_purpose.rb', line 4

def transition_to(plate, state, user, contents = nil, customer_accepts_responsibility = false)
  ActiveRecord::Base.transaction do
    super
    new_outer_state = %w[started passed qc_complete].include?(state) ? 'started' : state

    # CAUTION!
    # TODO: While the behaviour here wont cause us any issues, its actually subtly wrong.
    # 1) Multiple wells on the same plate may have the same stock wells
    # 2) Well location may change between parent and child plates.
    # 3) As we only fire on pending requests this isn't actually a massive problem as we'll be targeting the whole plate anyway
    active_submissions = plate.submission_ids

    stock_wells(plate, contents).each do |source_well|
      # Only transitions from last submission
      source_well.requests.select { |r| r.library_creation? && active_submissions.include?(r.submission_id) }.each do |request|
        request.transition_to(new_outer_state) if request.pending?
      end
    end
  end
end