-
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-976-modify-customer-file-handling' into dpl-977-upd…
…ate-tnano-export-file
- Loading branch information
Showing
22 changed files
with
416 additions
and
450 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
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,70 @@ | ||
# 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 true if empty? | ||
|
||
return true 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 true if empty? | ||
|
||
# check the value is within range when we do expect a value to be present | ||
if submit_for_sequencing? | ||
return in_range?('sub_pool', sub_pool, @row_config.sub_pool_min, @row_config.sub_pool_max) | ||
end | ||
|
||
# expect sub-pool field to be blank, possible mistake by user if not | ||
return true if sub_pool.blank? | ||
|
||
# sub-pool is NOT blank and should be | ||
errors.add('sub_pool', format(SUB_POOL_NOT_BLANK, to_s)) | ||
false | ||
end | ||
end | ||
end | ||
end |
36 changes: 36 additions & 0 deletions
36
...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,36 @@ | ||
# 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::DuplexSeq | ||
# | ||
# Class WellDetailsHeader provides a simple wrapper for handling and validating | ||
# the plate barcode header row from the customer csv file | ||
# | ||
class WellDetailsHeader < PcrCyclesBinnedPlate::CsvFile::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' | ||
|
||
validates :submit_for_sequencing_column, | ||
presence: { | ||
message: ->(object, _data) { "could not be found in: '#{object}'" } | ||
} | ||
validates :sub_pool_column, presence: { message: ->(object, _data) { "could not be found in: '#{object}'" } } | ||
validates :coverage_column, presence: { message: ->(object, _data) { "could not be found in: '#{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.
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
Oops, something went wrong.