Class: Pacbio::Run
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Pacbio::Run
- Defined in:
- app/models/pacbio/run.rb
Overview
Pacbio::Run
Constant Summary collapse
- NAME_PREFIX =
'TRACTION-RUN-'
Instance Attribute Summary collapse
-
#plates_attributes ⇒ Object
readonly
This will return an empty list If plate/well data is required via the run, use ?include=plates.wells.
Instance Method Summary collapse
-
#adaptive_loading ⇒ Boolean
True if all wells have adaptive loading enabled.
-
#aliquots_to_publish_on_run ⇒ Array
Collects and returns a list of aliquots to be published during a run.
-
#generate_barcodes_and_concentrations ⇒ Object
combines the library concentration or on plate loading concentration with the tube barcode to generate a comment for each well in the run.
-
#generate_sample_sheet ⇒ Object
returns sample sheet csv for a Pacbio::Run using pipelines.yml configuration to generate data.
-
#instrument_name ⇒ Object
v12 has changed to use instrument_name We can’t alias it as it is an enum.
-
#sequencing_kit_box_barcodes ⇒ Array<String>
The barcodes of the sequencing kits.
-
#sorted_wells ⇒ Object
Returns a list of wells associated with all plates which are sorted by plate first and then by wells in column order Example: ([<Plate plate_number:1> [<Well position:‘A1’>, <Well position:‘A2’>,<Well position:‘B1’>]<Plate> <Plate plate_number:2> [<Well position:‘A3’>, <Well position:‘A4’>,<Well position:‘B3’>]<Plate>]) => [<Well position:‘A1’>, <Well position:‘B1’>, <Well position:‘A2’>,<Well position:‘A3’> <Well position:‘A3’>,<Well position:‘B3’>,<Well position:‘A4’>],.
-
#update_smrt_link_options(options) ⇒ Integer
updates the smrt link options for all of the wells in the run returns the number of wells updated each well is saved after the update it is inefficient to save each well individually but this is not used by the UI.
-
#used_aliquots_lib_source_in_pool(pools) ⇒ Array
This method filters and retrieves all aliquots from a given collection of pools where the aliquot’s source is of type ‘Pacbio::Library’.
-
#wells ⇒ Object
This is needed to generate the comments.
Methods included from Uuidable
Instance Attribute Details
#plates_attributes ⇒ Object (readonly)
This will return an empty list If plate/well data is required via the run, use ?include=plates.wells
48 49 50 |
# File 'app/models/pacbio/run.rb', line 48 def plates_attributes @plates_attributes end |
Instance Method Details
#adaptive_loading ⇒ Boolean
Returns true if all wells have adaptive loading enabled.
141 142 143 |
# File 'app/models/pacbio/run.rb', line 141 def adaptive_loading wells.all? { |w| w.use_adaptive_loading == 'True' } end |
#aliquots_to_publish_on_run ⇒ Array
Collects and returns a list of aliquots to be published during a run.
It iterates over all plates associated with the run, and for each plate, it collects
the used aliquots from the wells. It also collects the used aliquots from the wells that have a source type of ‘Pacbio::Pool’ and further collects the used aliquots from these pools that have a source type of ‘Pacbio::Library’. and aliquots that have a source of ‘Pacbio::Library’ within those pools.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'app/models/pacbio/run.rb', line 95 def aliquots_to_publish_on_run [].tap do |to_publish| plates.flat_map do |plate| # Collect all used aliquots from the plate used_aliquots = plate.wells.flat_map(&:used_aliquots) # Collect all used aliquots from the plate that have a source of 'Pacbio::Pool' used_aliquots_pool_source = used_aliquots .select { |aliquot| aliquot.source_type == 'Pacbio::Pool' } # Aggregate all used aliquots from the plate and used aliquots from the pool with # a source of 'Pacbio::Library' to_publish.concat(used_aliquots, used_aliquots_lib_source_in_pool(used_aliquots_pool_source)) end end end |
#generate_barcodes_and_concentrations ⇒ Object
combines the library concentration or on plate loading concentration with the tube barcode to generate a comment for each well in the run
55 56 57 58 59 60 61 62 |
# File 'app/models/pacbio/run.rb', line 55 def = wells.collect do |well| concentration = well.library_concentration || well.on_plate_loading_concentration "#{well.used_aliquots.first.source.tube.} #{concentration}pM" end.join(' ') update(barcodes_and_concentrations: ) end |
#generate_sample_sheet ⇒ Object
returns sample sheet csv for a Pacbio::Run using pipelines.yml configuration to generate data
133 134 135 136 137 138 |
# File 'app/models/pacbio/run.rb', line 133 def generate_sample_sheet configuration = Pipelines.pacbio.sample_sheet.by_version(smrt_link_version.name) sample_sheet_class = "RunCsv::#{configuration.sample_sheet_class}".constantize sample_sheet = sample_sheet_class.new(object: self, configuration:) sample_sheet.payload end |
#instrument_name ⇒ Object
v12 has changed to use instrument_name We can’t alias it as it is an enum
66 67 68 |
# File 'app/models/pacbio/run.rb', line 66 def instrument_name system_name end |
#sequencing_kit_box_barcodes ⇒ Array<String>
Returns the barcodes of the sequencing kits.
124 125 126 |
# File 'app/models/pacbio/run.rb', line 124 def plates.map { |p| "Plate #{p.plate_number}: #{p.}" } end |
#sorted_wells ⇒ Object
Returns a list of wells associated with all plates which are sorted by plate first and then by wells in column order Example: ([<Plate plate_number:1> [<Well position:‘A1’>, <Well position:‘A2’>,<Well position:‘B1’>]<Plate> <Plate plate_number:2> [<Well position:‘A3’>, <Well position:‘A4’>,<Well position:‘B3’>]<Plate>]) => [<Well position:‘A1’>, <Well position:‘B1’>, <Well position:‘A2’>,<Well position:‘A3’> <Well position:‘A3’>,<Well position:‘B3’>,<Well position:‘A4’>],
153 154 155 156 |
# File 'app/models/pacbio/run.rb', line 153 def sorted_wells sorted_plates = plates.sort_by(&:plate_number) sorted_plates.flat_map { |plate| plate.wells.sort_by { |well| [well.column.to_i, well.row] } } end |
#update_smrt_link_options(options) ⇒ Integer
updates the smrt link options for all of the wells in the run returns the number of wells updated each well is saved after the update it is inefficient to save each well individually but this is not used by the UI
81 82 83 84 85 86 |
# File 'app/models/pacbio/run.rb', line 81 def () wells.each do |well| well.() end wells.count end |
#used_aliquots_lib_source_in_pool(pools) ⇒ Array
This method filters and retrieves all aliquots from a given collection of pools where the aliquot’s source is of type ‘Pacbio::Library’.
116 117 118 119 120 121 |
# File 'app/models/pacbio/run.rb', line 116 def used_aliquots_lib_source_in_pool(pools) pools.flat_map(&:source).flat_map(&:used_aliquots) .select do |aliquot| aliquot.source_type == 'Pacbio::Library' end end |
#wells ⇒ Object
This is needed to generate the comments
71 72 73 |
# File 'app/models/pacbio/run.rb', line 71 def wells plates.collect(&:wells).flatten end |