Module: Request::SampleCompoundAliquotTransfer

Included in:
SequencingRequest
Defined in:
app/models/request/sample_compound_aliquot_transfer.rb

Overview

Module to provide support to handle creation of compound samples from the list of samples at the source. A compound sample is a sample that represents a combination of other samples.

The reason for this is to ensure that when the data gets to the MLWH, each row has a unique combination of tag1 and tag2 - this is a requirement for the Illumina de-plexing that NPG does.

tag_depth on aliquot is used to indicate that, even though certain aliquots might share the same tags, they can in fact be separated out by other means (e.g. by genotype, because they have been sequenced before).

In the case where multiple aliquots share the same tag1 tag2 combo, we represent them as a single aliquot with a single sample in the target Lane, but link the sample back to its component sample using the SampleCompoundComponent join object.

Assumptions:

  • This module will be included in a Request class

Defined Under Namespace

Classes: Error

Instance Method Summary collapse

Instance Method Details

#compound_samples_needed?Boolean

Indicates if a compound sample creation is needed, by checking if any of the source aliquots share the same tag1 and tag2

Returns:

  • (Boolean)


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

 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

#transfer_aliquots_into_compound_sample_aliquotsObject

Groups the source aliquots by their tag1 and tag2 combination For each of these groups, find or create a compound sample.



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/models/request/sample_compound_aliquot_transfer.rb', line 37

 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