Sha256: 8b67dbbbd1779897e9e1b11dd7ea118331d68b9105cb4c5389e3f3b9eafa85c5
Contents?: true
Size: 765 Bytes
Versions: 2
Compression:
Stored size: 765 Bytes
Contents
module FlexStationData class DefaultSampleMap attr_reader :rows, :columns, :wells_per_sample def initialize(rows, columns, wells_per_sample) @rows = rows @columns = columns @wells_per_sample = wells_per_sample end def [](sample_label) sample_label = Integer(sample_label) map[sample_label] ||= map_sample(sample_label) end private def map_sample(sample_label) column, row = (sample_label - 1).divmod(rows) row_label = ("A".ord + row).chr base_column = (column * wells_per_sample) + 1 (0...wells_per_sample).map do |column_offset| [ row_label, base_column +column_offset ].join("") end end def map @map ||= {} end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
flex-station-data-1.0.1 | lib/flex_station_data/default_sample_map.rb |
flex-station-data-1.0.0 | lib/flex_station_data/default_sample_map.rb |