Class: LabwareCreators::CommonFileHandling::CsvFileForTubeRack

Inherits:
CommonFileHandling::CsvFileBase
  • Object
show all
Defined in:
app/models/labware_creators/common_file_handling/csv_file_for_tube_rack.rb

Overview

This is an abstract class for handling tube rack csv files.

Takes the user uploaded tube rack scan csv file, validates the content and extracts the information.

This version of the rack scan file contains 2 columns, the first is the tube location (coordinate within rack) and the second is the tube barcode.

Example of file content (NB. no header line): A1,FX05653780 A2,NO READ etc.

Direct Known Subclasses

CsvFileForTubeRackWithRackBarcode

Constant Summary collapse

NO_TUBE_TEXTS =
['NO READ', 'NOSCAN', 'EMPTY', ''].freeze
NO_DUPLICATE_RACK_POSITIONS_MSG =
'contains duplicate rack positions (%s)'
NO_DUPLICATE_TUBE_BARCODES_MSG =
'contains duplicate tube barcodes (%s)'

Instance Method Summary collapse

Instance Method Details

#location_by_barcode_detailsHash

This hash is useful when we want to know the location of a tube barcode within the rack.

Returns:

  • (Hash)

    eg. { ‘FX00000001’ => ‘A1’, ‘FX00000002 => ’B1’ etc. }



42
43
44
45
# File 'app/models/labware_creators/common_file_handling/csv_file_for_tube_rack.rb', line 42

def location_by_barcode_details
  @location_by_barcode_details ||=
    position_details.each_with_object({}) { |(position, details), hash| hash[details['tube_barcode']] = position }
end

#position_detailsHash

Extracts tube details by rack location from the uploaded csv file. This hash is useful when we want the details for a rack location.

Returns:

  • (Hash)

    e.g. { ‘A1’ => { details for this location }, ‘B1’ => etc. }



33
34
35
# File 'app/models/labware_creators/common_file_handling/csv_file_for_tube_rack.rb', line 33

def position_details
  @position_details ||= generate_position_details_hash
end