Class: DuplexSeq::Row

Inherits:
RowBase
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
app/models/labware_creators/pcr_cycles_binned_plate/csv_file/duplex_seq/row.rb

Overview

This version of the row is for the Duplex Seq pipeline.

Constant Summary collapse

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'

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#coverageObject (readonly)

Returns the value of attribute coverage.



19
20
21
# File 'app/models/labware_creators/pcr_cycles_binned_plate/csv_file/duplex_seq/row.rb', line 19

def coverage
  @coverage
end

#sub_poolObject (readonly)

Returns the value of attribute sub_pool.



19
20
21
# File 'app/models/labware_creators/pcr_cycles_binned_plate/csv_file/duplex_seq/row.rb', line 19

def sub_pool
  @sub_pool
end

#submit_for_sequencingObject (readonly)

Returns the value of attribute submit_for_sequencing.



19
20
21
# File 'app/models/labware_creators/pcr_cycles_binned_plate/csv_file/duplex_seq/row.rb', line 19

def submit_for_sequencing
  @submit_for_sequencing
end

Instance Method Details

#initialize_pipeline_specific_columnsObject



35
36
37
38
39
# File 'app/models/labware_creators/pcr_cycles_binned_plate/csv_file/duplex_seq/row.rb', line 35

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

#sub_pool_within_expected_rangeObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'app/models/labware_creators/pcr_cycles_binned_plate/csv_file/duplex_seq/row.rb', line 53

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

#submit_for_sequencing?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'app/models/labware_creators/pcr_cycles_binned_plate/csv_file/duplex_seq/row.rb', line 41

def submit_for_sequencing?
  @submit_for_sequencing ||= (@submit_for_sequencing_as_string == 'Y')
end

#submit_for_sequencing_has_expected_valueObject



45
46
47
48
49
50
51
# File 'app/models/labware_creators/pcr_cycles_binned_plate/csv_file/duplex_seq/row.rb', line 45

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