class BioPlates::Plate::Well

Attributes

annotation[RW]
column[RW]
row[RW]
well[RW]

Public Class Methods

new(hash) click to toggle source
# File lib/bio-plates/plates.rb, line 123
def initialize(hash)

  if hash[:row] && hash[:column]
    @row = hash[:row]
    @column = hash[:column].to_s
  else
    # Split the well annotation if row & col not given separately
    m = hash[:well].match(@@regexp)
    @well = hash[:well]
    @row = m[:row]
    @column = m[:column]
  end
  # NB annotation includes the original well annotation
  @annotation = hash.delete_if{|k,f| [:row, :column, :well].include? k}.to_h
end

Public Instance Methods

index!() click to toggle source
# File lib/bio-plates/plates.rb, line 139
def index!
  @well = @row.upcase.to_s + @column
end
quadrantize(plate) click to toggle source
# File lib/bio-plates/plates.rb, line 155
def quadrantize(plate)
  dup = self.dup
  dup.quadrantize!(plate)
end
quadrantize!(plate) click to toggle source
# File lib/bio-plates/plates.rb, line 143
def quadrantize!(plate)
  self.index! unless @well
  @annotation[:original_well] = @well
  @annotation[:original_plate] = @annotation[:plate]
  @annotation.delete(:plate) # Remove so no conflict with new plate
  (plate == 2 || plate == 4) ? inc = 1 : inc = 0
  (plate == 3 || plate == 4) ? rowinc = 1 : rowinc = 0
  @column = (@column.to_i + [*0..@@ncol][@column.to_i-1]+inc).to_s
  @row = (@row.ord + [*0..@@nrow][@row.upcase.ord-65]+rowinc).chr # 65 = ASCII "A"
  self
end