Class: Well
Overview
A Well is a Receptacle on a Plate, it can contain one or more aliquots.
A plate may have multiple wells, with the two most common sizes being 128 (96) and
2426 (384). The wells are differentiated via their Map which corresponds to a
row and column. Most well locations are identified by a letter-number combination,
eg. A1, H12.
Defined Under Namespace
Modules: AttributeUpdater
Classes: Link
Constant Summary
Constants inherited
from Receptacle
Receptacle::QC_STATE_ALIASES
Transfer::State::ALL_STATES
Class Method Summary
collapse
Instance Method Summary
collapse
#untag!
included, #qc_report
#volume_to_cherrypick_by_micro_litre
#volume_to_cherrypick_by_nano_grams_per_micro_litre
#volume_to_cherrypick_by_nano_grams
included
Methods inherited from Receptacle
#any_barcode_matching?, #api_asset_type, #assign_tag2, #attach_tag, #been_through_qc?, #compatible_qc_state, #created_with_request_options, #friendly_name, #labware_comment_count, #legacy_asset_type, #library_information, #library_types, #most_recent_requests_as_target_group_by_same_source, #primary_aliquot_if_unique, #related_studies, #role, #set_as_library, #set_qc_state, #tag_range, #total_comment_count, #update_aliquot_quality
#qc_report
#on_downstream_aliquots, #process_aliquots, #remove_downstream_aliquots, #remove_matching_aliquots
#default_state, #state, #state_from, state_helper
#after_comment_addition
included, #unsaved_uuid!, #uuid
Methods inherited from Asset
#ancestor_of_purpose, #barcode_number, #compatible_purposes, #contained_samples, #generate_barcode, #get_qc_result_value_for, #has_stock_asset?, #label, #label=, #original_stock_plates, #prefix, #printable?, #printable_target, #register_stock!, #request_types, #type
#has_many_events, #has_many_lab_events, #has_one_event_with_family
#event_date, #fluidigm_stamp_date, #gel_qc_date, #pico_date, #qc_started_date, #sequenom_stamp_date
alias_association, convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!
Methods included from Squishify
extended
Class Method Details
.delegate_to_well_attribute(attribute, options = {}) ⇒ Object
178
179
180
181
182
183
184
|
# File 'app/models/well.rb', line 178
def delegate_to_well_attribute(attribute, options = {})
class_eval <<-END_OF_METHOD_DEFINITION
def get_#{attribute}
self.well_attribute.#{attribute} || #{options[:default].inspect}
end
END_OF_METHOD_DEFINITION
end
|
.hash_stock_with_targets(wells, purpose_names) ⇒ Object
194
195
196
197
198
199
200
201
202
203
|
# File 'app/models/well.rb', line 194
def hash_stock_with_targets(wells, purpose_names)
return {} unless purpose_names
purposes = PlatePurpose.where(name: purpose_names)
target_wells = Well.target_wells_for(wells).on_plate_purpose(purposes).preload(:well_attribute).with_concentration
target_wells.group_by(&:stock_well_id)
end
|
.writer_for_well_attribute_as_float(attribute) ⇒ Object
186
187
188
189
190
191
192
|
# File 'app/models/well.rb', line 186
def writer_for_well_attribute_as_float(attribute)
class_eval <<-END_OF_METHOD_DEFINITION
def set_#{attribute}(value)
self.well_attribute.update!(:#{attribute} => value.to_f)
end
END_OF_METHOD_DEFINITION
end
|
Instance Method Details
#absolute_position_name ⇒ Object
Returns the name of the position (eg. A1) of the well
315
316
317
|
# File 'app/models/well.rb', line 315
def absolute_position_name
map_description
end
|
#asset_type_for_request_types ⇒ Object
353
354
355
|
# File 'app/models/well.rb', line 353
def asset_type_for_request_types
self.class
end
|
#buffer_required? ⇒ Boolean
323
324
325
|
# File 'app/models/well.rb', line 323
def buffer_required?
get_buffer_volume > 0.0
end
|
#details ⇒ Object
340
341
342
343
344
|
# File 'app/models/well.rb', line 340
def details
return 'Not yet picked' if plate.nil?
plate.purpose.try(:name) || 'Unknown plate purpose'
end
|
#display_name ⇒ Object
Returns a name for the well in the format HumanBarcode:Location eg. DN12345S:A1
333
334
335
336
337
338
|
# File 'app/models/well.rb', line 333
def display_name
source = association_cached?(:plate) ? plate : labware
plate_name = source.present? ? source.human_barcode : '(not on a plate)'
plate_name ||= source.display_name "#{plate_name}:#{map_description}"
end
|
#empty? ⇒ Boolean
369
370
371
|
# File 'app/models/well.rb', line 369
def empty?
aliquots.blank?
end
|
#external_identifier ⇒ Object
236
237
238
|
# File 'app/models/well.rb', line 236
def external_identifier
display_name
end
|
#generate_name(_) ⇒ Object
232
233
234
|
# File 'app/models/well.rb', line 232
def generate_name(_)
end
|
#get_sequenom_pass ⇒ Object
The sequenom pass value is either the string 'Unknown' or it is the combination of gender marker values.
309
310
311
312
|
# File 'app/models/well.rb', line 309
def get_sequenom_pass
markers = well_attribute.gender_markers
markers.is_a?(Array) ? markers.join : markers
end
|
#latest_stock_metrics(product) ⇒ Object
346
347
348
349
350
351
|
# File 'app/models/well.rb', line 346
def latest_stock_metrics(product)
metric_wells = stock_wells.empty? ? [self] : stock_wells
metric_wells.filter_map { |stock_well| stock_well.qc_metrics.for_product(product).most_recent_first.first }.uniq
end
|
#library_name ⇒ Object
365
366
367
|
# File 'app/models/well.rb', line 365
def library_name
nil
end
|
#name ⇒ Object
361
362
363
|
# File 'app/models/well.rb', line 361
def name
nil
end
|
#outer_request(submission_id) ⇒ Object
214
215
216
|
# File 'app/models/well.rb', line 214
def outer_request(submission_id)
outer_requests.order(id: :desc).find_by(submission_id:)
end
|
Returns a collection of PolyMetadatum records associated with the Well.
This method overrides the autogenerated poly_metadata method to pick the
correct metadatable_type instead of the parent type. Without this override,
the generated SQL uses the wrong class name, e.g. Receptacle instead of Well.
60
61
62
|
# File 'app/models/well.rb', line 60
def poly_metadata
PolyMetadatum.where(metadatable_id: id, metadatable_type: self.class.name)
end
|
#qc_data ⇒ Object
319
320
321
|
# File 'app/models/well.rb', line 319
def qc_data
{ pico: get_pico_pass, gel: get_gel_pass, sequenom: get_sequenom_pass, concentration: get_concentration }
end
|
#qc_result_for(key) ⇒ Object
222
223
224
225
226
227
228
229
230
|
# File 'app/models/well.rb', line 222
def qc_result_for(key)
results = qc_results_by_key[key]
result = results.first.value if results.present?
return if result.nil?
return result.to_f.round(3) if result.to_s.include?('.')
result.to_i
end
|
#qc_results_by_key ⇒ Object
218
219
220
|
# File 'app/models/well.rb', line 218
def qc_results_by_key
@qc_results_by_key ||= qc_results.by_key
end
|
#stock_wells_for_downstream_wells ⇒ Object
206
207
208
|
# File 'app/models/well.rb', line 206
def stock_wells_for_downstream_wells
labware&.stock_plate? ? [self] : stock_wells
end
|
#subject_type ⇒ Object
210
211
212
|
# File 'app/models/well.rb', line 210
def subject_type
'well'
end
|
#update_from_qc(qc_result) ⇒ Object
357
358
359
|
# File 'app/models/well.rb', line 357
def update_from_qc(qc_result)
Well::AttributeUpdater.update(self, qc_result)
end
|
#update_gender_markers!(gender_markers, resource) ⇒ Object
rubocop:todo Metrics/MethodLength
286
287
288
289
290
291
292
293
294
295
296
297
298
299
|
# File 'app/models/well.rb', line 286
def update_gender_markers!(gender_markers, resource) if well_attribute.gender_markers == gender_markers
gender_marker_event = events.where(family: 'update_gender_markers').order(id: :desc).first
if gender_marker_event.blank?
events.update_gender_markers!(resource)
elsif resource == 'SNP' && gender_marker_event.content != resource
events.update_gender_markers!(resource)
end
else
events.update_gender_markers!(resource)
end
well_attribute.update!(gender_markers:)
end
|
#update_sequenom_count!(sequenom_count, resource) ⇒ Object
rubocop:enable Metrics/MethodLength
303
304
305
306
|
# File 'app/models/well.rb', line 303
def update_sequenom_count!(sequenom_count, resource)
events.update_sequenom_count!(resource) unless well_attribute.sequenom_count == sequenom_count
well_attribute.update!(sequenom_count:)
end
|
#update_volume(volume_change) ⇒ Object
263
264
265
266
|
# File 'app/models/well.rb', line 263
def update_volume(volume_change)
value_current_volume = get_current_volume.nil? ? 0 : get_current_volume
set_current_volume([0, value_current_volume + volume_change].max)
end
|
#well_attribute ⇒ Object
240
241
242
|
# File 'app/models/well.rb', line 240
def well_attribute
super || build_well_attribute
end
|