Class: SampleManifestExcel::Worksheet::TestWorksheet

Inherits:
SequencescapeExcel::Worksheet::Base show all
Includes:
SequencescapeExcel::Helpers::Worksheet
Defined in:
app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb

Overview

A test worksheet is necessary for testing uploads.

Constant Summary

Constants included from SequencescapeExcel::Helpers::Worksheet

SequencescapeExcel::Helpers::Worksheet::STYLES

Instance Attribute Summary collapse

Attributes inherited from SequencescapeExcel::Worksheet::Base

#axlsx_worksheet, #columns, #name, #password, #ranges, #workbook

Instance Method Summary collapse

Methods included from SequencescapeExcel::Helpers::Worksheet

#add_headers, #create_styles, #find_or_create_style, #first_row, #styles

Methods inherited from SequencescapeExcel::Worksheet::Base

#add_row, #add_rows, #create_worksheet, #insert_axlsx_worksheet, #protect

Constructor Details

#initialize(attributes = {}) ⇒ TestWorksheet

rubocop:todo Metrics/MethodLength



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 26

def initialize(attributes = {}) # rubocop:todo Metrics/MethodLength
  super
  @validation_errors ||= []
  if type == 'Plates'
    # create a worksheet for Plates
    create_plate_dynamic_attributes
  else
    # by default create a worksheet for Tubes
    create_library_type
    create_reference_genome
    create_tube_dynamic_attributes
    create_tube_requests
  end
  create_styles
  add_title_and_description(study.name, supplier, count)
  add_headers
  add_data
end

Instance Attribute Details

#cgapObject

Returns the value of attribute cgap.



12
13
14
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 12

def cgap
  @cgap
end

#countObject

Returns the value of attribute count.



12
13
14
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 12

def count
  @count
end

#dataObject

Returns the value of attribute data.



12
13
14
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 12

def data
  @data
end

#dynamic_attributesObject (readonly)

Returns the value of attribute dynamic_attributes.



23
24
25
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 23

def dynamic_attributes
  @dynamic_attributes
end

#manifest_typeObject



75
76
77
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 75

def manifest_type
  @manifest_type ||= 'tube_default'
end

#missing_columnsObject

Returns the value of attribute missing_columns.



12
13
14
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 12

def missing_columns
  @missing_columns
end

#no_of_rowsObject

Returns the value of attribute no_of_rows.



12
13
14
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 12

def no_of_rows
  @no_of_rows
end

#num_filled_wells_per_plateObject

Returns the value of attribute num_filled_wells_per_plate.



12
13
14
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 12

def num_filled_wells_per_plate
  @num_filled_wells_per_plate
end

#num_platesObject

Returns the value of attribute num_plates.



12
13
14
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 12

def num_plates
  @num_plates
end

#num_rows_per_well=(value) ⇒ Object

Sets the attribute num_rows_per_well

Parameters:

  • value

    the value to set the attribute num_rows_per_well to.



24
25
26
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 24

def num_rows_per_well=(value)
  @num_rows_per_well = value
end

#partialObject

Returns the value of attribute partial.



12
13
14
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 12

def partial
  @partial
end

#studyObject

Returns the value of attribute study.



23
24
25
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 23

def study
  @study
end

#supplierObject

Returns the value of attribute supplier.



12
13
14
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 12

def supplier
  @supplier
end

#tagsObject (readonly)

Returns the value of attribute tags.



23
24
25
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 23

def tags
  @tags
end

#typeObject

Returns the value of attribute type.



12
13
14
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 12

def type
  @type
end

#validation_errorsObject

Returns the value of attribute validation_errors.



12
13
14
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 12

def validation_errors
  @validation_errors
end

Instance Method Details

#assetsObject



67
68
69
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 67

def assets
  @assets ||= []
end

#compute_last_rowObject



59
60
61
62
63
64
65
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 59

def compute_last_row
  if %w[plate_default plate_full plate_rnachip].include? manifest_type
    computed_first_row + (num_plates * num_filled_wells_per_plate * num_rows_per_well) - 1
  else
    computed_first_row + no_of_rows
  end
end

#create_sample_manifestObject

rubocop:todo Metrics/MethodLength



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 83

def create_sample_manifest # rubocop:todo Metrics/MethodLength
  case manifest_type
  when /plate/
    FactoryBot.create(
      :pending_plate_sample_manifest,
      num_plates:,
      num_filled_wells_per_plate:,
      num_rows_per_well:,
      study:
    )
  when /tube_library/, /tube_chromium_library/
    FactoryBot.create(:sample_manifest, asset_type: 'library', study: study)
  when /tube_multiplexed_library/
    FactoryBot.create(:sample_manifest, asset_type: 'multiplexed_library', study: study)
  when /tube_rack/
    FactoryBot.create(:tube_rack_manifest, asset_type: 'tube_rack', study: study)
  else
    FactoryBot.create(:sample_manifest, asset_type: '1dtube', study: study)
  end
end

#empty_columnsObject



71
72
73
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 71

def empty_columns
  %w[supplier_name i7 i5]
end

#last_rowObject



55
56
57
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 55

def last_row
  @last_row ||= compute_last_row
end

#multiplexed_library_tubeObject



104
105
106
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 104

def multiplexed_library_tube
  @multiplexed_library_tube ||= FactoryBot.create(:multiplexed_library_tube)
end

#sample_manifestObject



79
80
81
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 79

def sample_manifest
  @sample_manifest ||= create_sample_manifest
end