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

Returns a new instance of TestWorksheet.


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 19

def initialize(attributes = {})
  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, 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


16
17
18
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 16

def dynamic_attributes
  @dynamic_attributes
end

#manifest_typeObject


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

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


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

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


16
17
18
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 16

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


50
51
52
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 50

def assets
  @assets ||= []
end

#compute_last_rowObject


42
43
44
45
46
47
48
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 42

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


66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 66

def create_sample_manifest
  if %w[plate_default plate_full plate_rnachip].include? manifest_type
    FactoryBot.create(:pending_plate_sample_manifest,
                      num_plates: num_plates,
                      num_samples_per_plate: num_samples_per_plate)
  elsif %w[tube_library_with_tag_sequences].include? manifest_type
    FactoryBot.create(:sample_manifest, asset_type: 'library')
  elsif %w[tube_multiplexed_library tube_multiplexed_library_with_tag_sequences].include? manifest_type
    FactoryBot.create(:sample_manifest, asset_type: 'multiplexed_library')
  elsif %w[tube_rack_default].include? manifest_type
    FactoryBot.create(:tube_rack_manifest, asset_type: 'tube_rack')
  else
    FactoryBot.create(:sample_manifest, asset_type: '1dtube')
  end
end

#empty_columnsObject


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

def empty_columns
  %w[supplier_name i7 i5]
end

#last_rowObject


38
39
40
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 38

def last_row
  @last_row ||= compute_last_row
end

#multiplexed_library_tubeObject


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

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

#sample_manifestObject


62
63
64
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 62

def sample_manifest
  @sample_manifest ||= create_sample_manifest
end