Class: LabwareCreators::PcrCyclesBinnedPlateBase

Inherits:
StampedPlate show all
Includes:
CustomPage
Defined in:
app/models/labware_creators/pcr_cycles_binned_plate_base.rb

Overview

Handles the generation of a plate with wells binned according to the number of PCR cycles that has been determined by the customer. Uploads a file supplied by the customer that has a row per each well. Uses the PCR Cycles column to determine the binning arrangement of the wells, and the Sample Volume and Diluent Volume columns in the well transfers. Values from some columns need to be stored for a later file export step downstream in the pipeline. Wells in the bins are applied to the destination by column order. If there is enough space on the destination plate each new bin will start in a new column. Otherwise bins will run consecutively without gaps.

Source Plate Dest Plate --–+–~ --–+–~ |A1| pcr_cycles = 12 (bin 2) |B1|A1|C1| --–+–~ --–+–~ |B1| pcr_cycles = 15 (bin 1) |D1|E1| | --–+–~ + --–+–~ |C1| pcr_cycles = 10 (bin 3) | |G1| | --–+–~ --–+–~ |D1| pcr_cycles = 15 (bin 1) | | | | --–+–~ --–+–~ |E1| pcr_cycles = 12 (bin 2) | | | | --–+–~ --–+–~ |G1| pcr_cycles = 12 (bin 2) | | | |

Constant Summary collapse

MISSING_WELL_DETAIL =
'is missing a row for well %s, all wells with content must have a row in the uploaded file.'
PENDING_WELL =
'contains at least one pending well %s, the plate and all wells in it should be passed before creating the child plate.'
PARENT_PLATE_INCLUDES =
'wells.aliquots,wells.qc_results,wells.requests_as_source.request_type,wells.aliquots.request.request_type'
CHILD_PLATE_INCLUDES =
'wells.aliquots'

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.



42
43
44
# File 'app/models/labware_creators/pcr_cycles_binned_plate_base.rb', line 42

def file
  @file
end

Instance Method Details

#after_transfer!Object



78
79
80
# File 'app/models/labware_creators/pcr_cycles_binned_plate_base.rb', line 78

def after_transfer!
  raise '#after_transfer! must be implemented on subclasses'
end

#csv_file_upload_configObject

Configurations from the plate purpose.



65
66
67
# File 'app/models/labware_creators/pcr_cycles_binned_plate_base.rb', line 65

def csv_file_upload_config
  @csv_file_upload_config ||= purpose_config.fetch(:csv_file_upload)
end

#dilutions_calculatorObject



91
92
93
# File 'app/models/labware_creators/pcr_cycles_binned_plate_base.rb', line 91

def dilutions_calculator
  @dilutions_calculator ||= Utility::PcrCyclesBinningCalculator.new(well_details)
end

#dilutions_configObject



69
70
71
# File 'app/models/labware_creators/pcr_cycles_binned_plate_base.rb', line 69

def dilutions_config
  @dilutions_config ||= purpose_config.fetch(:dilutions)
end

#parentObject



56
57
58
# File 'app/models/labware_creators/pcr_cycles_binned_plate_base.rb', line 56

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

#parent_v1Object



60
61
62
# File 'app/models/labware_creators/pcr_cycles_binned_plate_base.rb', line 60

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

#saveObject



73
74
75
76
# File 'app/models/labware_creators/pcr_cycles_binned_plate_base.rb', line 73

def save
  # NB. need the && true!!
  super && upload_file && true
end

#wells_have_required_information?Boolean

Returns:

  • (Boolean)


82
83
84
85
86
87
88
89
# File 'app/models/labware_creators/pcr_cycles_binned_plate_base.rb', line 82

def wells_have_required_information?
  filtered_wells.each do |well|
    next if well.aliquots.empty?

    errors.add(:csv_file, format(MISSING_WELL_DETAIL, well.location)) unless well_details.include? well.location
    errors.add(:csv_file, format(PENDING_WELL, well.location)) if well.pending?
  end
end