Class: Map
Overview
Map identifies a wells position on a Plate. It is not related to the ruby #map method.
Defined Under Namespace
Modules: Coordinate, Sequential
Class Method Summary
collapse
-
.horizontal_to_vertical(well_position, plate_size, _plate_shape = nil) ⇒ Object
-
.location_from_row_and_column(row, column) ⇒ Object
-
.map_384wells ⇒ Object
-
.map_96wells ⇒ Object
-
.pad_description(map) ⇒ Object
-
.split_well_description(well_description) ⇒ Object
-
.strip_description(description) ⇒ Object
Stip any leading zeros from the well name eg.
-
.valid_plate_position_and_plate_size?(well_position, plate_size) ⇒ Boolean
-
.valid_plate_size?(plate_size) ⇒ Boolean
-
.valid_well_description_and_plate_size?(well_description, plate_size) ⇒ Boolean
-
.valid_well_position?(well_position) ⇒ Boolean
-
.vertical_to_horizontal(well_position, plate_size, _plate_shape = nil) ⇒ Object
-
.walk_plate_in_column_major_order(size, asset_shape = nil) ⇒ Object
(also: walk_plate_vertically)
Walking in column major order goes by the columns: A1, B1, C1, …
-
.walk_plate_in_row_major_order(size, asset_shape = nil) ⇒ Object
(also: walk_plate_horizontally)
Walking in row major order goes by the rows: A1, A2, A3, …
Instance Method Summary
collapse
alias_association, convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!
Methods included from Squishify
extended
Class Method Details
.horizontal_to_vertical(well_position, plate_size, _plate_shape = nil) ⇒ Object
234
235
236
|
# File 'app/models/map.rb', line 234
def self.horizontal_to_vertical(well_position, plate_size, _plate_shape = nil)
Map::Coordinate.horizontal_to_vertical(well_position, plate_size)
end
|
.location_from_row_and_column(row, column) ⇒ Object
230
231
232
|
# File 'app/models/map.rb', line 230
def self.location_from_row_and_column(row, column)
"#{('A'.getbyte(0) + row).chr}#{column}"
end
|
.map_384wells ⇒ Object
246
247
248
|
# File 'app/models/map.rb', line 246
def self.map_384wells
Map.where(asset_size: 384)
end
|
.map_96wells ⇒ Object
242
243
244
|
# File 'app/models/map.rb', line 242
def self.map_96wells
Map.where(asset_size: 96)
end
|
.pad_description(map) ⇒ Object
260
261
262
263
264
265
|
# File 'app/models/map.rb', line 260
def self.pad_description(map)
split_description = split_well_description(map.description)
return "#{map.description[0].chr}0#{split_description[:col]}" if split_description[:col] < 10
map.description
end
|
.split_well_description(well_description) ⇒ Object
250
251
252
|
# File 'app/models/map.rb', line 250
def self.split_well_description(well_description)
{ row: well_description.getbyte(0) - 65, col: well_description[1, well_description.size].to_i }
end
|
.strip_description(description) ⇒ Object
Stip any leading zeros from the well name eg. A01 => A1
256
257
258
|
# File 'app/models/map.rb', line 256
def self.strip_description(description)
description.sub(/0(\d)$/, '\1')
end
|
.valid_plate_position_and_plate_size?(well_position, plate_size) ⇒ Boolean
177
178
179
180
181
182
183
|
# File 'app/models/map.rb', line 177
def self.valid_plate_position_and_plate_size?(well_position, plate_size)
return false unless valid_well_position?(well_position)
return false unless valid_plate_size?(plate_size)
return false if well_position > plate_size
true
end
|
.valid_plate_size?(plate_size) ⇒ Boolean
173
174
175
|
# File 'app/models/map.rb', line 173
def self.valid_plate_size?(plate_size)
plate_size.is_a?(Integer) && plate_size > 0
end
|
.valid_well_description_and_plate_size?(well_description, plate_size) ⇒ Boolean
185
186
187
188
189
190
|
# File 'app/models/map.rb', line 185
def self.valid_well_description_and_plate_size?(well_description, plate_size)
return false if well_description.blank?
return false unless valid_plate_size?(plate_size)
true
end
|
.valid_well_position?(well_position) ⇒ Boolean
192
193
194
|
# File 'app/models/map.rb', line 192
def self.valid_well_position?(well_position)
well_position.is_a?(Integer) && well_position > 0
end
|
.vertical_to_horizontal(well_position, plate_size, _plate_shape = nil) ⇒ Object
238
239
240
|
# File 'app/models/map.rb', line 238
def self.vertical_to_horizontal(well_position, plate_size, _plate_shape = nil)
Map::Coordinate.vertical_to_horizontal(well_position, plate_size)
end
|
.walk_plate_in_column_major_order(size, asset_shape = nil) ⇒ Object
Also known as:
walk_plate_vertically
Walking in column major order goes by the columns: A1, B1, C1, … A2, B2, …
274
275
276
277
278
279
|
# File 'app/models/map.rb', line 274
def walk_plate_in_column_major_order(size, asset_shape = nil)
asset_shape ||= AssetShape.default_id
where(asset_size: size, asset_shape_id: asset_shape)
.order(:column_order)
.each { |position| yield(position, position.column_order) }
end
|
.walk_plate_in_row_major_order(size, asset_shape = nil) ⇒ Object
Also known as:
walk_plate_horizontally
Walking in row major order goes by the rows: A1, A2, A3, … B1, B2, B3 .…
283
284
285
286
287
288
|
# File 'app/models/map.rb', line 283
def walk_plate_in_row_major_order(size, asset_shape = nil)
asset_shape ||= AssetShape.default_id
where(asset_size: size, asset_shape_id: asset_shape)
.order(:row_order)
.each { |position| yield(position, position.row_order) }
end
|
Instance Method Details
#column ⇒ Object
Column of particular map location. Zero indexed integer
210
211
212
|
# File 'app/models/map.rb', line 210
def column
row_order % width
end
|
#height ⇒ Object
200
201
202
|
# File 'app/models/map.rb', line 200
def height
asset_shape.plate_height(asset_size)
end
|
#horizontal_plate_position ⇒ Object
220
221
222
|
# File 'app/models/map.rb', line 220
def horizontal_plate_position
row_order + 1
end
|
#row ⇒ Object
Row of particular map location. Zero indexed integer
216
217
218
|
# File 'app/models/map.rb', line 216
def row
column_order % height
end
|
#snp_id ⇒ Object
224
225
226
227
228
|
# File 'app/models/map.rb', line 224
def snp_id
raise StandardError, 'Only standard maps can be converted to SNP' unless map.standard?
horizontal_plate_position
end
|
#vertical_plate_position ⇒ Object
196
197
198
|
# File 'app/models/map.rb', line 196
def vertical_plate_position
column_order + 1
end
|
#width ⇒ Object
204
205
206
|
# File 'app/models/map.rb', line 204
def width
asset_shape.plate_width(asset_size)
end
|