Class: Plate::QuadCreator

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
app/models/plate/quad_creator.rb

Overview

The Quad creator takes 4 parent 96 well plates or size 96 tube-racks and transfers them onto a new 384 well plate

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#target_purposeObject

Returns the value of attribute target_purpose.



8
9
10
# File 'app/models/plate/quad_creator.rb', line 8

def target_purpose
  @target_purpose
end

#userObject

Returns the value of attribute user.



8
9
10
# File 'app/models/plate/quad_creator.rb', line 8

def user
  @user
end

#user_barcodeObject

Returns the value of attribute user_barcode.



8
9
10
# File 'app/models/plate/quad_creator.rb', line 8

def user_barcode
  @user_barcode
end

Class Method Details

.target_coordinate_for(source_coordinate_name, quadrant_index) ⇒ String

Calculate the target coordinate for a source coordinate and quadrant number

Parameters:

  • source_coordinate_name (String)

    Location name of the well or tube. Eg. H12

  • quadrant_index (int)

    Quadrant index 1-4 e.g. 4

Returns:

  • (String)

    The target coordinate in the destination 384-well plate, e.g. P24



113
114
115
116
117
118
119
120
# File 'app/models/plate/quad_creator.rb', line 113

def target_coordinate_for(source_coordinate_name, quadrant_index)
  row_offset = quadrant_index % 2 # q0 -> 0, q1 -> 1, q2 -> 0, q3 -> 1
  col_offset = quadrant_index / 2 # q0 -> 0, q1 -> 0, q2 -> 1, q3 -> 1
  col, row = locn_coordinate(source_coordinate_name) # A1 -> 0, 0
  target_col = (col * 2) + col_offset
  target_row = (row * 2) + row_offset
  Map.location_from_row_and_column(target_row, target_col + 1) # this method expects target_col to be 1-indexed
end

Instance Method Details

#parent_barcodesObject



31
32
33
# File 'app/models/plate/quad_creator.rb', line 31

def parent_barcodes
  @parent_barcodes ||= @parents.transform_values(&:machine_barcode)
end

#parent_barcodes=(quad_barcodes) ⇒ Object



22
23
24
25
26
27
28
29
# File 'app/models/plate/quad_creator.rb', line 22

def parent_barcodes=(quad_barcodes)
  @parent_barcodes = quad_barcodes
  found_parents = Labware.with_barcode(quad_barcodes.values)
  @parents =
    quad_barcodes.transform_values do |barcode|
      found_parents.detect { |candidate| candidate.any_barcode_matching?(barcode) } || :not_found
    end
end

#saveObject



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

def save
  valid? && creation.save && transfer_request_collection.save && .save
end

#target_plateObject



18
19
20
# File 'app/models/plate/quad_creator.rb', line 18

def target_plate
  @creation&.child
end

#target_purpose_idObject



35
36
37
# File 'app/models/plate/quad_creator.rb', line 35

def target_purpose_id
  @target_purpose&.id
end