Module: ModelExtensions::Plate

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

Defined Under Namespace

Modules: NamedScopeHelpers

Constant Summary collapse

PLATE_INCLUDES =
[
  :plate_metadata, {
    wells: [
      :map,
      :transfer_requests_as_target,
      :uuid_object
    ]
  }
]

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object


18
19
20
21
22
23
24
# File 'app/api/model_extensions/plate.rb', line 18

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


34
35
36
# File 'app/api/model_extensions/plate.rb', line 34

def library_source_plate
  plate_purpose.library_source_plate(self)
end

#library_source_platesObject


38
39
40
# File 'app/api/model_extensions/plate.rb', line 38

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.


45
46
47
48
49
50
51
52
53
54
# File 'app/api/model_extensions/plate.rb', line 45

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


59
60
61
62
63
64
65
66
67
# File 'app/api/model_extensions/plate.rb', line 59

def pre_cap_groups
  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

#source_plateObject


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

def source_plate
  plate_purpose.source_plate(self)
end

#source_platesObject


30
31
32
# File 'app/api/model_extensions/plate.rb', line 30

def source_plates
  plate_purpose.source_plates(self)
end