Class: Tag
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Tag
- Includes:
- Api::TagIo::Extensions, Uuid::Uuidable
- Defined in:
- app/models/tag.rb
Overview
A Tag is a short, know sequence of DNA which gets applied to a sample. The tag remains attached through subsequent processing, and means that it is possible to identify the origin of a sample if multiple samples are subsequently pooled together. Tags are sometimes referred to as barcodes by our users. Tag is stored on aliquot, and an individual aliquot can have two tags identified as tag and tag2, these may also be known as i7 and i5 respectively.
Defined Under Namespace
Modules: Associations
Instance Method Summary collapse
-
#multitag!(asset) ⇒ Object
Allows the application of multiple tags to an aliquot.
- #name ⇒ Object
-
#summary ⇒ Object
Map id is converted to a string here for consistency with elsewhere in the api.
-
#tag!(asset) ⇒ Object
Connects a tag instance to the specified asset.
Methods included from Uuid::Uuidable
included, #unsaved_uuid!, #uuid
Methods included from Api::TagIo::Extensions
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
#multitag!(asset) ⇒ Object
Allows the application of multiple tags to an aliquot
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/models/tag.rb', line 40 def multitag!(asset) # rubocop:todo Metrics/MethodLength raise StandardError, 'Cannot tag an empty asset' if asset.aliquots.empty? asset .aliquots .group_by(&:sample_id) .each do |_sample_id, aliquots| if aliquots.first.no_tag1? aliquots.first.update(tag: self) else asset.aliquots << aliquots.first.dup(tag: self, receptacle: asset) end end end |
#name ⇒ Object
30 31 32 |
# File 'app/models/tag.rb', line 30 def name "Tag #{map_id}" end |
#summary ⇒ Object
Map id is converted to a string here for consistency with elsewhere in the api.
56 57 58 |
# File 'app/models/tag.rb', line 56 def summary { tag_group: tag_group.name, tag_index: map_id.to_s } end |
#tag!(asset) ⇒ Object
Connects a tag instance to the specified asset
35 36 37 |
# File 'app/models/tag.rb', line 35 def tag!(asset) asset.attach_tag(self) end |