Class: IlluminaHtp::MxTubePurpose

Inherits:
Tube::Purpose
  • Object
show all
Defined in:
app/models/illumina_htp/mx_tube_purpose.rb

Overview

Note:

Most current activity is on subclasses of this purpose, especially IlluminaHtp::MxTubeNoQcPurpose As of 2019-10-01 only used directly by 'Lib Pool Norm' and 'Lib Pool SS-XP-Norm' which haven't been used since 2017-04-28 14:16:03 +0100

Purposes of this class represent multiplexed library tubes in the high-throughput pipeline. These tubes represent the cleaned-up normalized libraries at the end of the process that can pass directly into a SequencingPipeline. State changes on these tubes will automatically update the requests into the tubes

Instance Method Summary collapse

Instance Method Details

#customer_requests(tube) ⇒ Object


36
37
38
# File 'app/models/illumina_htp/mx_tube_purpose.rb', line 36

def customer_requests(tube)
  tube.requests_as_target.for_billing.where(state: Request::Statemachine::OPENED_STATE)
end

#library_source_plates(tube) ⇒ Object


48
49
50
# File 'app/models/illumina_htp/mx_tube_purpose.rb', line 48

def library_source_plates(tube)
  source_plate_scope(tube).map(&:source_plate)
end

#source_plate(tube) ⇒ Object


44
45
46
# File 'app/models/illumina_htp/mx_tube_purpose.rb', line 44

def source_plate(tube)
  super || source_plate_scope(tube).first
end

#source_plate_scope(tube) ⇒ Object


52
53
54
55
56
57
58
59
# File 'app/models/illumina_htp/mx_tube_purpose.rb', line 52

def source_plate_scope(tube)
  Plate
    .joins(wells: :requests)
    .where(requests: {
             target_asset_id: tube.id,
             sti_type: [Request::Multiplexing, Request::AutoMultiplexing, Request::LibraryCreation, *Request::LibraryCreation.descendants].map(&:name)
           }).distinct
end

#stock_plate(tube) ⇒ Object


40
41
42
# File 'app/models/illumina_htp/mx_tube_purpose.rb', line 40

def stock_plate(tube)
  tube.requests_as_target.where.not(requests: { asset_id: nil }).first&.asset&.plate
end

#transition_customer_requests(tube, state, user, customer_accepts_responsibility) ⇒ Object


26
27
28
29
30
31
32
33
34
# File 'app/models/illumina_htp/mx_tube_purpose.rb', line 26

def transition_customer_requests(tube, state, user, customer_accepts_responsibility)
  orders = Set.new
  customer_requests(tube).each do |request|
    request.customer_accepts_responsibility! if customer_accepts_responsibility
    request.transition_to(state)
    orders << request.order.id
  end
  generate_events_for(tube, orders, user) if state == 'passed'
end

#transition_to(tube, state, user, _ = nil, customer_accepts_responsibility = false) ⇒ Void

Called via Tube#transition_to Updates the state of tube to state

Parameters:

  • tube (Tube)

    The tube being updated

  • state (String)

    The desired target state

  • user (User)

    Provided for interface compatibility (The user performing the action)

  • _ (nil, Array) (defaults to: nil)

    Provided for interface compatibility

  • customer_accepts_responsibility (Boolean) (defaults to: false)

    The customer has proceeded against advice and will be charged for failures

Returns:

  • (Void)

21
22
23
24
# File 'app/models/illumina_htp/mx_tube_purpose.rb', line 21

def transition_to(tube, state, user, _ = nil, customer_accepts_responsibility = false)
  transition_customer_requests(tube, mappings[state], user, customer_accepts_responsibility) if mappings[state]
  tube.transfer_requests_as_target.each { |request| request.transition_to(state) }
end