Class: LabwareCreators::StampedPlateAddingRandomisedControls
- Inherits:
-
StampedPlate
- Object
- Base
- StampedPlate
- LabwareCreators::StampedPlateAddingRandomisedControls
- Defined in:
- app/models/labware_creators/stamped_plate_adding_randomised_controls.rb
Overview
Stamps the majority of samples from the parent plate straight into the child plate (A1 to A1, B1 to B1 etc.). Also creates and adds a number of randomised control samples according to configuration from the plate purpose. NB. This was specifically made for adding 2 controls in Bioscan Lysate plates, with specific sample metdata, and is fairly specific for that purpose.
Constant Summary collapse
- PARENT_PLATE_INCLUDES =
rubocop:todo Metrics/ClassLength
'wells.requests_as_source,wells.requests_as_source.request_type,' \ 'wells.aliquots,wells.aliquots.sample,wells.aliquots.sample.sample_metadata'
Instance Method Summary collapse
-
#control_project_name ⇒ Object
fetch the project name to use for the control sample from the purpose configuration.
-
#control_study_name ⇒ Object
fetch the study name to use for the control sample from the purpose configuration.
- #control_well_locations ⇒ Object
-
#generate_control_well_locations ⇒ Object
generate randomised well locations for each control.
- #labware_wells ⇒ Object
-
#list_of_controls ⇒ Object
fetch list of controls to add from the child purpose configuration.
-
#list_of_rules ⇒ Object
fetch list of rules from the child purpose configuration.
- #parent ⇒ Object
-
#validate_control_rules(control_locations) ⇒ Object
check the selected well locations meet rules specified in purpose configuration.
Constructor Details
This class inherits a constructor from LabwareCreators::Base
Instance Method Details
#control_project_name ⇒ Object
fetch the project name to use for the control sample from the purpose configuration
32 33 34 |
# File 'app/models/labware_creators/stamped_plate_adding_randomised_controls.rb', line 32 def control_project_name @control_project_name ||= purpose_config.fetch(:control_project_name) end |
#control_study_name ⇒ Object
fetch the study name to use for the control sample from the purpose configuration
37 38 39 |
# File 'app/models/labware_creators/stamped_plate_adding_randomised_controls.rb', line 37 def control_study_name @control_study_name ||= purpose_config.fetch(:control_study_name) end |
#control_well_locations ⇒ Object
58 59 60 |
# File 'app/models/labware_creators/stamped_plate_adding_randomised_controls.rb', line 58 def control_well_locations @control_well_locations ||= generate_control_well_locations end |
#generate_control_well_locations ⇒ Object
generate randomised well locations for each control
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/models/labware_creators/stamped_plate_adding_randomised_controls.rb', line 42 def generate_control_well_locations max_retries = 5 retries_count = 0 until retries_count >= max_retries # use purpose config settings to create control locations control_locations = generate_control_locations_from_purpose_config # check control locations selected pass rules, otherwise we retry with new locations return control_locations if validate_control_rules(control_locations) retries_count += 1 end raise StandardError, "Control well location randomisation failed to pass rules after #{max_retries} attempts" end |
#labware_wells ⇒ Object
62 63 64 |
# File 'app/models/labware_creators/stamped_plate_adding_randomised_controls.rb', line 62 def labware_wells parent.wells.filter_map { |well| well unless control_well_locations.include?(well.position['name']) } end |
#list_of_controls ⇒ Object
fetch list of controls to add from the child purpose configuration
22 23 24 |
# File 'app/models/labware_creators/stamped_plate_adding_randomised_controls.rb', line 22 def list_of_controls purpose_config.fetch(:controls) end |
#list_of_rules ⇒ Object
fetch list of rules from the child purpose configuration
27 28 29 |
# File 'app/models/labware_creators/stamped_plate_adding_randomised_controls.rb', line 27 def list_of_rules purpose_config.fetch(:control_location_rules) end |
#parent ⇒ Object
17 18 19 |
# File 'app/models/labware_creators/stamped_plate_adding_randomised_controls.rb', line 17 def parent @parent ||= Sequencescape::Api::V2.plate_with_custom_includes(PARENT_PLATE_INCLUDES, uuid: parent_uuid) end |
#validate_control_rules(control_locations) ⇒ Object
check the selected well locations meet rules specified in purpose configuration
67 68 69 70 71 72 73 |
# File 'app/models/labware_creators/stamped_plate_adding_randomised_controls.rb', line 67 def validate_control_rules(control_locations) # first check for duplicates, in case the sampling chose the same well more than once return false if control_locations.uniq.length != control_locations.length # check the chosen locations against the purpose config rules (will add more options as required) check_control_rules_from_config(control_locations) end |