Module: PhiX
- Defined in:
- app/models/phi_x.rb
Overview
PhiX
PhiX is a well characterized bacteriophage with a small, known, genome. It is used to provide short DNA sequences which can get added to sequencing lanes for control and calibration purposes.
Process
PhiX samples arrive on site and have tags applied as required. These may be single indexed (i7 only) or dual indexed (i5 & i7) as required. The single and dual indexed tag sets are fixed and are selected from the 'Control Tag Group 888' TagGroup.
Library information is filled in on the PhiXesController#show page and one or more library tubes are generated via StocksController#create and the Stock factory. These tubes are considered stocks, and get transferred to the sequencing teams.
Subsequently the sequencing team will split the contents of each LibraryTube into a number of SpikedBuffer tubes, adjusting the volume and concentration as required. This is achieved via a separate form on the PhiXesController#show page, followed by SpikedBuffersController#create and the SpikedBuffer factory.
Finally, during the processing of a SequencingPipeline the SpikedBuffer barcode is scanned in during the AddSpikedInControlTask. This adds the SpikedBuffer in as a parent of each Lane in the Batch, which in turn ensures the control can be found by batch.xml generation and Api::Messages::FlowcellIO.
Configuration
Configuration and values are stored in config/phi_x.yml tag_group_name: The name of the tag group to use tag_map_id: The default map_id for tags tag_options: Hash of available tag options, indexed by option name. Values are hashes of i5 and i7 oligos. null indicates no tag. default_tag_option: The option which will be initially selected
Defined Under Namespace
Classes: SpikedBuffer, SpikedBuffersController, Stock, StocksController
Class Method Summary collapse
-
.configuration ⇒ Hash
Returns the configuration as defined in phi_x.
- .default_study_option ⇒ Object
-
.default_tag_option ⇒ String
Returns the default tag option which will be automatically selected when generating new PhiX stocks.
-
.find_tag(tag_option, tag_type) ⇒ Tag?
Returns the appropriate tag or creates it if it doesn't exist.
-
.sample ⇒ Sample
Returns the sample the represents PhiX, creates it if it doesn't exist.
-
.spiked_buffer_purpose ⇒ Tube::Purpose
Returns the purpose used to generate new PhiX SpikedBuffers creates it if it doesn't exist.
-
.stock_purpose ⇒ Tube::Purpose
Returns the purpose used to generate new PhiX Stocks creates it if it doesn't exist.
-
.studies ⇒ Study::ActiveRecord_Relation
Returns the studies that can be used to register PhiX.
-
.tag_group ⇒ TagGroup
Returns the tag group for PhiX tags or creates it if it doesn't exist.
-
.tag_option_for(i7_oligo:, i5_oligo:) ⇒ String
Performs a lookup of the tag option matching the given oligo pair.
-
.tag_option_names ⇒ Array
Returns the names of valid tag options for creation of PhiX libraries.
-
.tag_options ⇒ Hash
Returns the tag_options configured.
Class Method Details
.configuration ⇒ Hash
Returns the configuration as defined in phi_x
44 45 46 |
# File 'app/models/phi_x.rb', line 44 def self.configuration Rails.application.config.phi_x end |
.default_study_option ⇒ Object
100 101 102 |
# File 'app/models/phi_x.rb', line 100 def self.default_study_option Study.find_by(name: configuration[:default_study_option]) end |
.default_tag_option ⇒ String
Returns the default tag option which will be automatically selected when generating new PhiX stocks
64 65 66 |
# File 'app/models/phi_x.rb', line 64 def self.default_tag_option configuration[:default_tag_option] end |
.find_tag(tag_option, tag_type) ⇒ Tag?
Returns the appropriate tag or creates it if it doesn't exist.
123 124 125 126 127 128 |
# File 'app/models/phi_x.rb', line 123 def self.find_tag(tag_option, tag_type) oligo = .dig(tag_option.to_sym, tag_type) return nil if oligo.nil? tag_group..create_with(map_id: configuration[:tag_map_id]).find_or_create_by!(oligo:) end |
.sample ⇒ Sample
Returns the sample the represents PhiX, creates it if it doesn't exist
84 85 86 |
# File 'app/models/phi_x.rb', line 84 def self.sample Sample.find_or_create_by!(name: 'phiX_for_spiked_buffers') end |
.spiked_buffer_purpose ⇒ Tube::Purpose
Returns the purpose used to generate new PhiX SpikedBuffers creates it if it doesn't exist
78 79 80 |
# File 'app/models/phi_x.rb', line 78 def self.spiked_buffer_purpose Tube::Purpose.create_with(target_type: 'SpikedBuffer').find_or_create_by(name: 'PhiX Spiked Buffer') end |
.stock_purpose ⇒ Tube::Purpose
Returns the purpose used to generate new PhiX Stocks creates it if it doesn't exist
71 72 73 |
# File 'app/models/phi_x.rb', line 71 def self.stock_purpose Tube::Purpose.create_with(target_type: 'LibraryTube').find_or_create_by(name: 'PhiX Stock') end |
.studies ⇒ Study::ActiveRecord_Relation
Returns the studies that can be used to register PhiX
96 97 98 |
# File 'app/models/phi_x.rb', line 96 def self.studies Study.where(name: configuration[:studies]) end |
.tag_group ⇒ TagGroup
Returns the tag group for PhiX tags or creates it if it doesn't exist
90 91 92 |
# File 'app/models/phi_x.rb', line 90 def self.tag_group TagGroup.find_or_create_by!(name: configuration[:tag_group_name]) end |
.tag_option_for(i7_oligo:, i5_oligo:) ⇒ String
Performs a lookup of the tag option matching the given oligo pair. If no option can be found returns: UNKOWN i7:i7_olgo i5:i5_oligo
112 113 114 115 |
# File 'app/models/phi_x.rb', line 112 def self.tag_option_for(i7_oligo:, i5_oligo:) .deep_symbolize_keys.key(i7_oligo:, i5_oligo:)&.to_s || "UNKNOWN i7:#{i7_oligo || '-'} i5:#{i5_oligo || '-'}" end |
.tag_option_names ⇒ Array
Returns the names of valid tag options for creation of PhiX libraries.
57 58 59 |
# File 'app/models/phi_x.rb', line 57 def self.tag_option_names .keys.map(&:to_s) end |
.tag_options ⇒ Hash
Returns the tag_options configured.
51 52 53 |
# File 'app/models/phi_x.rb', line 51 def self. configuration[:tag_options] end |