Module: Robot::Generator::Behaviours::TecanDefault
Overview
Module with the file generation functionality for Tecan robots
Instance Method Summary collapse
- #buffer_seperator ⇒ Object
- #buffers(data_object) ⇒ Object
- #description_to_column_index(well_name, plate_size) ⇒ Object
-
#dyn_mappings(data_object) ⇒ Object
rubocop:todo Metrics/AbcSize.
- #each_mapping(data_object) ⇒ Object
- #footer ⇒ Object
- #header(data_object) ⇒ Object
- #mapping(data_object: picking_data) ⇒ Object
- #sort_order ⇒ Object
- #sorted_control_plates ⇒ Object
- #sorted_destination_plates ⇒ Object
- #sorted_source_plates ⇒ Object
- #tecan_precision_value(value) ⇒ Object
Instance Method Details
#buffer_seperator ⇒ Object
65 66 67 |
# File 'app/models/robot/generator/behaviours/tecan_default.rb', line 65 def buffer_seperator 'C;' end |
#buffers(data_object) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'app/models/robot/generator/behaviours/tecan_default.rb', line 69 def buffers(data_object) buffer = [] each_mapping(data_object) do |mapping, , plate_details| next unless total_volume > mapping['volume'] dest_name = data_object['destination'][]['name'] volume = mapping['buffer_volume'] vert_map_id = description_to_column_index(mapping['dst_well'], plate_details['plate_size']) buffer << <<~TECAN A;#{buffer_info(vert_map_id)};;#{tecan_precision_value(volume)} D;#{};;#{dest_name};#{vert_map_id};;#{tecan_precision_value(volume)} W; TECAN end buffer.join("\n") end |
#description_to_column_index(well_name, plate_size) ⇒ Object
109 110 111 |
# File 'app/models/robot/generator/behaviours/tecan_default.rb', line 109 def description_to_column_index(well_name, plate_size) Map::Coordinate.description_to_vertical_plate_position(well_name, plate_size) end |
#dyn_mappings(data_object) ⇒ Object
rubocop:todo Metrics/AbcSize
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/models/robot/generator/behaviours/tecan_default.rb', line 47 def dyn_mappings(data_object) # rubocop:todo Metrics/AbcSize dyn_mappings = +'' each_mapping(data_object) do |mapping, , dest_plate| , source_well = mapping['src_well'] source_name, source_size = data_object['source'][.to_s].values_at('name', 'plate_size') source_position = description_to_column_index(source_well, source_size) destination_position = description_to_column_index(mapping['dst_well'], dest_plate['plate_size']) dyn_mappings << <<~TECAN A;#{};;#{source_name};#{source_position};;#{tecan_precision_value(mapping['volume'])} D;#{};;#{dest_plate['name']};#{destination_position};;#{tecan_precision_value(mapping['volume'])} W; TECAN end dyn_mappings end |
#each_mapping(data_object) ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'app/models/robot/generator/behaviours/tecan_default.rb', line 36 def each_mapping(data_object) data_object['destination'].each do |, plate_details| mapping_by_well = plate_details['mapping'].sort_by do |mapping| description_to_column_index(mapping['dst_well'], plate_details['plate_size']) end mapping_by_well.each { |mapping| yield(mapping, , plate_details) } end end |
#footer ⇒ Object
87 88 89 90 91 92 93 94 95 |
# File 'app/models/robot/generator/behaviours/tecan_default.rb', line 87 def = +"C;\n" sorted_source_plates.each { |, index| << "C; SCRC#{index} = #{}\n" } << "C;\n" if .present? sorted_control_plates.each { |, index| << "C; CTRL#{index} = #{}\n" } << "C;\n" sorted_destination_plates.each { |, index| << "C; DEST#{index} = #{}\n" } end |
#header(data_object) ⇒ Object
24 25 26 27 28 29 30 |
# File 'app/models/robot/generator/behaviours/tecan_default.rb', line 24 def header(data_object) <<~HEADER C; C; This file created by #{data_object['user']} on #{data_object['time']} C; HEADER end |
#mapping(data_object: picking_data) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/models/robot/generator/behaviours/tecan_default.rb', line 5 def mapping(data_object: picking_data) raise ArgumentError, 'Data object not present for Tecan mapping' if data_object.nil? output_file_contents = [header(data_object)] buffer_data = buffers(data_object) if buffer_data.present? output_file_contents << buffer_data output_file_contents << buffer_seperator end output_file_contents << dyn_mappings(data_object) output_file_contents << output_file_contents.join("\n").gsub("\n\n", "\n") end |
#sort_order ⇒ Object
20 21 22 |
# File 'app/models/robot/generator/behaviours/tecan_default.rb', line 20 def sort_order :row_order end |
#sorted_control_plates ⇒ Object
101 102 103 |
# File 'app/models/robot/generator/behaviours/tecan_default.rb', line 101 def sorted_control_plates &.sort_by { |a| a[1] } || [] end |
#sorted_destination_plates ⇒ Object
105 106 107 |
# File 'app/models/robot/generator/behaviours/tecan_default.rb', line 105 def sorted_destination_plates .sort_by { |a| a[1] } end |
#sorted_source_plates ⇒ Object
97 98 99 |
# File 'app/models/robot/generator/behaviours/tecan_default.rb', line 97 def sorted_source_plates .sort_by { |a| a[1] } end |
#tecan_precision_value(value) ⇒ Object
32 33 34 |
# File 'app/models/robot/generator/behaviours/tecan_default.rb', line 32 def tecan_precision_value(value) value.to_f.round(configatron.tecan_precision) end |