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


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

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


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

def dynamic_attributes
  @dynamic_attributes
end

#manifest_typeObject


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

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


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

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


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

def assets
  @assets ||= []
end

#compute_last_rowObject


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

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

#create_sample_manifestObject


65
66
67
68
69
70
71
72
73
74
75
# File 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb', line 65

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')
  else
    FactoryBot.create(:sample_manifest, asset_type: '1dtube')
  end
end

#empty_columnsObject


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

def empty_columns
  %w[supplier_name i7 i5]
end

#last_rowObject


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

def last_row
  @last_row ||= compute_last_row
end

#multiplexed_library_tubeObject


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

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

#sample_manifestObject


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

def sample_manifest
  @sample_manifest ||= create_sample_manifest
end