Class: SampleManifestExcel::Upload::Processor::Plate
- Defined in:
- app/sample_manifest_excel/sample_manifest_excel/upload/processor/plate.rb
Overview
TODO: had to explicitly specify the namespace for Base here otherwise it picks up Upload::Base
Processor to handle plate manifest uploads.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#check_for_barcodes_unique ⇒ Object
For plate manifests the barcodes (sanger plate id column) should be the same for each well from the same plate, and different for each plate.
-
#duplicate_barcodes ⇒ Object
Return the row of the first encountered barcode mismatch.
- #find_plate_id_for_sample_id(sample_id) ⇒ Object
Methods inherited from Base
#aliquots_updated?, #downstream_aliquots_updated?, #initialize, #processed?, #run, #sample_manifest_updated?, #samples_updated?, #substitutions, #type, #update_sample_manifest, #update_samples_and_aliquots
Constructor Details
This class inherits a constructor from SampleManifestExcel::Upload::Processor::Base
Instance Method Details
#check_for_barcodes_unique ⇒ Object
For plate manifests the barcodes (sanger plate id column) should be the same for each well from the same plate, and different for each plate. Uniqueness of foreign barcodes in the database is checked in the specialised field sanger_plate_id.
14 15 16 17 18 19 |
# File 'app/sample_manifest_excel/sample_manifest_excel/upload/processor/plate.rb', line 14 def , err_msg = return if .nil? errors.add(:base, "Barcode duplicated at row: #{.number}. #{err_msg}") end |
#duplicate_barcodes ⇒ Object
Return the row of the first encountered barcode mismatch
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/sample_manifest_excel/sample_manifest_excel/upload/processor/plate.rb', line 22 def return nil, nil unless upload.respond_to?('rows') unique_bcs = {} unique_plates = {} upload.rows.each do |row| next if row.columns.blank? || row.data.blank? = row.value('sanger_plate_id') sample_id = row.value('sanger_sample_id') next if .nil? || sample_id.nil? plate_id_for_sample = find_plate_id_for_sample_id(sample_id) next if plate_id_for_sample.nil? # Check that a barcode is used for only one plate if unique_bcs.key?() err_msg = 'Barcode is used in multiple plates.' return row, err_msg unless unique_bcs[] == plate_id_for_sample else unique_bcs[] = plate_id_for_sample end # Check that a plate has only one barcode if unique_plates.key?(plate_id_for_sample) err_msg = 'Plate has multiple barcodes.' return row, err_msg unless unique_plates[plate_id_for_sample] == else unique_plates[plate_id_for_sample] = end end [nil, nil] end |
#find_plate_id_for_sample_id(sample_id) ⇒ Object
55 56 57 58 |
# File 'app/sample_manifest_excel/sample_manifest_excel/upload/processor/plate.rb', line 55 def find_plate_id_for_sample_id(sample_id) sample_manifest_asset = SampleManifestAsset.find_by(sanger_sample_id: sample_id) sample_manifest_asset.labware&.id end |