Class: LabwareCreators::PooledTubesBySample

Inherits:
PooledTubesBase show all
Includes:
CustomPage, SupportParent::PlateOnly
Defined in:
app/models/labware_creators/pooled_tubes_by_sample.rb

Overview

Pools from a plate into tubes, grouping together wells that contain the same sample NB. Currently this is specific to the Cardinal usage of FluidX tubes

Constant Summary collapse

PARENT_PLATE_INCLUDES =
'wells.aliquots,wells.aliquots.sample,wells.aliquots.sample.sample_metadata'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from LabwareCreators::Base

Instance Attribute Details

#fileObject

Returns the value of attribute file.



17
18
19
# File 'app/models/labware_creators/pooled_tubes_by_sample.rb', line 17

def file
  @file
end

Instance Method Details

#create_child_stock_tubesObject

TODO: QUESTIONS:

Should we pre-filter wells, based on whether they have been failed, or based on what request they have?

-> Should check this general strategy with team, as labware creators are inconsistent.

Are these pool identifiers recorded in the db? SS transfer_request.rb mentions ‘the pool_id attribute on well’…?

Have we made this class so cardinal-specific (e.g. lookup of ancestor vac tubes) that it cannot be re-used?



49
50
51
52
53
54
55
56
57
58
59
60
# File 'app/models/labware_creators/pooled_tubes_by_sample.rb', line 49

def create_child_stock_tubes
  api
    .specific_tube_creation
    .create!(
      user: user_uuid,
      parent: parent_uuid,
      child_purposes: [purpose_uuid] * pool_uuids.length,
      tube_attributes: tube_attributes
    )
    .children
    .index_by(&:name)
end

#name_for_details(pool_identifier) ⇒ Object



62
63
64
65
66
67
# File 'app/models/labware_creators/pooled_tubes_by_sample.rb', line 62

def name_for_details(pool_identifier)
  {
    source_tube_barcode: pools_with_extra_details[pool_identifier][:source_tube_barcode],
    destination_tube_posn: pools_with_extra_details[pool_identifier][:destination_tube_posn]
  }
end

#parentObject



32
33
34
# File 'app/models/labware_creators/pooled_tubes_by_sample.rb', line 32

def parent
  @parent ||= Sequencescape::Api::V2.plate_with_custom_includes(PARENT_PLATE_INCLUDES, uuid: parent_uuid)
end

#parent_v1Object



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

def parent_v1
  @parent_v1 ||= api.plate.find(parent_uuid)
end

#poolsObject



82
83
84
# File 'app/models/labware_creators/pooled_tubes_by_sample.rb', line 82

def pools
  @pools ||= determine_pools
end

#saveObject



28
29
30
# File 'app/models/labware_creators/pooled_tubes_by_sample.rb', line 28

def save
  super && upload_file && true
end

#transfer_request_attributesObject



69
70
71
72
73
74
75
76
77
78
79
80
# File 'app/models/labware_creators/pooled_tubes_by_sample.rb', line 69

def transfer_request_attributes
  pools.each_with_object([]) do |(pool_identifier, pool), transfer_requests|
    pool.each do |location|
      transfer_requests <<
        request_hash(
          well_locations.fetch(location).uuid,
          child_stock_tubes.fetch(name_for(name_for_details(pool_identifier))).uuid,
          pool_identifier
        )
    end
  end
end