Module: Submission::ValidationsByTemplateName

Includes:
ScrnaCoreCdnaPrepFeasibilityValidator
Included in:
BulkSubmission
Defined in:
app/models/submission/validations_by_template_name.rb

Constant Summary collapse

SCRNA_CORE_CDNA_PREP_GEM_X_5P =

Template names

'Limber-Htp - scRNA Core cDNA Prep GEM-X 5p'
HEADER_TEMPLATE_NAME =

Column headers

'template name'
HEADER_STUDY_NAME =
'study name'
HEADER_PROJECT_NAME =
'project name'
HEADER_BARCODE =
'barcode'
HEADER_PLATE_WELLS =
'plate well'
HEADER_NUMBER_OF_POOLS =
'scrna core number of pools'
HEADER_CELLS_PER_CHIP_WELL =
'scrna core cells per chip well'
SAMPLES_PER_POOL =
{ max: 25, min: 5 }.freeze

Constants included from ScrnaCoreCdnaPrepFeasibilityValidator

ScrnaCoreCdnaPrepFeasibilityValidator::I18N_SCOPE_SCRNA_CORE_CDNA_PREP_FEASIBILITY_VALIDATOR

Constants included from ScrnaCoreCdnaPrepFeasibilityCalculator

ScrnaCoreCdnaPrepFeasibilityCalculator::ALLOWANCE_BANDS, ScrnaCoreCdnaPrepFeasibilityCalculator::HEADER_PLATE_WELL

Instance Method Summary collapse

Methods included from ScrnaCoreCdnaPrepFeasibilityValidator

#validate_required_headers, #validate_scrna_core_cdna_prep_feasibility

Methods included from ScrnaCoreCdnaPrepFeasibilityCalculator

#calculate_allowance_bands, #calculate_chip_loading_volume, #calculate_resuspension_volume, #calculate_total_cells_in_300ul, #calculate_volume_needed

Instance Method Details

#apply_additional_validations_by_template_namevoid

This method returns an undefined value.

Applies additional validations based on the submission template type.

This method determines the submission template type from the CSV data and calls the appropriate validation methods based on the template type. It assumes that all rows in the CSV have the same submission template name. If no match is found for the submission template name, no additional validations are performed.

Uses the following instance variables: csv_data_rows [Array<Array>] The CSV data rows, where each row is an array of strings. headers [Array] The headers of the CSV file, used to find the index of specific columns. errors [ActiveModel::Errors] The errors object to which validation errors are added.



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/models/submission/validations_by_template_name.rb', line 43

 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

#apply_number_of_samples_per_pool_validationObject



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'app/models/submission/validations_by_template_name.rb', line 57

 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

#group_rows_by_study_and_projectObject



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'app/models/submission/validations_by_template_name.rb', line 62

 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

#submission_template_nameObject

Looks for the index of the 'template name' header in the CSV headers and returns the value from the first row in the corresponding column. Assumptions:

  • The CSV data has already been parsed into an array of rows.
  • The template name exists in the headers and is present in the first row.


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/models/submission/validations_by_template_name.rb', line 25

 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

#validate_consistent_column_value(column_header, check_zero: false) ⇒ void

This method returns an undefined value.

Validates that the specified column is consistent for all rows with the same study and project name.

This method groups the rows in the CSV data by the study name and project name, and checks if the specified column has the same value for all rows within each group. If check_zero is true, it also ensures that the value is not zero. If inconsistencies or zero values are found (depending on the check), an error is added to the errors collection.

Parameters:

  • column_header (String)

    The header of the column to validate.

  • check_zero (Boolean) (defaults to: false)

    Whether to also validate that the value is not zero. Defaults to false.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'app/models/submission/validations_by_template_name.rb', line 78

 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