Skip to content
48 changes: 48 additions & 0 deletions app/sample_manifest_excel/sample_manifest_excel/upload/row.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,54 @@
validate :country_of_origin_has_correct_case,
if: -> { data.present? && columns.present? && columns.names.include?('country_of_origin') }

validate :i7_present
# Ensure i7 column is not blank if it exists in the manifest
def i7_present
return unless columns.present? && data.present? && columns.names.include?('i7') && value('i7').blank?

errors.add(:base, "#{row_title} i7 can't be blank")
end

validate :i5_present
# Ensure i5 column is not blank if it exists in the manifest
def i5_present
return unless columns.present? && data.present? && columns.names.include?('i5') && value('i5').blank?

errors.add(:base, "#{row_title} i5 can't be blank, putting “n/a” in i5 if only needs one set of tags")
end

validate :chromium_tag_group
# Ensure chromium_tag_group column is not blank if it exists in the manifest
def chromium_tag_group
return unless columns.present? && data.present? && columns.names.include?('chromium_tag_group') && value('chromium_tag_group').blank?

Check failure on line 44 in app/sample_manifest_excel/sample_manifest_excel/upload/row.rb

View workflow job for this annotation

GitHub Actions / Rubocop

Layout/LineLength: Line is too long. [141/120] (https://rubystyle.guide#max-line-length)

Check failure on line 44 in app/sample_manifest_excel/sample_manifest_excel/upload/row.rb

View workflow job for this annotation

GitHub Actions / Rubocop

Style/IfUnlessModifier: Modifier form of `unless` makes the line too long. (https://rubystyle.guide#if-as-a-modifier)

Check failure on line 44 in app/sample_manifest_excel/sample_manifest_excel/upload/row.rb

View workflow job for this annotation

GitHub Actions / Rubocop

Layout/LineLength: Line is too long. [141/120] (https://rubystyle.guide#max-line-length)

Check failure on line 44 in app/sample_manifest_excel/sample_manifest_excel/upload/row.rb

View workflow job for this annotation

GitHub Actions / Rubocop

Style/IfUnlessModifier: Modifier form of `unless` makes the line too long. (https://rubystyle.guide#if-as-a-modifier)

errors.add(:base, "#{row_title} chromium_tag_group can't be blank")
end

validate :chromium_tag_well
# Ensure chromium_tag_well column is not blank if it exists in the manifest
def chromium_tag_well
return unless columns.present? && data.present? && columns.names.include?('chromium_tag_well') && value('chromium_tag_well').blank?

Check failure on line 52 in app/sample_manifest_excel/sample_manifest_excel/upload/row.rb

View workflow job for this annotation

GitHub Actions / Rubocop

Layout/LineLength: Line is too long. [139/120] (https://rubystyle.guide#max-line-length)

Check failure on line 52 in app/sample_manifest_excel/sample_manifest_excel/upload/row.rb

View workflow job for this annotation

GitHub Actions / Rubocop

Style/IfUnlessModifier: Modifier form of `unless` makes the line too long. (https://rubystyle.guide#if-as-a-modifier)

Check failure on line 52 in app/sample_manifest_excel/sample_manifest_excel/upload/row.rb

View workflow job for this annotation

GitHub Actions / Rubocop

Layout/LineLength: Line is too long. [139/120] (https://rubystyle.guide#max-line-length)

Check failure on line 52 in app/sample_manifest_excel/sample_manifest_excel/upload/row.rb

View workflow job for this annotation

GitHub Actions / Rubocop

Style/IfUnlessModifier: Modifier form of `unless` makes the line too long. (https://rubystyle.guide#if-as-a-modifier)

errors.add(:base, "#{row_title} chromium_tag_well can't be blank")
end

validate :dual_index_tag_set
# Ensure dual_index_tag_set column is not blank if it exists in the manifest
def dual_index_tag_set
return unless columns.present? && data.present? && columns.names.include?('dual_index_tag_set') && value('dual_index_tag_set').blank?

Check failure on line 60 in app/sample_manifest_excel/sample_manifest_excel/upload/row.rb

View workflow job for this annotation

GitHub Actions / Rubocop

Layout/LineLength: Line is too long. [141/120] (https://rubystyle.guide#max-line-length)

Check failure on line 60 in app/sample_manifest_excel/sample_manifest_excel/upload/row.rb

View workflow job for this annotation

GitHub Actions / Rubocop

Style/IfUnlessModifier: Modifier form of `unless` makes the line too long. (https://rubystyle.guide#if-as-a-modifier)

Check failure on line 60 in app/sample_manifest_excel/sample_manifest_excel/upload/row.rb

View workflow job for this annotation

GitHub Actions / Rubocop

Layout/LineLength: Line is too long. [141/120] (https://rubystyle.guide#max-line-length)

Check failure on line 60 in app/sample_manifest_excel/sample_manifest_excel/upload/row.rb

View workflow job for this annotation

GitHub Actions / Rubocop

Style/IfUnlessModifier: Modifier form of `unless` makes the line too long. (https://rubystyle.guide#if-as-a-modifier)

errors.add(:base, "#{row_title} dual_index_tag_set can't be blank")
end

validate :dual_index_tag_well
# Ensure dual_index_tag_well column is not blank if it exists in the manifest
def dual_index_tag_well
return unless columns.present? && data.present? && columns.names.include?('dual_index_tag_well') && value('dual_index_tag_well').blank?

Check failure on line 68 in app/sample_manifest_excel/sample_manifest_excel/upload/row.rb

View workflow job for this annotation

GitHub Actions / Rubocop

Layout/LineLength: Line is too long. [143/120] (https://rubystyle.guide#max-line-length)

Check failure on line 68 in app/sample_manifest_excel/sample_manifest_excel/upload/row.rb

View workflow job for this annotation

GitHub Actions / Rubocop

Style/IfUnlessModifier: Modifier form of `unless` makes the line too long. (https://rubystyle.guide#if-as-a-modifier)

Check failure on line 68 in app/sample_manifest_excel/sample_manifest_excel/upload/row.rb

View workflow job for this annotation

GitHub Actions / Rubocop

Layout/LineLength: Line is too long. [143/120] (https://rubystyle.guide#max-line-length)

Check failure on line 68 in app/sample_manifest_excel/sample_manifest_excel/upload/row.rb

View workflow job for this annotation

GitHub Actions / Rubocop

Style/IfUnlessModifier: Modifier form of `unless` makes the line too long. (https://rubystyle.guide#if-as-a-modifier)

errors.add(:base, "#{row_title} dual_index_tag_well can't be blank")
end

delegate :present?, to: :sample, prefix: true
delegate :aliquots, :asset, to: :manifest_asset

Expand Down
30 changes: 20 additions & 10 deletions config/sample_manifest_excel/columns.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,38 @@ i7:
validation:
options:
type: :textLength
operator: :lessThanOrEqual
formula1: "255"
operator: :between
formula1: "1"
formula2: "255"
allowBlank: false
showInputMessage: true
showErrorMessage: true
promptTitle: "i7"
prompt: "Input i7."
errorStyle: :warning
errorTitle: "i7"
error: "i7 cannot be blank"
conditional_formattings:
empty_cell:
empty_mandatory_cell_2:
i5:
heading: i5 TAG SEQUENCE
unlocked: true
validation:
options:
type: :textLength
operator: :lessThanOrEqual
formula1: "255"
operator: :between
formula1: "1"
formula2: "255"
allowBlank: false
showInputMessage: true
showErrorMessage: true
errorStyle: :warning
errorTitle: "i5"
error: "i5 cannot be blank"
promptTitle: "i5"
prompt: "Input i5."
conditional_formattings:
empty_cell:
empty_mandatory_cell_2:
tag_group:
heading: TAG GROUP
unlocked: true
Expand Down Expand Up @@ -137,7 +147,7 @@ chromium_tag_group:
prompt: "Input the name of a valid tag set. All samples in a library need to be tagged with the same tag set."
range_name: :chromium_tag_groups
conditional_formattings:
empty_cell:
empty_mandatory_cell_2:
chromium_tag_well:
heading: CHROMIUM TAG WELL
unlocked: true
Expand All @@ -155,7 +165,7 @@ chromium_tag_well:
errorTitle: "Tag well"
error: "Tag Index must be a well."
conditional_formattings:
empty_cell:
empty_mandatory_cell_2:
is_number:
len:
formula:
Expand Down Expand Up @@ -235,7 +245,7 @@ dual_index_tag_set:
prompt: "Input the name of a valid dual index tag plate."
range_name: :dual_index_tag_sets
conditional_formattings:
empty_cell:
empty_mandatory_cell_2:
dual_index_tag_well:
heading: DUAL INDEX TAG WELL
unlocked: true
Expand All @@ -253,7 +263,7 @@ dual_index_tag_well:
errorTitle: "Dual index tag well"
error: "Dual Index Tag must be a well."
conditional_formattings:
empty_cell:
empty_mandatory_cell_2:
is_number:
len:
formula:
Expand Down
9 changes: 9 additions & 0 deletions config/sample_manifest_excel/conditional_formattings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ empty_mandatory_cell:
formula: "FALSE"
operator: :equal
priority: 1
empty_mandatory_cell_2:
style:
bg_color: "FF991C"
type: :dxf
options:
type: :cellIs
formula: "FALSE"
operator: :equal
priority: 1
len:
style:
bg_color: "FF0000"
Expand Down
8 changes: 4 additions & 4 deletions spec/data/sample_manifest_excel/columns.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ chromium_tag_group:
prompt: "Input the name of a valid tag set. All samples in a library need to be tagged with the same tag set."
range_name: :chromium_tag_groups
conditional_formattings:
empty_cell:
empty_mandatory_cell_2:
chromium_tag_well:
heading: CHROMIUM TAG WELL
unlocked: true
Expand All @@ -145,7 +145,7 @@ chromium_tag_well:
errorTitle: "Tag well"
error: "Tag Index must be a well."
conditional_formattings:
empty_cell:
empty_mandatory_cell_2:
is_number:
len:
formula:
Expand Down Expand Up @@ -184,7 +184,7 @@ dual_index_tag_set:
prompt: "Input the name of a valid dual index tag plate."
range_name: :dual_index_tag_sets
conditional_formattings:
empty_cell:
empty_mandatory_cell_2:
dual_index_tag_well:
heading: DUAL INDEX TAG WELL
unlocked: true
Expand All @@ -202,7 +202,7 @@ dual_index_tag_well:
errorTitle: "Dual index tag well"
error: "Dual Index Tag must be a well."
conditional_formattings:
empty_cell:
empty_mandatory_cell_2:
is_number:
len:
formula:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@
let!(:user) { create(:admin) }
let(:columns) { SampleManifestExcel.configuration.columns.tube_library_with_tag_sequences.dup }
let(:test_file) { 'test_file.xlsx' }
let(:manifest_type) { 'tube_library_with_tag_sequences' }

before do
download.save(test_file)
end

context 'valid' do
context 'standard' do
let(:download) { build(:test_download_tubes, columns:) }
let(:download) { build(:test_download_tubes, columns:, manifest_type:) }

it 'upload' do

Check failure on line 39 in spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb

View workflow job for this annotation

GitHub Actions / Feature tests (2, 1)

Sample manifest with tag sequences library tube sample manifest with tag sequences valid standard upload Failure/Error: arguments[:conditional_formattings][k] = defaults.find_by(:type, k).combine(cf) NoMethodError: undefined method 'combine' for nil

Check failure on line 39 in spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb

View workflow job for this annotation

GitHub Actions / Feature tests (2, 1)

Sample manifest with tag sequences library tube sample manifest with tag sequences valid standard upload Failure/Error: arguments[:conditional_formattings][k] = defaults.find_by(:type, k).combine(cf) NoMethodError: undefined method 'combine' for nil
login_user(user)
visit('sample_manifest_upload_with_tag_sequences/new')
attach_file('File to upload', Rails.root.join(test_file))
Expand All @@ -47,7 +48,7 @@
)
end

it 'reupload and override' do

Check failure on line 51 in spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb

View workflow job for this annotation

GitHub Actions / Feature tests (2, 1)

Sample manifest with tag sequences library tube sample manifest with tag sequences valid standard reupload and override Failure/Error: arguments[:conditional_formattings][k] = defaults.find_by(:type, k).combine(cf) NoMethodError: undefined method 'combine' for nil

Check failure on line 51 in spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb

View workflow job for this annotation

GitHub Actions / Feature tests (2, 1)

Sample manifest with tag sequences library tube sample manifest with tag sequences valid standard reupload and override Failure/Error: arguments[:conditional_formattings][k] = defaults.find_by(:type, k).combine(cf) NoMethodError: undefined method 'combine' for nil
login_user(user)
visit('sample_manifest_upload_with_tag_sequences/new')
attach_file('File to upload', test_file)
Expand Down Expand Up @@ -81,9 +82,9 @@
end

context 'cgap foreign barcodes' do
let(:download) { build(:test_download_tubes_cgap, columns:) }
let(:download) { build(:test_download_tubes_cgap, columns:, manifest_type:) }

it 'upload' do

Check failure on line 87 in spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb

View workflow job for this annotation

GitHub Actions / Feature tests (2, 1)

Sample manifest with tag sequences library tube sample manifest with tag sequences valid cgap foreign barcodes upload Failure/Error: arguments[:conditional_formattings][k] = defaults.find_by(:type, k).combine(cf) NoMethodError: undefined method 'combine' for nil

Check failure on line 87 in spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb

View workflow job for this annotation

GitHub Actions / Feature tests (2, 1)

Sample manifest with tag sequences library tube sample manifest with tag sequences valid cgap foreign barcodes upload Failure/Error: arguments[:conditional_formattings][k] = defaults.find_by(:type, k).combine(cf) NoMethodError: undefined method 'combine' for nil
login_user(user)
visit('sample_manifest_upload_with_tag_sequences/new')
attach_file('File to upload', test_file)
Expand All @@ -97,7 +98,7 @@
context 'upload' do
let(:download) { build(:test_download_tubes, columns: columns, validation_errors: [:library_type]) }

it 'validation errors' do

Check failure on line 101 in spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb

View workflow job for this annotation

GitHub Actions / Feature tests (2, 1)

Sample manifest with tag sequences library tube sample manifest with tag sequences invalid upload validation errors Failure/Error: arguments[:conditional_formattings][k] = defaults.find_by(:type, k).combine(cf) NoMethodError: undefined method 'combine' for nil

Check failure on line 101 in spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb

View workflow job for this annotation

GitHub Actions / Feature tests (2, 1)

Sample manifest with tag sequences library tube sample manifest with tag sequences invalid upload validation errors Failure/Error: arguments[:conditional_formattings][k] = defaults.find_by(:type, k).combine(cf) NoMethodError: undefined method 'combine' for nil
login_user(user)
visit('sample_manifest_upload_with_tag_sequences/new')
attach_file('File to upload', test_file)
Expand All @@ -105,7 +106,7 @@
expect(page).to have_content('Your sample manifest couldn\'t be uploaded.')
end

it 'no file' do

Check failure on line 109 in spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb

View workflow job for this annotation

GitHub Actions / Feature tests (2, 1)

Sample manifest with tag sequences library tube sample manifest with tag sequences invalid upload no file Failure/Error: arguments[:conditional_formattings][k] = defaults.find_by(:type, k).combine(cf) NoMethodError: undefined method 'combine' for nil

Check failure on line 109 in spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb

View workflow job for this annotation

GitHub Actions / Feature tests (2, 1)

Sample manifest with tag sequences library tube sample manifest with tag sequences invalid upload no file Failure/Error: arguments[:conditional_formattings][k] = defaults.find_by(:type, k).combine(cf) NoMethodError: undefined method 'combine' for nil
login_user(user)
visit('sample_manifest_upload_with_tag_sequences/new')
click_button('Upload manifest')
Expand All @@ -116,7 +117,7 @@
context 'cgap foreign barcodes' do
let(:download) { build(:test_download_tubes_cgap, columns: columns, validation_errors: [:library_type]) }

it 'validation errors' do

Check failure on line 120 in spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb

View workflow job for this annotation

GitHub Actions / Feature tests (2, 1)

Sample manifest with tag sequences library tube sample manifest with tag sequences invalid cgap foreign barcodes validation errors Failure/Error: arguments[:conditional_formattings][k] = defaults.find_by(:type, k).combine(cf) NoMethodError: undefined method 'combine' for nil
login_user(user)
visit('sample_manifest_upload_with_tag_sequences/new')
attach_file('File to upload', test_file)
Expand All @@ -130,7 +131,7 @@
build(:test_download_tubes_cgap, columns: columns, validation_errors: [:sample_tube_id_duplicates])
end

it 'validation errors' do

Check failure on line 134 in spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb

View workflow job for this annotation

GitHub Actions / Feature tests (2, 1)

Sample manifest with tag sequences library tube sample manifest with tag sequences invalid duplicate cgap foreign barcodes validation errors Failure/Error: arguments[:conditional_formattings][k] = defaults.find_by(:type, k).combine(cf) NoMethodError: undefined method 'combine' for nil
login_user(user)
visit('sample_manifest_upload_with_tag_sequences/new')
attach_file('File to upload', test_file)
Expand All @@ -156,7 +157,7 @@
build(:test_download_tubes, columns: columns, manifest_type: 'tube_multiplexed_library_with_tag_sequences')
end

it 'with override' do

Check failure on line 160 in spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb

View workflow job for this annotation

GitHub Actions / Feature tests (2, 1)

Sample manifest with tag sequences multiplexed tube sample manifest with tag sequences valid upload and reupload with override Failure/Error: arguments[:conditional_formattings][k] = defaults.find_by(:type, k).combine(cf) NoMethodError: undefined method 'combine' for nil
# upload
expect(download.worksheet.multiplexed_library_tube.aliquots.count).to eq 0
login_user(user)
Expand Down Expand Up @@ -203,7 +204,7 @@
)
end

it 'upload' do

Check failure on line 207 in spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb

View workflow job for this annotation

GitHub Actions / Feature tests (2, 1)

Sample manifest with tag sequences multiplexed tube sample manifest with tag sequences valid cgap foreign barcodes upload Failure/Error: arguments[:conditional_formattings][k] = defaults.find_by(:type, k).combine(cf) NoMethodError: undefined method 'combine' for nil
login_user(user)
visit('sample_manifest_upload_with_tag_sequences/new')
attach_file('File to upload', test_file)
Expand Down
49 changes: 47 additions & 2 deletions spec/sample_manifest_excel/upload/row_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
tube.human_barcode,
sample_manifest.sample_manifest_assets.first.sanger_sample_id,
'AA',
'',
'CC',
'My reference genome',
'My New Library Type',
200,
Expand Down Expand Up @@ -101,6 +101,47 @@
'Unknown'
]
end
let(:data_without_i7_i5) do
[
tube.human_barcode,
sample_manifest.sample_manifest_assets.first.sanger_sample_id,
'',
'',
'My reference genome',
'My New Library Type',
200,
1500,
'SCG--1222_A01',
'',
1,
1,
'Unknown',
'',
'',
'',
'Cell Line',
'Nov-16',
'Nov-16',
'',
'No',
'',
'OTHER',
'',
'',
'',
'',
'',
'SCG--1222_A01',
9606,
'Homo sapiens',
'',
'',
'',
'',
11,
'Unknown'
]
end

it 'is not valid without row number' do
expect(described_class.new(number: 'one', data: data, columns: columns)).not_to be_valid
Expand All @@ -115,6 +156,10 @@
expect(described_class.new(number: 1, data: data)).not_to be_valid
end

it 'is not valid without i7/i5 if i7/i5 column exists' do
expect(described_class.new(number: 1, data: data_without_i7_i5, columns: columns)).not_to be_valid
end

it '#value returns value for specified key' do
expect(described_class.new(number: 1, data: data, columns: columns).value(:sanger_sample_id)).to eq(
sample_manifest.labware.first.sample_manifest_assets.first.sanger_sample_id
Expand Down Expand Up @@ -184,7 +229,7 @@
aliquot = row.aliquots.first
expect(Sample.count - sample_count).to eq(1)
expect(aliquot.tag.oligo).to eq('AA')
expect(aliquot.tag2).to be_nil
expect(aliquot.tag2.oligo).to eq('CC')
expect(aliquot.insert_size_from).to eq(200)
expect(aliquot.insert_size_to).to eq(1500)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/sample_manifest_excel/upload/rows_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
end

it 'is valid if some rows are empty' do
download = build(:test_download_tubes_partial, columns:)
download = build(:test_download_tubes_partial, columns: columns, manifest_type: 'tube_library_with_tag_sequences')
download.save(test_file_name)
expect(described_class.new(SampleManifestExcel::Upload::Data.new(test_file), columns)).to be_valid
end
Expand Down
3 changes: 2 additions & 1 deletion spec/sample_manifest_excel/upload/upload_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
download =
build(
:test_download_tubes,
columns: SampleManifestExcel.configuration.columns.tube_library_with_tag_sequences.dup
columns: SampleManifestExcel.configuration.columns.tube_library_with_tag_sequences.dup,
manifest_type: 'tube_library_with_tag_sequences'
)
download.save(test_file_name)
upload = SampleManifestExcel::Upload::Base.new(file: test_file, column_list: columns, start_row: 9)
Expand Down
Loading