Class: UatActions::TubeSubmission
- Inherits:
-
UatActions
- Object
- UatActions
- UatActions::TubeSubmission
- Defined in:
- app/uat_actions/uat_actions/tube_submission.rb
Overview
This UAT Action will generates a basic submission for tubes. Initially, it has been designed for generating scRNA Core Donor Pooling and cDNA Prep submissions on LRC Bank Seq/Spare tubes. rubocop:disable Metrics/ClassLength
Constant Summary collapse
- ERROR_SUBMISSION_TEMPLATE_DOES_NOT_EXIST =
"Submission template '%s' does not exist."
- ERROR_TUBES_DO_NOT_EXIST =
'Tubes with barcodes do not exist: %s'
- ERROR_LIBRARY_TYPE_DOES_NOT_EXIST =
"Library type '%s' does not exist."
- SCRNA_CORE_CDNA_PREP_GEM_X_5P =
'Limber-Htp - scRNA Core cDNA Prep GEM-X 5p'
Constants inherited from UatActions
Class Method Summary collapse
-
.compatible_submission_templates ⇒ Array<String>
Returns the submission templates which are compatible with the UAT action.
-
.default ⇒ UatActions::TestSubmission
Returns a default copy of the UatAction which will be used to fill in the form.
Instance Method Summary collapse
-
#assets ⇒ Array<Tube>
Returns the tubes to use for the submission.
-
#calculated_request_options_by_template_name ⇒ Hash
Returns the allowance_band to prevent integration suite breakage for the scRNA Core testing suite.
-
#custom_request_options ⇒ Hash
Returns the custom request options to use for the submission.
-
#default_request_options ⇒ Hash
Returns the default request options to use for the submission.
-
#fill_report(order) ⇒ Void
Fills the report with the information from the submission.
-
#order_request_options ⇒ Hash
Returns the request options to use for the submission.
-
#perform ⇒ Boolean
Generates tube submission for the given template.
-
#project ⇒ Project
Returns the project to use for UAT.
-
#select_assets ⇒ Array<Tube>
Returns the tubes from the specified barcodes in the form field.
-
#study ⇒ Study
Returns the study to use for UAT.
-
#submission_template ⇒ SubmissionTemplate
Returns the submisssion template to use for the submission.
-
#user ⇒ User
Returns the uat user.
-
#validate_library_type_exists ⇒ Object
Validates that the library type exists for the specified library type name.
-
#validate_submission_template_exists ⇒ void
Validates that the submission template exists for the specified submission template name.
-
#validate_tubes_exist ⇒ void
Validates that the tubes exist for the specified barcodes.
Methods inherited from UatActions
all, category, find, form_field, form_fields, grouped_and_sorted_uat_actions, id, inherited, permitted, #report, #save, to_partial_path, uat_actions
Class Method Details
.compatible_submission_templates ⇒ Array<String>
Returns the submission templates which are compatible with the UAT action. These are submission templates which have a tube as an input asset type.
82 83 84 85 86 87 88 89 90 |
# File 'app/uat_actions/uat_actions/tube_submission.rb', line 82 def self.compatible_submission_templates SubmissionTemplate .visible .each_with_object([]) do |submission_template, compatible| next unless submission_template.input_asset_type.constantize <= Tube compatible << submission_template.name end end |
.default ⇒ UatActions::TestSubmission
Returns a default copy of the UatAction which will be used to fill in the form
74 75 76 |
# File 'app/uat_actions/uat_actions/tube_submission.rb', line 74 def self.default new end |
Instance Method Details
#assets ⇒ Array<Tube>
Returns the tubes to use for the submission
180 181 182 |
# File 'app/uat_actions/uat_actions/tube_submission.rb', line 180 def assets @assets ||= select_assets end |
#calculated_request_options_by_template_name ⇒ Hash
Returns the allowance_band to prevent integration suite breakage for the scRNA Core testing suite.
Allowance bands are only supported for bulk submissions using the Limber-HTP scRNA Core cDNA Prep GEM-X 5p template. In bulk submissions, allowance_band is determined by the calculate_allowance_bands
method.
The allowance_band is not included in the form, as it is a calculated value (does not require user input).
@todo: Implement allowance_band support for standard tube submissions (Y25-153) @todo: Remove this method once allowance_band is properly handled for tube submissions.
240 241 242 243 244 245 246 |
# File 'app/uat_actions/uat_actions/tube_submission.rb', line 240 def if submission_template_name == SCRNA_CORE_CDNA_PREP_GEM_X_5P { 'allowance_band' => '2 pool attempts, 2 counts' } else {} end end |
#custom_request_options ⇒ Hash
Returns the custom request options to use for the submission
218 219 220 221 222 223 224 |
# File 'app/uat_actions/uat_actions/tube_submission.rb', line 218 def = {} [:library_type] = library_type_name if library_type_name.present? [:number_of_pools] = number_of_pools.presence [:cells_per_chip_well] = cells_per_chip_well.presence end |
#default_request_options ⇒ Hash
Returns the default request options to use for the submission
201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'app/uat_actions/uat_actions/tube_submission.rb', line 201 def submission_template .input_field_infos .each_with_object({}) do |ifi, | [ifi.key] = ( if ifi.default_value.nil? ifi.selection&.first.presence || ifi.max.presence || ifi.min else ifi.default_value end ) end end |
#fill_report(order) ⇒ Void
Fills the report with the information from the submission
rubocop:disable Metrics/AbcSize
155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'app/uat_actions/uat_actions/tube_submission.rb', line 155 def fill_report(order) report['tube_barcodes'] = assets.map(&:human_barcode) report['submission_id'] = order.submission.id report['library_type'] = order.[:library_type] if order.[:library_type].present? report['number_of_pools'] = order.[:number_of_pools] if order.[ :number_of_pools ].present? report['cells_per_chip_well'] = order.[:cells_per_chip_well] if order.[ :cells_per_chip_well ].present? report['allowance_band'] = order.[:allowance_band] if order.[:allowance_band].present? end |
#order_request_options ⇒ Hash
Returns the request options to use for the submission
194 195 196 |
# File 'app/uat_actions/uat_actions/tube_submission.rb', line 194 def .merge().merge() end |
#perform ⇒ Boolean
Generates tube submission for the given template.
95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'app/uat_actions/uat_actions/tube_submission.rb', line 95 def perform order = submission_template.create_with_submission!( study: study, project: project, user: user, assets: assets, request_options: ) fill_report(order) order.submission.built! true end |
#project ⇒ Project
Returns the project to use for UAT
256 |
# File 'app/uat_actions/uat_actions/tube_submission.rb', line 256 delegate :project, to: :'UatActions::StaticRecords' |
#select_assets ⇒ Array<Tube>
Returns the tubes from the specified barcodes in the form field
187 188 189 |
# File 'app/uat_actions/uat_actions/tube_submission.rb', line 187 def select_assets .gsub(/(\\[trfvn])+/, ' ').split.map { || Tube.() } end |
#study ⇒ Study
Returns the study to use for UAT
251 |
# File 'app/uat_actions/uat_actions/tube_submission.rb', line 251 delegate :study, to: :'UatActions::StaticRecords' |
#submission_template ⇒ SubmissionTemplate
Returns the submisssion template to use for the submission
173 174 175 |
# File 'app/uat_actions/uat_actions/tube_submission.rb', line 173 def submission_template @submission_template = SubmissionTemplate.find_by(name: submission_template_name) end |
#user ⇒ User
Returns the uat user
262 |
# File 'app/uat_actions/uat_actions/tube_submission.rb', line 262 delegate :user, to: :'UatActions::StaticRecords' |
#validate_library_type_exists ⇒ Object
Validates that the library type exists for the specified library type name.
return [void]
143 144 145 146 147 148 149 |
# File 'app/uat_actions/uat_actions/tube_submission.rb', line 143 def validate_library_type_exists return if library_type_name.blank? # optional return if LibraryType.exists?(name: library_type_name) = format(ERROR_LIBRARY_TYPE_DOES_NOT_EXIST, library_type_name) errors.add(:library_type_name, ) end |
#validate_submission_template_exists ⇒ void
This method returns an undefined value.
Validates that the submission template exists for the specified submission template name.
113 114 115 116 117 118 119 |
# File 'app/uat_actions/uat_actions/tube_submission.rb', line 113 def validate_submission_template_exists return if submission_template_name.blank? # already validated by presence return if SubmissionTemplate.exists?(name: submission_template_name) = format(ERROR_SUBMISSION_TEMPLATE_DOES_NOT_EXIST, submission_template_name) errors.add(:submission_template_name, ) end |
#validate_tubes_exist ⇒ void
This method returns an undefined value.
Validates that the tubes exist for the specified barcodes.
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'app/uat_actions/uat_actions/tube_submission.rb', line 124 def validate_tubes_exist return if .blank? # already validated by presence = .gsub(/(\\[trfvn])+/, ' ') .strip .split .select do || Tube.().blank? # not found end return if .empty? = format(ERROR_TUBES_DO_NOT_EXIST, .join(', ')) errors.add(:tube_barcodes, ) end |