Class: PhiX::SpikedBuffer

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Instance Attribute Details

#concentrationFloat

Returns The concentration of the created library in nM.

Returns:

  • (Float)

    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

#nameString

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’).

Returns:

  • (String)

    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

#numberInteger

Returns The number of library tubes to create.

Returns:



25
26
27
# File 'app/models/phi_x/spiked_buffer.rb', line 25

def number
  @number
end

#parentTube

Returns the provided parent, or the matching tube found via the parent_barcode

Returns:

  • (Tube)

    The parent tube



64
65
66
# File 'app/models/phi_x/spiked_buffer.rb', line 64

def parent
  @parent ||= Tube.includes(aliquots: %i[sample tag tag2]).find_by_barcode(parent_barcode)
end

#parent_barcodeString

has been created

Returns:

  • (String)

    The barcode of the LibraryTube from which the SpikedBuffer



16
17
18
# File 'app/models/phi_x/spiked_buffer.rb', line 16

def parent_barcode
  @parent_barcode
end

#study_idInteger

Returns The id of the Study to associate with the Aliquot.

Returns:

  • (Integer)

    The id of the Study to associate with the Aliquot



31
32
33
# File 'app/models/phi_x/spiked_buffer.rb', line 31

def study_id
  @study_id
end

#volumeFloat

Returns The volume of the created library in ul.

Returns:

  • (Float)

    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_buffersArray

Returns the spiked_buffers that were create as part of #save Will be an empty array if called before the #save method

Returns:

  • (Array)

    Array of the spiked_buffers created by the factory.



56
57
58
# File 'app/models/phi_x/spiked_buffer.rb', line 56

def created_spiked_buffers
  @created_spiked_buffers || []
end

#parent_contains_phi_xObject

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

#saveBoolean

Generates spiked buffers if the factory is valid, otherwise returns false and does nothing

Returns:

  • (Boolean)

    true if the operation completed successfully, false otherwise



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

#tagsObject



77
78
79
80
# File 'app/models/phi_x/spiked_buffer.rb', line 77

def tags
  i7_oligo, i5_oligo = parent.aliquots.first.tags_combination
  PhiX.tag_option_for(i7_oligo:, i5_oligo:)
end