Module: Robot::Generator::Behaviours::TecanDefault

Included in:
Tecan, TecanV2
Defined in:
app/models/robot/generator/behaviours/tecan_default.rb

Overview

Module with the file generation functionality for Tecan robots

Instance Method Summary collapse

Instance Method Details

#buffer_seperatorObject


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, dest_plate_barcode, plate_details|
    next unless total_volume > mapping['volume']

    dest_name = data_object['destination'][dest_plate_barcode]['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_plate_barcode};;#{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_barcode, dest_plate|
    source_barcode, source_well = mapping['src_well']
    source_name, source_size = data_object['source'][source_barcode.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_barcode};;#{source_name};#{source_position};;#{tecan_precision_value(mapping['volume'])}
      D;#{dest_plate_barcode};;#{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 |dest_plate_barcode, 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, dest_plate_barcode, plate_details) }
  end
end

87
88
89
90
91
92
93
94
95
# File 'app/models/robot/generator/behaviours/tecan_default.rb', line 87

def footer
  footer = +"C;\n"
  sorted_source_plates.each { |barcode, index| footer << "C; SCRC#{index} = #{barcode}\n" }
  footer << "C;\n" if ctrl_barcode_index.present?
  sorted_control_plates.each { |barcode, index| footer << "C; CTRL#{index} = #{barcode}\n" }
  footer << "C;\n"
  sorted_destination_plates.each { |barcode, index| footer << "C; DEST#{index} = #{barcode}\n" }
  footer
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

Raises:

  • (ArgumentError)

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 << footer
  output_file_contents.join("\n").gsub(/\n\n/, "\n")
end

#sort_orderObject


20
21
22
# File 'app/models/robot/generator/behaviours/tecan_default.rb', line 20

def sort_order
  :row_order
end

#sorted_control_platesObject


101
102
103
# File 'app/models/robot/generator/behaviours/tecan_default.rb', line 101

def sorted_control_plates
  ctrl_barcode_index&.sort_by { |a| a[1] } || []
end

#sorted_destination_platesObject


105
106
107
# File 'app/models/robot/generator/behaviours/tecan_default.rb', line 105

def sorted_destination_plates
  dest_barcode_index.sort_by { |a| a[1] }
end

#sorted_source_platesObject


97
98
99
# File 'app/models/robot/generator/behaviours/tecan_default.rb', line 97

def sorted_source_plates
  source_barcode_index.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