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
-
#apply_additional_validations_by_template_name ⇒ void
Applies additional validations based on the submission template type.
- #apply_number_of_samples_per_pool_validation ⇒ Object
- #group_rows_by_study_and_project ⇒ Object
-
#submission_template_name ⇒ Object
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.
-
#validate_consistent_column_value(column_header) ⇒ void
Validates that the specified column is consistent for all rows with the same study and project name.
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_name ⇒ void
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<String>>] The CSV data rows, where each row is an array of strings. headers [Array<String>] 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 |
# File 'app/models/submission/validations_by_template_name.rb', line 43 def apply_additional_validations_by_template_name # depending on the submission template type, call additional validations # NB. assumption that all rows in the csv have the same submission template name case submission_template_name # this validation is for the scRNA pipeline cDNA submission when SCRNA_CORE_CDNA_PREP_GEM_X_5P validate_consistent_column_value(HEADER_NUMBER_OF_POOLS) validate_consistent_column_value(HEADER_CELLS_PER_CHIP_WELL) validate_scrna_core_cdna_prep_feasibility end end |
#apply_number_of_samples_per_pool_validation ⇒ Object
54 55 56 57 |
# File 'app/models/submission/validations_by_template_name.rb', line 54 def apply_number_of_samples_per_pool_validation # Creates groups of rows based on the study and project name (pool_number, study-project) combinations group_rows_by_study_and_project end |
#group_rows_by_study_and_project ⇒ Object
59 60 61 62 63 |
# File 'app/models/submission/validations_by_template_name.rb', line 59 def group_rows_by_study_and_project index_of_study_name = headers.index(HEADER_STUDY_NAME) index_of_project_name = headers.index(HEADER_PROJECT_NAME) csv_data_rows.group_by { |row| [row[index_of_study_name], row[index_of_project_name]] } end |
#submission_template_name ⇒ Object
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 |
# File 'app/models/submission/validations_by_template_name.rb', line 25 def submission_template_name index_of_template_name = headers.index(HEADER_TEMPLATE_NAME) csv_data_rows.first[index_of_template_name] end |
#validate_consistent_column_value(column_header) ⇒ 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 inconsistencies are found, an error is added to the errors collection.
73 74 75 76 77 78 79 80 |
# File 'app/models/submission/validations_by_template_name.rb', line 73 def validate_consistent_column_value(column_header) index_of_column = headers.index(column_header) grouped_rows = group_rows_by_study_and_project grouped_rows.each do |study_project, rows| validate_unique_values(study_project, rows, index_of_column, column_header) end end |