-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dpl-977-update-tnano-export-file' into uat-19th-feb-24
- Loading branch information
Showing
45 changed files
with
2,183 additions
and
456 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
app/models/labware_creators/pcr_cycles_binned_plate/csv_file/duplex_seq/row.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# frozen_string_literal: true | ||
|
||
# Part of the Labware creator classes | ||
module LabwareCreators | ||
require_dependency 'labware_creators/pcr_cycles_binned_plate/csv_file_for_duplex_seq' | ||
|
||
module PcrCyclesBinnedPlate::CsvFile | ||
# | ||
# This version of the row is for the Duplex Seq pipeline. | ||
# | ||
class DuplexSeq::Row < RowBase | ||
include ActiveModel::Validations | ||
|
||
SUB_POOL_NOT_BLANK = 'has a value when Submit for Sequencing is N, it should be empty, in %s' | ||
SUBMIT_FOR_SEQ_INVALID = 'is empty or has an unrecognised value (should be Y or N), in %s' | ||
COVERAGE_MISSING = 'is missing but should be present when Submit for Sequencing is Y, in %s' | ||
COVERAGE_NEGATIVE = 'is negative but should be a positive value, in %s' | ||
|
||
attr_reader :submit_for_sequencing, :sub_pool, :coverage | ||
|
||
validate :submit_for_sequencing_has_expected_value | ||
validate :sub_pool_within_expected_range | ||
validates :coverage, | ||
presence: { | ||
message: ->(object, _data) { COVERAGE_MISSING % object } | ||
}, | ||
numericality: { | ||
greater_than: 0, | ||
message: ->(object, _data) { COVERAGE_NEGATIVE % object } | ||
}, | ||
unless: -> { empty? || !submit_for_sequencing? } | ||
|
||
delegate :submit_for_sequencing_column, :sub_pool_column, :coverage_column, to: :header | ||
|
||
def initialize_pipeline_specific_columns | ||
@submit_for_sequencing_as_string = @row_data[submit_for_sequencing_column]&.strip&.upcase | ||
@sub_pool = @row_data[sub_pool_column]&.strip&.to_i | ||
@coverage = @row_data[coverage_column]&.strip&.to_i | ||
end | ||
|
||
def submit_for_sequencing? | ||
@submit_for_sequencing ||= (@submit_for_sequencing_as_string == 'Y') | ||
end | ||
|
||
def submit_for_sequencing_has_expected_value | ||
return if empty? | ||
|
||
return if %w[Y N].include? @submit_for_sequencing_as_string | ||
|
||
errors.add('submit_for_sequencing', format(SUBMIT_FOR_SEQ_INVALID, to_s)) | ||
end | ||
|
||
def sub_pool_within_expected_range | ||
return if empty? | ||
|
||
# check the value is within range when we do expect a value to be present | ||
if submit_for_sequencing? | ||
in_range('sub_pool', sub_pool, @row_config.sub_pool_min, @row_config.sub_pool_max) | ||
else | ||
# expect sub-pool field to be blank, possible mistake by user if not | ||
return if sub_pool.blank? | ||
|
||
# sub-pool is NOT blank and should be | ||
errors.add('sub_pool', format(SUB_POOL_NOT_BLANK, to_s)) | ||
end | ||
end | ||
end | ||
end | ||
end |
34 changes: 34 additions & 0 deletions
34
...odels/labware_creators/pcr_cycles_binned_plate/csv_file/duplex_seq/well_details_header.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# frozen_string_literal: true | ||
|
||
# Part of the Labware creator classes | ||
module LabwareCreators | ||
require_dependency 'labware_creators/pcr_cycles_binned_plate/csv_file_for_duplex_seq' | ||
|
||
module PcrCyclesBinnedPlate::CsvFile | ||
# | ||
# Class WellDetailsHeader provides a simple wrapper for handling and validating | ||
# the plate barcode header row from the customer csv file | ||
# | ||
class DuplexSeq::WellDetailsHeader < WellDetailsHeaderBase | ||
# Return the index of the respective column. | ||
attr_reader :submit_for_sequencing_column, :sub_pool_column, :coverage_column | ||
|
||
SUBMIT_FOR_SEQUENCING_COLUMN = 'Submit for sequencing (Y/N)?' | ||
SUB_POOL_COLUMN = 'Sub-Pool' | ||
COVERAGE_COLUMN = 'Coverage' | ||
NOT_FOUND = 'could not be found in: ' | ||
|
||
validates :submit_for_sequencing_column, presence: { message: ->(object, _data) { "#{NOT_FOUND}'#{object}'" } } | ||
validates :sub_pool_column, presence: { message: ->(object, _data) { "#{NOT_FOUND}'#{object}'" } } | ||
validates :coverage_column, presence: { message: ->(object, _data) { "#{NOT_FOUND}'#{object}'" } } | ||
|
||
private | ||
|
||
def initialize_pipeline_specific_columns | ||
@submit_for_sequencing_column = index_of_header(SUBMIT_FOR_SEQUENCING_COLUMN) | ||
@sub_pool_column = index_of_header(SUB_POOL_COLUMN) | ||
@coverage_column = index_of_header(COVERAGE_COLUMN) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
173 changes: 0 additions & 173 deletions
173
app/models/labware_creators/pcr_cycles_binned_plate/csv_file/row.rb
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.