Class: Utility::CommonDilutionCalculations::Binner

Inherits:
Object
  • Object
show all
Defined in:
app/models/utility/common_dilution_calculations.rb

Overview

Class used by calculators that perform binning of wells according to concentration. Handles the determination of the next well location for bins.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(compression_reqd, number_of_rows) ⇒ Binner

Sets up an instance of the Binner class for a plate.

new bin in a new column. Depends on number of bins and wells containing aliquots on the plate.

Parameters:

  • compression_reqd (bool)

    Whether the binning should be compressed, or start each

  • number_of_rows (int)

    Number of rows on the plate.



162
163
164
165
166
167
168
# File 'app/models/utility/common_dilution_calculations.rb', line 162

def initialize(compression_reqd, number_of_rows)
  @compression_reqd = compression_reqd
  @number_of_rows = number_of_rows
  @row = 0
  @column = 0
  validate_initial_arguments
end

Instance Attribute Details

#columnObject

Returns the value of attribute column.



152
153
154
# File 'app/models/utility/common_dilution_calculations.rb', line 152

def column
  @column
end

#rowObject

Returns the value of attribute row.



152
153
154
# File 'app/models/utility/common_dilution_calculations.rb', line 152

def row
  @row
end

Instance Method Details

#next_well_location(index_within_bin, bin_size) ⇒ Object

Work out what the next well location will be. This depends on whether we are in the last well of a bin, whether compression is required, and whether we are in the last row of the plate and will need to start a new column. NB. rows and columns are zero-based here.

Parameters:

  • index_within_bin (int)

    The index of the well within the current bin.

  • bin_size (int)

    The number of wells in the bin.

Returns:

  • nothing Sets the next row and column in the Binner instance.



181
182
183
184
185
186
187
188
189
190
191
# File 'app/models/utility/common_dilution_calculations.rb', line 181

def next_well_location(index_within_bin, bin_size)
  validate_next_well_arguments(index_within_bin, bin_size)

  if index_within_bin == bin_size - 1
    # last well in bin, so next well location depends on whether compression is required
    @compression_reqd ? determine_next_available_location : reset_to_top_of_next_column
  else
    # there are more wells yet in this bin so continue
    determine_next_available_location
  end
end