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
-
#annotations_attributes ⇒ Object
readonly
Returns the value of attribute annotations_attributes.
-
#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
#annotations_attributes ⇒ Object (readonly)
Returns the value of attribute annotations_attributes.
53 54 55 |
# File 'app/models/pacbio/run.rb', line 53 def annotations_attributes @annotations_attributes end |
#plates_attributes ⇒ Object (readonly)
This will return an empty list If plate/well data is required via the run, use ?include=plates.wells
52 53 54 |
# File 'app/models/pacbio/run.rb', line 52 def plates_attributes @plates_attributes end |
Instance Method Details
#adaptive_loading ⇒ Boolean
Returns true if all wells have adaptive loading enabled.
146 147 148 |
# File 'app/models/pacbio/run.rb', line 146 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.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'app/models/pacbio/run.rb', line 100 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
60 61 62 63 64 65 66 67 |
# File 'app/models/pacbio/run.rb', line 60 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
138 139 140 141 142 143 |
# File 'app/models/pacbio/run.rb', line 138 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
71 72 73 |
# File 'app/models/pacbio/run.rb', line 71 def instrument_name system_name end |
#sequencing_kit_box_barcodes ⇒ Array<String>
Returns the barcodes of the sequencing kits.
129 130 131 |
# File 'app/models/pacbio/run.rb', line 129 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’>],
158 159 160 161 |
# File 'app/models/pacbio/run.rb', line 158 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
86 87 88 89 90 91 |
# File 'app/models/pacbio/run.rb', line 86 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’.
121 122 123 124 125 126 |
# File 'app/models/pacbio/run.rb', line 121 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
76 77 78 |
# File 'app/models/pacbio/run.rb', line 76 def wells plates.collect(&:wells).flatten end |