Class: Tag

Inherits:
ApplicationRecord show all
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

Methods included from Uuid::Uuidable

included, #unsaved_uuid!, #uuid

Methods included from Api::TagIO::Extensions

included

Methods inherited from ApplicationRecord

convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!

Methods included from Warren::BroadcastMessages

#broadcast, included, #queue_associated_for_broadcast, #queue_for_broadcast, #warren

Instance Method Details

#multitag!(asset) ⇒ Object

Allows the application of multiple tags to an aliquot

Raises:

  • (StandardError)

39
40
41
42
43
44
45
46
47
48
49
# File 'app/models/tag.rb', line 39

def multitag!(asset)
  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

#nameObject


29
30
31
# File 'app/models/tag.rb', line 29

def name
  "Tag #{map_id}"
end

#summaryObject

Map id is converted to a string here for consistency with elsewhere in the api.


52
53
54
55
56
57
# File 'app/models/tag.rb', line 52

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


34
35
36
# File 'app/models/tag.rb', line 34

def tag!(asset)
  asset.attach_tag(self)
end