Class: LabwareCreators::PooledTubesBySubmissionWithPhiX

Inherits:
PooledTubesBySubmission show all
Includes:
CustomPage
Defined in:
app/models/labware_creators/pooled_tubes_by_submission_with_phi_x.rb

Overview

Includes the addition of PhiX, a specific type of control sample. User scans SpikedBuffer tube containing PhiX into an interstitial page, on tube creation. SpikedBuffer tube is recorded as a parent of the newly created tube(s).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from LabwareCreators::Base

Instance Attribute Details

#spikedbuffer_tube_barcodeObject

Returns the value of attribute spikedbuffer_tube_barcode.



15
16
17
# File 'app/models/labware_creators/pooled_tubes_by_submission_with_phi_x.rb', line 15

def spikedbuffer_tube_barcode
  @spikedbuffer_tube_barcode
end

Instance Method Details

#create_child_stock_tubesObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/models/labware_creators/pooled_tubes_by_submission_with_phi_x.rb', line 17

def create_child_stock_tubes
  api
    .specific_tube_creation
    .create!(
      user: user_uuid,
      parents: parents,
      child_purposes: [purpose_uuid] * pool_uuids.length,
      tube_attributes: tube_attributes
    )
    .children
    .index_by(&:name)
end

#parentsObject



30
31
32
33
34
# File 'app/models/labware_creators/pooled_tubes_by_submission_with_phi_x.rb', line 30

def parents
  parents = [parent_uuid]
  parents << scanned_tube.uuid if spikedbuffer_tube_barcode.present?
  parents
end

#scanned_tubeObject

Only call this method if the spikedbuffer_tube_barcode is present



45
46
47
48
# File 'app/models/labware_creators/pooled_tubes_by_submission_with_phi_x.rb', line 45

def scanned_tube
  search_params = { barcode: spikedbuffer_tube_barcode }
  @scanned_tube ||= Sequencescape::Api::V2::Tube.find_by(search_params)
end

#tube_must_be_spiked_bufferObject

It is valid to not provide a spikedbuffer_tube_barcode, but if provided out it must make sense



37
38
39
40
41
42
# File 'app/models/labware_creators/pooled_tubes_by_submission_with_phi_x.rb', line 37

def tube_must_be_spiked_buffer
  return if spikedbuffer_tube_barcode.blank?

  errors.add(:base, "A tube with that barcode couldn't be found.") if scanned_tube.blank?
  # TODO: add validation to check tube is SpikedBuffer (requires change to SS V2 API)
end