Class: AssetShape
Overview
Describes the shape of the plate and its numbering system. The majority of our plates have a 3:2 width height ratio: eg. 12*8 or 24*16 And wells are numbered by 'coordinate' eg. A1, H12 However FluidigmPlates have different dimensions:
-
6 * 16 (96)
-
12 * 16 (192)
In addition, wells are labeled sequentially in column order, padded with zeros: eg. S01-S96 and S001-S192
Class Method Summary
collapse
Instance Method Summary
collapse
included
convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!
Methods included from Squishify
extended
#broadcast, included, #queue_associated_for_broadcast, #queue_for_broadcast, #warren
Class Method Details
.default ⇒ Object
20
21
22
23
24
25
26
|
# File 'app/models/asset_shape.rb', line 20
def self.default
AssetShape.create_with(
horizontal_ratio: 3,
vertical_ratio: 2,
description_strategy: 'Map::Coordinate'
).find_or_create_by(name: 'Standard')
end
|
.default_id ⇒ Object
16
17
18
|
# File 'app/models/asset_shape.rb', line 16
def self.default_id
@default_id ||= default.id
end
|
Instance Method Details
#alternate_position(well_position, size, *dimensions) ⇒ Object
74
75
76
77
78
79
80
81
82
83
|
# File 'app/models/asset_shape.rb', line 74
def alternate_position(well_position, size, *dimensions)
return nil unless Map.valid_well_position?(well_position)
divisor, multiplier = dimensions.map { |n| send("plate_#{n}", size) }
column, row = (well_position - 1).divmod(divisor)
return nil unless (0...multiplier).cover?(column)
return nil unless (0...divisor).cover?(row)
alternate = (row * multiplier) + column + 1
end
|
#generate_map(size) ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'app/models/asset_shape.rb', line 56
def generate_map(size)
raise StandardError, 'Map already exists' if Map.find_by(asset_size: size, asset_shape_id: id).present?
ActiveRecord::Base.transaction do
map_data = Array.new(size) do |i|
{
asset_size: size,
asset_shape_id: id,
location_id: i + 1,
row_order: i,
column_order: (horizontal_to_vertical(i + 1, size) || 1) - 1,
description: location_from_index(i, size)
}
end
Map.import(map_data)
end
end
|
#horizontal_to_vertical(well_position, plate_size) ⇒ Object
40
41
42
|
# File 'app/models/asset_shape.rb', line 40
def horizontal_to_vertical(well_position, plate_size)
alternate_position(well_position, plate_size, :width, :height)
end
|
#interlaced_vertical_to_horizontal(well_position, plate_size) ⇒ Object
48
49
50
|
# File 'app/models/asset_shape.rb', line 48
def interlaced_vertical_to_horizontal(well_position, plate_size)
alternate_position(interlace(well_position, plate_size), plate_size, :height, :width)
end
|
#location_from_row_and_column(row, column, size = 96) ⇒ Object
85
86
87
|
# File 'app/models/asset_shape.rb', line 85
def location_from_row_and_column(row, column, size = 96)
description_strategy.constantize.location_from_row_and_column(row, column, plate_width(size), size)
end
|
#plate_height(size) ⇒ Object
32
33
34
|
# File 'app/models/asset_shape.rb', line 32
def plate_height(size)
multiplier(size) * vertical_ratio
end
|
#plate_width(size) ⇒ Object
36
37
38
|
# File 'app/models/asset_shape.rb', line 36
def plate_width(size)
multiplier(size) * horizontal_ratio
end
|
#standard? ⇒ Boolean
28
29
30
|
# File 'app/models/asset_shape.rb', line 28
def standard?
horizontal_ratio == 3 && vertical_ratio == 2
end
|
#vertical_to_horizontal(well_position, plate_size) ⇒ Object
44
45
46
|
# File 'app/models/asset_shape.rb', line 44
def vertical_to_horizontal(well_position, plate_size)
alternate_position(well_position, plate_size, :height, :width)
end
|
#vertical_to_interlaced_vertical(well_position, plate_size) ⇒ Object
52
53
54
|
# File 'app/models/asset_shape.rb', line 52
def vertical_to_interlaced_vertical(well_position, plate_size)
interlace(well_position, plate_size)
end
|