Class: LabwareCreators::PooledWellsBySampleInGroups

Inherits:
Base
  • Object
show all
Includes:
SupportParent::PlateOnly
Defined in:
app/models/labware_creators/pooled_wells_by_sample_in_groups.rb

Overview

This labware creator pools PBMC isolations with the same samples in pairs (or configured number of source wells) per destination before cell counting to reduce the number runs on Celleca (cell counting). The robot transfer is done from LRC Blood Bank to LRC PBMC Bank plate. Only the wells with passed state will be transferred to the destination plate. The destination wells are compressed to top left by column on the plate.

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from LabwareCreators::Base

Instance Method Details

#build_poolsObject

List of pools to be created; index is the destination pool number; each pool is a list of source wells



41
42
43
44
45
# File 'app/models/labware_creators/pooled_wells_by_sample_in_groups.rb', line 41

def build_pools
  parent_wells_for_pooling
    .group_by { |well| well.aliquots.first.sample.uuid }
    .flat_map { |_uuid, wells| wells.each_slice(number_of_source_wells).to_a }
end

#get_well_for_plate_location(plate, well_location) ⇒ Object

Well object at well location on plate



66
67
68
# File 'app/models/labware_creators/pooled_wells_by_sample_in_groups.rb', line 66

def get_well_for_plate_location(plate, well_location)
  plate.wells.detect { |well| well.location == well_location }
end

#labware_wellsObject

List of passed wells of the parent labware in column order. Used by well filter.



26
27
28
# File 'app/models/labware_creators/pooled_wells_by_sample_in_groups.rb', line 26

def labware_wells
  source_plate.wells_in_columns.select(&:passed?)
end

#number_of_source_wellsObject

Number of source wells with the same sample to be pooled.



16
17
18
# File 'app/models/labware_creators/pooled_wells_by_sample_in_groups.rb', line 16

def number_of_source_wells
  @number_of_source_wells ||= purpose_config.dig(:creator_class, :args, :number_of_source_wells)
end

#parentObject Originally defined in module SupportParent::PlateOnly

#parent_wells_for_poolingObject

List of filtered wells for pooling.



36
37
38
# File 'app/models/labware_creators/pooled_wells_by_sample_in_groups.rb', line 36

def parent_wells_for_pooling
  well_filter.filtered.map(&:first)
end

#poolsObject

List of pools built from passed wells from parent plate



48
49
50
# File 'app/models/labware_creators/pooled_wells_by_sample_in_groups.rb', line 48

def pools
  @pools ||= build_pools
end

#request_hash(source_well, dest_plate, additional_parameters) ⇒ Object

Attributes for transfer request from source_well to dest_plate



71
72
73
74
75
76
77
78
# File 'app/models/labware_creators/pooled_wells_by_sample_in_groups.rb', line 71

def request_hash(source_well, dest_plate, additional_parameters)
  dest_location = transfer_hash[source_well.location][:dest_locn]
  {
    'source_asset' => source_well.uuid,
    'target_asset' => get_well_for_plate_location(dest_plate, dest_location)&.uuid,
    'merge_equivalent_aliquots' => true
  }.merge(additional_parameters)
end

#source_plateObject

Parent plate using SS v2 API



31
32
33
# File 'app/models/labware_creators/pooled_wells_by_sample_in_groups.rb', line 31

def source_plate
  @source_plate ||= Sequencescape::Api::V2::Plate.find_by(uuid: parent.uuid)
end

#transfer_hashObject

Object mapping source wells to destination wells for transfers



53
54
55
56
57
58
59
60
61
62
63
# File 'app/models/labware_creators/pooled_wells_by_sample_in_groups.rb', line 53

def transfer_hash
  result = {}
  pools.each_with_index do |pool, index|
    dest_location = WellHelpers.well_at_column_index(index)
    pool.each do |source_well|
      source_location = source_well.location
      result[source_location] = { dest_locn: dest_location }
    end
  end
  result
end

#transfer_material_from_parent!(dest_uuid) ⇒ Object

Send the transfer request to SS



88
89
90
91
92
93
94
95
# File 'app/models/labware_creators/pooled_wells_by_sample_in_groups.rb', line 88

def transfer_material_from_parent!(dest_uuid)
  dest_plate = Sequencescape::Api::V2::Plate.find_by(uuid: dest_uuid)
  api.transfer_request_collection.create!(
    user: user_uuid,
    transfer_requests: transfer_request_attributes(dest_plate)
  )
  true
end

#transfer_request_attributes(dest_plate) ⇒ Object

List of objects mapping source wells to destination wells



81
82
83
84
85
# File 'app/models/labware_creators/pooled_wells_by_sample_in_groups.rb', line 81

def transfer_request_attributes(dest_plate)
  well_filter.filtered.filter_map do |source_well, additional_parameters|
    request_hash(source_well, dest_plate, additional_parameters)
  end
end

#well_filterObject

Well filter with this object as the creator



21
22
23
# File 'app/models/labware_creators/pooled_wells_by_sample_in_groups.rb', line 21

def well_filter
  @well_filter ||= WellFilter.new(creator: self)
end