Module: ModelExtensions::Plate

Included in:
Plate
Defined in:
app/api/model_extensions/plate.rb

Overview

Included in Plate The intent of this file was to provide methods specific to the V1 API

Defined Under Namespace

Modules: NamedScopeHelpers

Constant Summary collapse

PLATE_INCLUDES =
:plate_metadata, { wells: %i[map transfer_requests_as_target uuid_object] }].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object


14
15
16
17
18
19
20
# File 'app/api/model_extensions/plate.rb', line 14

def self.included(base)
  base.class_eval do
    scope :include_plate_purpose, -> { includes(:plate_purpose) }
    scope :include_plate_metadata, -> { includes(:plate_metadata) }
    delegate :pool_id_for_well, to: :plate_purpose, allow_nil: true
  end
end

Instance Method Details

#library_source_plateObject


22
23
24
# File 'app/api/model_extensions/plate.rb', line 22

def library_source_plate
  plate_purpose.library_source_plate(self)
end

#library_source_platesObject


26
27
28
# File 'app/api/model_extensions/plate.rb', line 26

def library_source_plates
  plate_purpose.library_source_plate(self)
end

#poolsObject

Returns a hash from the submission for the pools to the wells that form that pool on this plate. This is not necessarily efficient but it is correct. Unpooled wells, those without submissions, are completely ignored within the returned result.


33
34
35
36
37
38
39
40
41
42
43
# File 'app/api/model_extensions/plate.rb', line 33

def pools
  Request
    .
    .for_pooling_of(self)
    .each_with_object({}) do |request, pools|
      pools[request.pool_id] =
        { wells: request.pool_into.split(','), pool_complete: request.pool_complete == 1 }.tap do |pool_information|
          request.update_pool_information(pool_information)
        end unless request.pool_id.nil?
    end
end

#pre_cap_groupsObject

Adds pre-capture pooling information, we need to delegate this to the stock plate, as we need all the wells Currently used in Transfer::BetweenPlates to set submission id, we should switch to doing this directly via Limber with transfer request collections


48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'app/api/model_extensions/plate.rb', line 48

def pre_cap_groups # rubocop:todo Metrics/AbcSize
  Request
    .
    .for_pre_cap_grouping_of(self)
    .each_with_object({}) do |request, groups|
      groups[request.group_id] =
        { wells: request.group_into.split(',') }.tap do |pool_information|
          pool_information[:pre_capture_plex_level] ||= request..pre_capture_plex_level

          # We supply the submission id to assist with correctly tagging transfer requests later
          pool_information[:submission_id] ||= request.submission_id
        end unless request.group_id.nil?
    end
end