Class: LabwareCreators::Tagging::TagCollection
- Inherits:
-
Object
- Object
- LabwareCreators::Tagging::TagCollection
- Defined in:
- app/models/labware_creators/tagging/tag_collection.rb
Overview
rubocop:todo Style/Documentation
Instance Method Summary collapse
-
#initialize(api, plate, purpose_uuid) ⇒ TagCollection
constructor
Create a tag collection.
- #layout_hash(layout) ⇒ Object
-
#list ⇒ Hash
Returns hash of usable tag layout templates, and the tags assigned to each well: eg.
-
#matches_templates_in_pool(uuid) ⇒ Bool
Used where the wells being pooled together originate from the same sample, so should have the same tags, so they are kept together when analysing sequencing data.
-
#used ⇒ Object
Returns a list of the tag layout templates (their uuids) that have already been used on other plates in the relevant submission pools.
-
#used? ⇒ Boolean
Have any tag layout templates already been used on other plates in the relevant submission pools?.
Constructor Details
#initialize(api, plate, purpose_uuid) ⇒ TagCollection
Create a tag collection
12 13 14 15 16 |
# File 'app/models/labware_creators/tagging/tag_collection.rb', line 12 def initialize(api, plate, purpose_uuid) @api = api @plate = plate @purpose_uuid = purpose_uuid end |
Instance Method Details
#layout_hash(layout) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'app/models/labware_creators/tagging/tag_collection.rb', line 33 def layout_hash(layout) { tags: (layout), dual_index: layout.dual_index?, used: used.include?(layout.uuid), matches_templates_in_pool: matches_templates_in_pool(layout.uuid), approved: acceptable_template?(layout) } end |
#list ⇒ Hash
Returns hash of usable tag layout templates, and the tags assigned to each well: eg. { “tag-layout-template-0” => { tags: [[“A1”, [1, 1]], [“B1”, [1, 2]]], dual_index: true } } where { tag_template_uuid => { tags: [[well_name, [ pool_id, tag_id ]]], dual_index: dual_index? } }
25 26 27 28 29 30 31 |
# File 'app/models/labware_creators/tagging/tag_collection.rb', line 25 def list @list ||= tag_layout_templates.each_with_object({}) do |layout, hash| # the `throw` that this catches comes from `generate_tag_layout` method catch(:unacceptable_tag_layout) { hash[layout.uuid] = layout_hash(layout) } end end |
#matches_templates_in_pool(uuid) ⇒ Bool
Used where the wells being pooled together originate from the same sample, so should have the same tags, so they are kept together when analysing sequencing data. (As opposed to when the pool will contain multiple samples, and therefore need to have different tags)
69 70 71 72 73 74 75 |
# File 'app/models/labware_creators/tagging/tag_collection.rb', line 69 def matches_templates_in_pool(uuid) # if there haven't been any templates used yet in the pool, we say it matches them return true if used.empty? # return true if this template has been used already in the pool used.include?(uuid) end |
#used ⇒ Object
Returns a list of the tag layout templates (their uuids) that have already been used on other plates in the relevant submission pools
45 46 47 48 49 50 51 52 |
# File 'app/models/labware_creators/tagging/tag_collection.rb', line 45 def used return [] if @plate.submission_pools.empty? @used ||= @plate .submission_pools .each_with_object(Set.new) { |pool, set| pool.used_tag_layout_templates.each { |used| set << used['uuid'] } } end |
#used? ⇒ Boolean
Have any tag layout templates already been used on other plates in the relevant submission pools?
55 56 57 |
# File 'app/models/labware_creators/tagging/tag_collection.rb', line 55 def used? used.present? end |