Class: PhiX::SpikedBuffer
- Inherits:
-
Object
- Object
- PhiX::SpikedBuffer
- Includes:
- ActiveModel::Model
- Defined in:
- app/models/phi_x/spiked_buffer.rb
Overview
PhiX is a short DNA fragment of known sequence which gets added into lanes of sequencing to provide a control. PhiX arrives on site in bulk where it is tagged with a fixed i7 tag, or fixed i5 and i7 tags. - When this occurs one or more library tubes are created in Sequencescape each containing an aliquot of the PhiX Sample (See #sample) with the appropriate tags applied. - At a later date, the LibraryTube Barcode is scanned in to Sequencescape and is used to create one or more tubes of SpikedBuffer. - Finally these tubes get used in the AddSpikedInControlTask during the SequencingPipeline
This controller handles the rendering of the two forms for creating the LibraryTube and the SpikedBuffer. Actual creation is handled by the respective controllers. Stock and SpikedBuffer act as factories
PhiX::SpikedBuffer acts as a factory to generate the required spiked buffer
Instance Attribute Summary collapse
-
#concentration ⇒ Float
The concentration of the created library in nM.
-
#name ⇒ String
The base name for the created library tubes Will be appended with #n to distinguish multiple tubes.
-
#number ⇒ Integer
The number of library tubes to create.
-
#parent ⇒ Tube
Returns the provided parent, or the matching tube found via the parent_barcode.
-
#parent_barcode ⇒ String
has been created.
- #study_id ⇒ Integer
-
#volume ⇒ Float
The volume of the created library in ul.
Instance Method Summary collapse
-
#created_spiked_buffers ⇒ Array
Returns the spiked_buffers that were create as part of #save Will be an empty array if called before the #save method.
-
#parent_contains_phi_x ⇒ Object
Validates the contents of the parent The parent MUST contain one aliquot, and it MUST be a PhiX sample This MAY be a stock, or a previously created spiked buffer.
-
#save ⇒ Boolean
Generates spiked buffers if the factory is valid, otherwise returns false and does nothing.
- #tags ⇒ Object
Instance Attribute Details
#concentration ⇒ Float
Returns The concentration of the created library in nM.
19 20 21 |
# File 'app/models/phi_x/spiked_buffer.rb', line 19 def concentration @concentration end |
#name ⇒ String
Returns the base name for the created library tubes Will be appended with #n to distinguish multiple tubes. eg. (‘Tube name #1’, ‘Tube name #2’).
12 13 14 |
# File 'app/models/phi_x/spiked_buffer.rb', line 12 def name @name end |
#number ⇒ Integer
Returns The number of library tubes to create.
25 26 27 |
# File 'app/models/phi_x/spiked_buffer.rb', line 25 def number @number end |
#parent ⇒ Tube
Returns the provided parent, or the matching tube found via the parent_barcode
64 65 66 |
# File 'app/models/phi_x/spiked_buffer.rb', line 64 def parent @parent ||= Tube.includes(aliquots: %i[sample tag tag2]).() end |
#parent_barcode ⇒ String
has been created
16 17 18 |
# File 'app/models/phi_x/spiked_buffer.rb', line 16 def @parent_barcode end |
#study_id ⇒ Integer
31 32 33 |
# File 'app/models/phi_x/spiked_buffer.rb', line 31 def study_id @study_id end |
#volume ⇒ Float
Returns The volume of the created library in ul.
22 23 24 |
# File 'app/models/phi_x/spiked_buffer.rb', line 22 def volume @volume end |
Instance Method Details
#created_spiked_buffers ⇒ Array
Returns the spiked_buffers that were create as part of #save Will be an empty array if called before the #save method
56 57 58 |
# File 'app/models/phi_x/spiked_buffer.rb', line 56 def created_spiked_buffers @created_spiked_buffers || [] end |
#parent_contains_phi_x ⇒ Object
Validates the contents of the parent The parent MUST contain one aliquot, and it MUST be a PhiX sample This MAY be a stock, or a previously created spiked buffer
71 72 73 74 75 |
# File 'app/models/phi_x/spiked_buffer.rb', line 71 def parent_contains_phi_x return true if parent.aliquots.one? && parent.aliquots.all? { |aliquot| aliquot.sample == PhiX.sample } errors.add(:parent_barcode, 'does not contain PhiX') end |
#save ⇒ Boolean
Generates spiked buffers if the factory is valid, otherwise returns false and does nothing
44 45 46 47 48 49 |
# File 'app/models/phi_x/spiked_buffer.rb', line 44 def save return false unless valid? @created_spiked_buffers = generate_spiked_buffers true end |
#tags ⇒ Object
77 78 79 80 |
# File 'app/models/phi_x/spiked_buffer.rb', line 77 def i7_oligo, i5_oligo = parent.aliquots.first. PhiX.tag_option_for(i7_oligo:, i5_oligo:) end |