Class: TubeRack

Inherits:
Labware show all
Includes:
Barcode::Barcodeable
Defined in:
app/models/tube_rack.rb

Overview

A rack that holds tubes Tubes are linked via the RackedTubes association

Defined Under Namespace

Classes: Purpose

Constant Summary collapse

LAYOUTS =
{ 48 => { 'rows' => 6, 'columns' => 8 }, 96 => { 'rows' => 8, 'columns' => 12 } }.freeze

Instance Attribute Summary

Attributes inherited from Labware

#storage_location_service

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Barcode::Barcodeable

#aker_barcode, #aker_barcode=, #any_barcode_matching?, #barcode_format, #barcode_number, #cgap_barcode, #cgap_barcode=, #external_barcode, #external_barcode=, #external_identifier, #fluidigm_barcode, #fluidigm_barcode=, #generate_barcode, included, #infinium_barcode, #infinium_barcode=, #prefix, #primary_barcode, #printable_target, #sanger_barcode

Methods inherited from Labware

#ancestor_of_purpose, #ancestors_of_purpose, #child, #display_name, find_by_barcode, find_from_any_barcode, #generate_name, #labware, #labwhere_location, labwhere_locations, #parent, #role, #scanned_in_date, #source_plate, #source_plates, #storage_location

Methods included from SharedBehaviour::Named

included

Methods included from AssetLink::Associations

included

Methods included from Uuid::Uuidable

included, #unsaved_uuid!, #uuid

Methods included from Commentable

#after_comment_addition

Methods inherited from Asset

#add_parent, #ancestor_of_purpose, #asset_type_for_request_types, #assign_relationships, #barcode_number, #compatible_purposes, #contained_samples, #details, #external_identifier, #generate_barcode, #get_qc_result_value_for, #has_stock_asset?, #label, #label=, #original_stock_plates, #prefix, #printable?, #printable_target, #register_stock!, #request_types, #spiked_in_buffer, #summary_hash, #type, #update_from_qc

Methods included from EventfulRecord

#has_many_events, #has_many_lab_events, #has_one_event_with_family

Methods included from Event::PlateEvents

#event_date, #fluidigm_stamp_date, #gel_qc_date, #pico_date, #qc_started_date, #sequenom_stamp_date

Methods inherited from ApplicationRecord

convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!

Methods included from Squishify

extended

Class Method Details

.check_if_coordinates_valid(rack_size, list_coordinates) ⇒ Object

rubocop:todo Metrics/MethodLength


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/models/tube_rack.rb', line 34

def self.check_if_coordinates_valid(rack_size, list_coordinates) # rubocop:todo Metrics/MethodLength
  output = []

  num_rows = LAYOUTS[rack_size]['rows']
  num_columns = LAYOUTS[rack_size]['columns']
  valid_row_values = generate_valid_row_values(num_rows)
  valid_column_values = (1..num_columns).to_a

  list_coordinates.each do |coordinate|
    row = coordinate[/[A-Za-z]+/].capitalize
    column = coordinate[/[0-9]+/]
    output << (valid_row_values.include?(row) && valid_column_values.include?(column.to_i))
  end
  output
end

.generate_valid_row_values(num_rows) ⇒ Object


50
51
52
53
54
55
56
57
58
# File 'app/models/tube_rack.rb', line 50

def self.generate_valid_row_values(num_rows)
  output = []
  count = 1
  ('A'..'Z').each do |letter|
    output << letter if count <= num_rows
    count += 1
  end
  output
end

Instance Method Details

#human_barcodeObject


24
25
26
# File 'app/models/tube_rack.rb', line 24

def human_barcode
  primary_barcode.present? ? primary_barcode.barcode : nil
end

#receptacles_with_positionObject

Used to unify interface with TubeRacks. Returns a list of all receptacles with position information included for aid performance


30
31
32
# File 'app/models/tube_rack.rb', line 30

def receptacles_with_position
  tube_receptacles.includes(:racked_tube)
end