Skip to content

Commit e24d58d

Browse files
authored
Merge pull request #1050 from sanger/dpl-745-revio-sample-sheets
DPL-745: Implement 2-plate sample sheets for Revio
2 parents d250e47 + b8ba0ef commit e24d58d

File tree

10 files changed

+327
-38
lines changed

10 files changed

+327
-38
lines changed

.erd.pacbio.erdconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ cluster: true
3636
indirect: false
3737

3838
# Filter to only include listed models in diagram.
39-
only: ",Pacbio::Run,Pacbio::Well,TagSet"
39+
only: ",Pacbio::Run,Pacbio::Well,TagSet,Request"
4040

4141
# Recurses into relations specified by --only up to a depth N.
4242
only_recursion_depth: 3

app/csv_generator/pacbio_sample_sheet.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def generate
3030
private
3131

3232
def wells
33-
run.plates.first.wells
33+
run.plates.flat_map(&:wells)
3434
end
3535

3636
# Returns a list of wells associated with the plate in column order

app/models/pacbio/well.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ def summary
7373
"#{sample_names} #{comment}".strip
7474
end
7575

76+
# return the sequencing_kit_box_barcode of this plate if well belongs to plate 1
77+
# used for 2-plate sample sheets
78+
def sequencing_kit_box_barcode_plate_1
79+
plate.plate_number == 1 ? plate.sequencing_kit_box_barcode : nil
80+
end
81+
82+
# return the sequencing_kit_box_barcode of this plate if well belongs to plate 2
83+
# used for 2-plate sample sheets
84+
def sequencing_kit_box_barcode_plate_2
85+
plate.plate_number == 2 ? plate.sequencing_kit_box_barcode : nil
86+
end
87+
7688
# collection of all of the requests for a library
7789
# useful for messaging
7890
def request_libraries

config/pipelines/pacbio.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ default: &default
7373
type: :model
7474
value: pool.tube.barcode
7575

76+
# For instructions on structure and syntax, see: 'app/csv_generator/pacbio_sample_sheet.rb'
7677
sample_sheet:
7778
v10:
7879
columns:
@@ -445,14 +446,14 @@ default: &default
445446
with: :well
446447
Plate 1:
447448
type: :model
448-
value: plate.sequencing_kit_box_barcode
449+
value: sequencing_kit_box_barcode_plate_1
449450
populate:
450451
for:
451452
- :well
452453
with: :well
453454
Plate 2:
454-
type: :string
455-
value: null
455+
type: :model
456+
value: sequencing_kit_box_barcode_plate_2
456457
populate:
457458
for:
458459
- :well

erd-pacbio.jpg

19.5 KB
Loading

spec/csv_generator/pacbio_sample_sheet_spec.rb

Lines changed: 178 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
require 'rails_helper'
44

