Module: Cherrypick::VolumeByNanoGrams

Included in:
Well
Defined in:
app/models/cherrypick/volume_by_nano_grams.rb

Overview

rubocop:todo Style/Documentation

Instance Method Summary collapse

Instance Method Details

#volume_to_cherrypick_by_nano_grams(minimum_volume, maximum_volume, target_ng, source_well, robot_minimum_picking_volume = 0.0) ⇒ Object

rubocop:todo Metrics/MethodLength, Metrics/AbcSize


43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'app/models/cherrypick/volume_by_nano_grams.rb', line 43

def volume_to_cherrypick_by_nano_grams(
  minimum_volume,
  maximum_volume,
  target_ng,
  source_well,
  robot_minimum_picking_volume = 0.0
)
  robot_minimum_picking_volume ||= 0.0
  check_inputs_to_volume_to_cherrypick_by_nano_grams!(minimum_volume, maximum_volume, target_ng, source_well)

  source_concentration = source_well.well_attribute.concentration.to_f

  # Current volume, fall back to measured if current not set
  source_volume = source_well.well_attribute.estimated_volume

  desired_volume = source_volume
  unless source_concentration.zero?
    desired_volume = [(target_ng.to_f / source_concentration), robot_minimum_picking_volume].max
  end
  requested_volume = [source_volume, desired_volume].min
  buffer_volume = buffer_volume_required(minimum_volume, requested_volume, robot_minimum_picking_volume)
  requested_volume = maximum_volume if requested_volume > maximum_volume

  well_attribute.current_volume = minimum_volume
  well_attribute.requested_volume = minimum_volume
  well_attribute.picked_volume = requested_volume
  well_attribute.buffer_volume = buffer_volume
  well_attribute.robot_minimum_picking_volume = robot_minimum_picking_volume

  requested_volume
end