Class: Sequencescape::Api::V2::Plate

Inherits:
Base
  • Object
show all
Includes:
Shared::HasBarcode, Shared::HasPurpose, Shared::HasRequests, Shared::HasWorklineIdentifier, WellHelpers::Extensions
Defined in:
app/sequencescape/sequencescape/api/v2/plate.rb

Overview

A plate from sequencescape via the V2 API

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find_all(options, includes: DEFAULT_INCLUDES) ⇒ Object



36
37
38
# File 'app/sequencescape/sequencescape/api/v2/plate.rb', line 36

def self.find_all(options, includes: DEFAULT_INCLUDES)
  Sequencescape::Api::V2::Plate.includes(*includes).where(**options).all
end

.find_by(options) ⇒ Object



32
33
34
# File 'app/sequencescape/sequencescape/api/v2/plate.rb', line 32

def self.find_by(options)
  Sequencescape::Api::V2.plate_for_presenter(**options)
end

Instance Method Details

#active_requestsObject

Note:

JG 17/09/2020

Active requests are determined on a per-well level This is to maintain pre-existing behaviour. What this means: In progress requests (those not passed or failed) take precedence over those which are passed/failed. Currently: This happens on a per-well level, which means if well A1 only has completed requests, and yet B1 has in-progress requests out of it, then both A1s completed requests, and B1s in progress requests will be listed. Alternatively: Remove this and even a single in progress request for any well will take precedence. In theory this probably makes more sense but in practice we tend to operate on the plate as a whole.



67
68
69
# File 'app/sequencescape/sequencescape/api/v2/plate.rb', line 67

def active_requests
  @active_requests ||= wells.flat_map(&:active_requests)
end

#columns_rangeObject Originally defined in module WellHelpers::Extensions

#each_well_and_aliquotObject



126
127
128
# File 'app/sequencescape/sequencescape/api/v2/plate.rb', line 126

def each_well_and_aliquot
  wells.each { |well| well.aliquots.each { |aliquot| yield well, aliquot } }
end

#locations_in_rowsObject Originally defined in module WellHelpers::Extensions

#model_nameActiveModel::Name

Override the model used in form/URL helpers to allow us to treat old and new api the same

Returns:

  • (ActiveModel::Name)

    The resource behaves like a Limber::Plate



46
47
48
# File 'app/sequencescape/sequencescape/api/v2/plate.rb', line 46

def model_name
  ::ActiveModel::Name.new(Limber::Plate, false)
end

#poolsObject



122
123
124
# File 'app/sequencescape/sequencescape/api/v2/plate.rb', line 122

def pools
  @pools ||= generate_pools
end

#primer_panelObject



118
119
120
# File 'app/sequencescape/sequencescape/api/v2/plate.rb', line 118

def primer_panel
  primer_panels.first
end

#primer_panelsObject



114
115
116
# File 'app/sequencescape/sequencescape/api/v2/plate.rb', line 114

def primer_panels
  active_requests.map(&:primer_panel).filter_map.uniq
end

#ready_for_automatic_pooling?Boolean

Returns:

  • (Boolean)


88
89
90
# File 'app/sequencescape/sequencescape/api/v2/plate.rb', line 88

def ready_for_automatic_pooling?
  for_multiplexing
end

#ready_for_custom_pooling?Boolean

Returns:

  • (Boolean)


92
93
94
# File 'app/sequencescape/sequencescape/api/v2/plate.rb', line 92

def ready_for_custom_pooling?
  any_complete_requests? || ready_for_automatic_pooling?
end

#rows_rangeObject Originally defined in module WellHelpers::Extensions

#sizeObject



96
97
98
# File 'app/sequencescape/sequencescape/api/v2/plate.rb', line 96

def size
  number_of_rows * number_of_columns
end

#stock_plateObject



104
105
106
107
108
# File 'app/sequencescape/sequencescape/api/v2/plate.rb', line 104

def stock_plate
  return self if stock_plate?

  stock_plates.order(id: :asc).last
end

#stock_plate?(purpose_names: SearchHelper.stock_plate_names) ⇒ Boolean

Returns:

  • (Boolean)


110
111
112
# File 'app/sequencescape/sequencescape/api/v2/plate.rb', line 110

def stock_plate?(purpose_names: SearchHelper.stock_plate_names)
  purpose_names.include?(purpose_name)
end

#stock_plates(purpose_names: SearchHelper.stock_plate_names) ⇒ Object



100
101
102
# File 'app/sequencescape/sequencescape/api/v2/plate.rb', line 100

def stock_plates(purpose_names: SearchHelper.stock_plate_names)
  @stock_plates ||= stock_plate? ? [self] : ancestors.where(purpose_name: purpose_names)
end

#tagged?Boolean

Returns:

  • (Boolean)


84
85
86
# File 'app/sequencescape/sequencescape/api/v2/plate.rb', line 84

def tagged?
  wells.any?(&:tagged?)
end

#to_paramObject

Currently use the uuid as our main identifier, might switch to human barcode soon



51
52
53
# File 'app/sequencescape/sequencescape/api/v2/plate.rb', line 51

def to_param
  uuid
end

#well_at_location(well_location) ⇒ Well?

Returns the well at a specified location.

Parameters:

  • well_location (String)

    The location to find the well at.

Returns:

  • (Well, nil)

    The well at the specified location, or ‘nil` if no well is found at that location.



80
81
82
# File 'app/sequencescape/sequencescape/api/v2/plate.rb', line 80

def well_at_location(well_location)
  wells.detect { |well| well.location == well_location }
end

#wells_in_columnsObject



71
72
73
# File 'app/sequencescape/sequencescape/api/v2/plate.rb', line 71

def wells_in_columns
  @wells_in_columns ||= wells.sort_by(&:coordinate)
end