5+
# See additional sample sheet specs at 'spec/pipelines/pacbio/sample_sheet_spec.rb'
6+
57
RSpec.describe PacbioSampleSheet, type: :model do
68
describe '#generate' do
79
subject(:csv_string) { csv.generate }
@@ -288,7 +290,6 @@
288290
]
289291
sample_expectations.each do |sample_data, well|
290292
expect(sample_data).to eq([
291-
292293
'',
293294
'',
294295
'false', # well.collection?
@@ -402,5 +403,181 @@
402403
end
403404
end
404405
end
406+
407+
context 'v12_revio' do
408+
let(:smrt_link_version) { create(:pacbio_smrt_link_version, name: 'v12_revio', default: true) }
409+
410+
context 'when the libraries are tagged' do
411+
let(:well1) do
412+
create(
413+
:pacbio_well_with_pools,
414+
pre_extension_time: 2,
415+
generate_hifi: 'In SMRT Link',
416+
ccs_analysis_output: 'Yes'
417+
)
418+
end
419+
let(:well2) do
420+
create(
421+
:pacbio_well_with_pools,
422+
pre_extension_time: 2,
423+
generate_hifi: 'In SMRT Link',
424+
ccs_analysis_output: 'No'
425+
)
426+
end
427+
428+
it 'must return a csv string' do
429+
expect(csv_string.class).to eq String
430+
end
431+
432+
it 'must have the correct headers' do
433+
headers = parsed_csv[0]
434+
435+
expected_headers = Pipelines.pacbio.sample_sheet.columns.map(&:first)
436+
expect(headers).to eq(expected_headers)
437+
end
438+
439+
it 'must have the correct well header rows' do
440+
well_data_1 = parsed_csv[1]
441+
well_data_2 = parsed_csv[7]
442+
# iterate through the wells under test
443+
well_expectations = [
444+
[well_data_1, well1],
445+
[well_data_2, well2]
446+
]
447+
well_expectations.each do |well_data, well|
448+
expect(well_data).to eq([
449+
'Standard', # library type
450+
'1', # reagent plate
451+
well.plate.run.sequencing_kit_box_barcode,
452+
nil, # plate 2: sequencing_kit_box_barcode
453+
well.plate.run.name,
454+
well.plate.run.system_name,
455+
well.plate.run.comments,
456+
'true', # well.collection?
457+
well.position_leading_zero,
458+
well.pool_barcode,
459+
well.movie_acquisition_time.to_s,
460+
well.include_base_kinetics.to_s,
461+
well.library_concentration.to_s,
462+
well.polymerase_kit,
463+
well.automation_parameters,
464+
well.barcode_set,
465+
'', # barcode name - does not apply
466+
'' # sample name - does not apply
467+
])
468+
end
469+
end
470+
471+
it 'must have the correct sample rows' do
472+
# Note the increment in the parsed_csv index
473+
sample_data_1 = parsed_csv[2]
474+
sample_data_2 = parsed_csv[8]
475+
476+
# iterate through the samples under test
477+
sample_expectations = [
478+
[sample_data_1, well1],
479+
[sample_data_2, well2]
480+
]
481+
sample_expectations.each do |sample_data, well|
482+
expect(sample_data).to eq([
483+
'',
484+
'1', # reagent plate
485+
'',
486+
'',
487+
'',
488+
'',
489+
'',
490+
'false', # well.collection?
491+
well.position,
492+
'',
493+
'',
494+
'',
495+
'',
496+
'',
497+
'',
498+
'',
499+
well.libraries.first.barcode_name,
500+
well.libraries.first.request.sample_name
501+
])
502+
end
503+
end
504+
end
505+
506+
context 'when the libraries are untagged' do
507+
let(:pool1) { create_list(:pacbio_pool, 1, :untagged) }
508+
let(:pool2) { create_list(:pacbio_pool, 1, :untagged) }
509+
let(:well1) do
510+
create(:pacbio_well, pre_extension_time: 2, generate_hifi: 'Do Not Generate',
511+
ccs_analysis_output: 'Yes', pools: pool1)
512+
end
513+
let(:well2) do
514+
create(:pacbio_well, generate_hifi: 'On Instrument', ccs_analysis_output: 'No',
515+
pools: pool2)
516+
end
517+
let(:plate) { create(:pacbio_plate, wells: [well1, well2]) }
518+
519+
it 'must return a csv string' do
520+
expect(csv_string).to be_a String
521+
end
522+
523+
it 'must have the correct headers' do
524+
headers = parsed_csv[0]
525+
526+
expected_headers = Pipelines.pacbio.sample_sheet.columns.map(&:first)
527+
expect(headers).to eq(expected_headers)
528+
end
529+
530+
it 'must have the correct well header rows' do
531+
well_data_1 = parsed_csv[1]
532+
well_data_2 = parsed_csv[2]
533+
# iterate through the wells under test
534+
well_expectations = [
535+
[well_data_1, well1],
536+
[well_data_2, well2]
537+
]
538+
well_expectations.each do |well_data, well|
539+
expect(well_data).to eq([
540+
'Standard', # library type
541+
'1', # reagent plate
542+
well.plate.run.sequencing_kit_box_barcode,
543+
nil, # plate 2: sequencing_kit_box_barcode
544+
well.plate.run.name,
545+
well.plate.run.system_name,
546+
well.plate.run.comments,
547+
'true', # well.collection?
548+
well.position_leading_zero,
549+
well.pool_barcode,
550+
well.movie_acquisition_time.to_s,
551+
well.include_base_kinetics.to_s,
552+
well.library_concentration.to_s,
553+
well.polymerase_kit,
554+
well.automation_parameters,
555+
well.barcode_set,
556+
'', # barcode name - does not apply
557+
well.find_sample_name
558+
])
559+
end
560+
end
561+
562+
it 'must not have sample rows' do
563+
expect(parsed_csv.size).to eq 3
564+
end
565+
end
566+
567+
context 'with lots of wells in unpredictable orders' do
568+
let(:pool1) { create_list(:pacbio_pool, 1, :untagged) }
569+
let(:pool2) { create_list(:pacbio_pool, 1, :untagged) }
570+
let(:pool3) { create_list(:pacbio_pool, 1, :untagged) }
571+
let(:well1) { create(:pacbio_well, pools: pool1, row: 'A', column: 10) }
572+
let(:well2) { create(:pacbio_well, pools: pool2, row: 'A', column: 5) }
573+
let(:well3) { create(:pacbio_well, pools: pool3, row: 'B', column: 1) }
574+
let(:plate) { create(:pacbio_plate, wells: [well1, well2, well3]) }
575+
576+
it 'sorts the wells by column' do
577+
sorted_well_positions = parsed_csv[1..].pluck(8)
578+
expect(sorted_well_positions).to eq(%w[B01 A05 A10])
579+
end
580+
end
581+
end
405582
end
406583
end

spec/factories/pacbio/runs.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,17 @@ def build_wells_by_position(positions)
2424
end
2525

2626
system_name { 'Revio' }
27-
plates { [build(:pacbio_plate, wells: build_wells_by_position(well_positions_plate_1)), build(:pacbio_plate, wells: build_wells_by_position(well_positions_plate_2))] }
27+
plates do
28+
[
29+
build(:pacbio_plate, plate_number: 1, wells: build_wells_by_position(well_positions_plate_1)),
30+
build(:pacbio_plate, plate_number: 2, wells: build_wells_by_position(well_positions_plate_2))
31+
]
32+
end
2833
end
2934

3035
factory :pacbio_sequel_run do
3136
system_name { 'Sequel IIe' }
32-
plates { build_list(:pacbio_plate, 1, wells: [build(:pacbio_well)]) }
37+
plates { build_list(:pacbio_plate, 1, plate_number: 1, wells: [build(:pacbio_well)]) }
3338
end
3439
end
3540
end

0 commit comments

Comments
 (0)