Class: Sanger::Robots::Tecan::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/tecan_file_generation.rb

Class Method Summary collapse

Class Method Details

.barcode_to_plate_index(plates) ⇒ Object


24
25
26
27
28
29
30
# File 'lib/tecan_file_generation.rb', line 24

def barcode_to_plate_index(plates)
  barcode_lookup = {}
  plates.each_with_index do |plate, index|
    barcode_lookup[plate[0]] = index + 1
  end
  barcode_lookup
end

.mapping(data_object, total_volume) ⇒ Object

Raises:

  • (ArgumentError)

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/tecan_file_generation.rb', line 6

def mapping(data_object, total_volume)
  raise ArgumentError, 'data_object needs to conform to an interface. WIP' if data_object.nil?

  dest_barcode_index = barcode_to_plate_index(data_object['destination'])

  source_barcode_index = source_barcode_to_plate_index(data_object['destination'])
  buffer_data = buffers(data_object, total_volume)
  output_file_contents = [header(data_object)]
  unless buffer_data.blank?
    output_file_contents << buffer_data
    output_file_contents << buffer_seperator
  end
  output_file_contents << dyn_mappings(data_object)
  output_file_contents << footer(source_barcode_index, dest_barcode_index)

  output_file_contents.join("\n").gsub(/\n\n/, "\n")
end

.source_barcode_to_plate_index(destination) ⇒ Object


32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/tecan_file_generation.rb', line 32

def source_barcode_to_plate_index(destination)
  all_barcodes = []
  barcode_lookup = {}
  destination.each do |_plate_id, plate_info|
    plate_info['mapping'].each do |map_well|
      well = map_well['src_well']
      all_barcodes << well[0]
    end
  end
  all_barcodes.uniq.each_with_index do |plate, index|
    barcode_lookup[plate] = index + 1
  end
  barcode_lookup
end