Class: Asset
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Asset
- Extended by:
- EventfulRecord
- Includes:
- Api::Messages::QcResultIo::AssetExtensions, Event::PlateEvents
- Defined in:
- app/models/asset.rb
Overview
Asset is a very busy class which combines what should probably be two separate concepts: Labware: A physical item which can move round the lab, such as a Plate or Tube
This class has now been split into two and should be eliminated.
Key subclasses
-
Receptacle: Something which can contain aliquots, such as a Well or Tube Currently those these all share a table, and exhibit single table inheritance.
-
Plate: A piece of labware containing multiple receptacles known as wells. Plates can be a variety of shapes and sizes, although the marority are 128 (96) or 2416 (384) wells in size.
-
Well: A receptacle on a plate. Wells themselves do not exist independently of plates in reality, although may occasionally be modelled as such.
-
Tube: A piece of labware with a single Receptacle. These behaviours are currently coupled together.
-
Lane: Forms part of a sequencing Flowcell. The flowcell itself is not currently modelled but can be approximated by a Batch
-
Fragment: Represents an isolated segment of DNA on a Gel. Historical.
-
Receptacle: Abstract class inherited by any asset which can contain stuff directly
Some of the above are further subclasses to handle specific behaviours.
Direct Known Subclasses
Defined Under Namespace
Modules: ApplyIdToNameOnCreate, Ownership, SharedLibraryTubeBehaviour, Stock Classes: Finder
Instance Method Summary collapse
- #ancestor_of_purpose(_ancestor_purpose_id) ⇒ Object
-
#asset_type_for_request_types ⇒ Object
Returns the type of asset that can be considered appropriate for request types.
-
#barcode_number ⇒ Object
Most assets don’t have a barcode.
- #compatible_purposes ⇒ Object
- #contained_samples ⇒ Object
- #details ⇒ Object
-
#generate_barcode ⇒ Object
By default only barcodeable assets generate barcodes.
- #get_qc_result_value_for(key) ⇒ Object
- #has_stock_asset? ⇒ Boolean
- #label ⇒ Object
- #label=(new_type) ⇒ Object
- #original_stock_plates ⇒ Object
- #prefix ⇒ Object
- #printable? ⇒ Boolean
- #printable_target ⇒ Object
-
#register_stock! ⇒ Object
Generates a message to broadcast the tube to the stock warehouse tables.
- #request_types ⇒ Object
- #type ⇒ Object
- #update_from_qc(qc_result) ⇒ Object
Methods included from EventfulRecord
has_many_events, has_many_lab_events, has_one_event_with_family
Methods included from Event::PlateEvents
#event_date, #fluidigm_stamp_date, #gel_qc_date, #pico_date, #qc_started_date, #sequenom_stamp_date
Methods inherited from ApplicationRecord
alias_association, convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!
Methods included from Squishify
Instance Method Details
#ancestor_of_purpose(_ancestor_purpose_id) ⇒ Object
89 90 91 92 |
# File 'app/models/asset.rb', line 89 def ancestor_of_purpose(_ancestor_purpose_id) # If it's not a tube or a plate, defaults to stock_plate stock_plate end |
#asset_type_for_request_types ⇒ Object
Returns the type of asset that can be considered appropriate for request types.
85 86 87 |
# File 'app/models/asset.rb', line 85 def asset_type_for_request_types self.class end |
#barcode_number ⇒ Object
Most assets don’t have a barcode
123 124 125 |
# File 'app/models/asset.rb', line 123 def nil end |
#compatible_purposes ⇒ Object
118 119 120 |
# File 'app/models/asset.rb', line 118 def compatible_purposes Purpose.none end |
#contained_samples ⇒ Object
136 137 138 |
# File 'app/models/asset.rb', line 136 def contained_samples Sample.none end |
#details ⇒ Object
106 107 108 |
# File 'app/models/asset.rb', line 106 def details nil end |
#generate_barcode ⇒ Object
By default only barcodeable assets generate barcodes
132 133 134 |
# File 'app/models/asset.rb', line 132 def nil end |
#get_qc_result_value_for(key) ⇒ Object
172 173 174 |
# File 'app/models/asset.rb', line 172 def get_qc_result_value_for(key) last_qc_result_for(key).pick(:value) end |
#has_stock_asset? ⇒ Boolean
114 115 116 |
# File 'app/models/asset.rb', line 114 def has_stock_asset? false end |
#label ⇒ Object
94 95 96 |
# File 'app/models/asset.rb', line 94 def label sti_type || 'Unknown' end |
#label=(new_type) ⇒ Object
98 99 100 |
# File 'app/models/asset.rb', line 98 def label=(new_type) self.sti_type = new_type end |
#original_stock_plates ⇒ Object
110 111 112 |
# File 'app/models/asset.rb', line 110 def original_stock_plates ancestors.where(plate_purpose_id: PlatePurpose.stock_plate_purpose) end |
#prefix ⇒ Object
127 128 129 |
# File 'app/models/asset.rb', line 127 def prefix nil end |
#printable? ⇒ Boolean
140 141 142 |
# File 'app/models/asset.rb', line 140 def printable? printable_target.present? end |
#printable_target ⇒ Object
144 145 146 |
# File 'app/models/asset.rb', line 144 def printable_target nil end |
#register_stock! ⇒ Object
Generates a message to broadcast the tube to the stock warehouse tables. Raises an exception if no template is configured for a give asset. In most cases this is because the asset is not a stock Called when importing samples, e.g. in sample_manifest > core_behaviour, on manifest upload
156 157 158 159 160 161 162 163 164 165 166 |
# File 'app/models/asset.rb', line 156 def register_stock! class_name = self.class.name if .nil? # rubocop:todo Layout/LineLength raise StandardError, "No stock template configured for #{class_name}. If #{class_name} is a stock, set stock_template on the class." # rubocop:enable Layout/LineLength end Messenger.create!(target: self, template: , root: 'stock_resource') end |
#request_types ⇒ Object
102 103 104 |
# File 'app/models/asset.rb', line 102 def request_types RequestType.where(asset_type: label) end |
#type ⇒ Object
148 149 150 |
# File 'app/models/asset.rb', line 148 def type self.class.name.underscore end |
#update_from_qc(qc_result) ⇒ Object
168 169 170 |
# File 'app/models/asset.rb', line 168 def update_from_qc(qc_result) Rails.logger.info "#{self.class.name} #{id} updated by QcResult #{qc_result.id}" end |