Class: TagLayout::TemplateSubmission

Inherits:
ApplicationRecord show all
Defined in:
app/models/tag_layout/template_submission.rb

Overview

Stores a record of which templates have been used in which submission This ensures that a tag clash is not introduced prior to later pooling. We can also enforce uniqueness at the database level, eliminating race conditions when multiple plates get processed at the same time. This is a genuine risk, as the users often process multiple plates in parallel and processing time is non-trivial.

A note on future changes: Once we've solved the duplicate-tag-sequences problems it might make sense to actually track tag sequence pairs here, but hopefully by that point we'll be pooling flexibly anyway. We'd probably also still need to be able to show which templates had been used, as a huge list of oligo sequences isn't very user friendly.

Author:

  • Genome Research Ltd.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

extended

Instance Attribute Details

#enforce_uniquenessnil, true

Returns true to enforce uniqueness of a template within a submission or nil to allow duplicate templates. This is enforced at the database level.

Returns:

  • (nil, true)

    true to enforce uniqueness of a template within a submission or nil to allow duplicate templates. This is enforced at the database level



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/models/tag_layout/template_submission.rb', line 28

 do
  # NOTE: The following attribute is not required for Microarray Genotyping.
  # I think this might be broken and suggests that there should be separate classes for project: one for
  # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping
  # that doesn't.
  include ProjectManager::Associations
  include BudgetDivision::Associations

  custom_attribute(:project_cost_code, required: true)
  custom_attribute(:funding_comments)
  custom_attribute(:collaborators)
  custom_attribute(:external_funding_source)
  custom_attribute(:sequencing_budget_cost_centre)
  custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS)
  custom_attribute(:gt_committee_tracking_id)

  before_validation do |record|
    record.project_cost_code = nil if record.project_cost_code.blank?
    record.project_funding_model = nil if record.project_funding_model.blank?
  end
end

Instance Method Details

#coerce_false_enforce_uniqueness_to_nilObject

By setting the value to nil, we can bypass the uniqueness constraint on the database.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/models/tag_layout/template_submission.rb', line 35

 do
  # NOTE: The following attribute is not required for Microarray Genotyping.
  # I think this might be broken and suggests that there should be separate classes for project: one for
  # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping
  # that doesn't.
  include ProjectManager::Associations
  include BudgetDivision::Associations

  custom_attribute(:project_cost_code, required: true)
  custom_attribute(:funding_comments)
  custom_attribute(:collaborators)
  custom_attribute(:external_funding_source)
  custom_attribute(:sequencing_budget_cost_centre)
  custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS)
  custom_attribute(:gt_committee_tracking_id)

  before_validation do |record|
    record.project_cost_code = nil if record.project_cost_code.blank?
    record.project_funding_model = nil if record.project_funding_model.blank?
  end
end