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, #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


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

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.


14
15
16
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 14

def cgap
  @cgap
end

#countObject

Returns the value of attribute count.


14
15
16
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 14

def count
  @count
end

#dataObject

Returns the value of attribute data.


14
15
16
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 14

def data
  @data
end

#dynamic_attributesObject (readonly)

Returns the value of attribute dynamic_attributes.


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

def dynamic_attributes
  @dynamic_attributes
end

#manifest_typeObject


77
78
79
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 77

def manifest_type
  @manifest_type ||= 'tube_default'
end

#missing_columnsObject

Returns the value of attribute missing_columns.


14
15
16
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 14

def missing_columns
  @missing_columns
end

#no_of_rowsObject

Returns the value of attribute no_of_rows.


14
15
16
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 14

def no_of_rows
  @no_of_rows
end

#num_platesObject

Returns the value of attribute num_plates.


14
15
16
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 14

def num_plates
  @num_plates
end

#num_samples_per_plateObject

Returns the value of attribute num_samples_per_plate.


14
15
16
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 14

def num_samples_per_plate
  @num_samples_per_plate
end

#partialObject

Returns the value of attribute partial.


14
15
16
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 14

def partial
  @partial
end

#studyObject

Returns the value of attribute study.


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

def study
  @study
end

#supplierObject

Returns the value of attribute supplier.


14
15
16
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 14

def supplier
  @supplier
end

#tagsObject (readonly)

Returns the value of attribute tags.


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

def tags
  @tags
end

#typeObject

Returns the value of attribute type.


14
15
16
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 14

def type
  @type
end

#validation_errorsObject

Returns the value of attribute validation_errors.


14
15
16
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 14

def validation_errors
  @validation_errors
end

Instance Method Details

#assetsObject


69
70
71
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 69

def assets
  @assets ||= []
end

#compute_last_rowObject


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

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

#create_sample_manifestObject


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

def create_sample_manifest
  case manifest_type
  when /plate/
    FactoryBot.create(
      :pending_plate_sample_manifest,
      num_plates: num_plates,
      num_samples_per_plate: num_samples_per_plate,
      study: study
    )
  when /tube_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


73
74
75
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 73

def empty_columns
  %w[supplier_name i7 i5]
end

#last_rowObject


57
58
59
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 57

def last_row
  @last_row ||= compute_last_row
end

#multiplexed_library_tubeObject


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

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

#sample_manifestObject


81
82
83
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 81

def sample_manifest
  @sample_manifest ||= create_sample_manifest
end