Sha256: 2c7f005b0323473da0794c56147bcc8c630eaa3af68006fd0bcc7f65dfa3325b
Contents?: true
Size: 927 Bytes
Versions: 2
Compression:
Stored size: 927 Bytes
Contents
require "matrix" require "active_support/core_ext" require "flex_station_data/concerns/service" module FlexStationData class ParseSampleMap include Concerns::Service attr_reader :plate_data def initialize(plate_data) @plate_data = plate_data end def sample_map_rows plate_data .drop_while { |row| !sample_map_header?(row) } .drop(1) .take_while { |row| !empty_row?(row) } .map(&method(:parse_row)) end def call sample_map_rows.each_with_object([]) do |(label, well), memo| memo << [ label, [] ] if label.present? memo.last.last << well end.to_h end private def parse_row(row) row.take(2).map(&:presence) end def empty_row?(row) row.all?(&:blank?) end def sample_map_header?(row) row[0].to_s =~ /\A\s*Sample\s*\z/i && row[1].to_s =~ /\A\s*Wells\s*\z/i 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/services/parse_sample_map.rb |
flex-station-data-1.0.0 | lib/flex_station_data/services/parse_sample_map.rb |