Skip to content

Commit

Permalink
Merge pull request #1050 from sanger/dpl-745-revio-sample-sheets
Browse files Browse the repository at this point in the history
DPL-745: Implement 2-plate sample sheets for Revio
  • Loading branch information
stevieing authored Jul 19, 2023
2 parents d250e47 + b8ba0ef commit e24d58d
Show file tree
Hide file tree
Showing 10 changed files with 327 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .erd.pacbio.erdconfig
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ cluster: true
indirect: false

# Filter to only include listed models in diagram.
only: ",Pacbio::Run,Pacbio::Well,TagSet"
only: ",Pacbio::Run,Pacbio::Well,TagSet,Request"

# Recurses into relations specified by --only up to a depth N.
only_recursion_depth: 3
2 changes: 1 addition & 1 deletion app/csv_generator/pacbio_sample_sheet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def generate
private

def wells
run.plates.first.wells
run.plates.flat_map(&:wells)
end

# Returns a list of wells associated with the plate in column order
Expand Down
12 changes: 12 additions & 0 deletions app/models/pacbio/well.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ def summary
"#{sample_names} #{comment}".strip
end

# return the sequencing_kit_box_barcode of this plate if well belongs to plate 1
# used for 2-plate sample sheets
def sequencing_kit_box_barcode_plate_1
plate.plate_number == 1 ? plate.sequencing_kit_box_barcode : nil
end

# return the sequencing_kit_box_barcode of this plate if well belongs to plate 2
# used for 2-plate sample sheets
def sequencing_kit_box_barcode_plate_2
plate.plate_number == 2 ? plate.sequencing_kit_box_barcode : nil
end

# collection of all of the requests for a library
# useful for messaging
def request_libraries
Expand Down
7 changes: 4 additions & 3 deletions config/pipelines/pacbio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ default: &default
type: :model
value: pool.tube.barcode

# For instructions on structure and syntax, see: 'app/csv_generator/pacbio_sample_sheet.rb'
sample_sheet:
v10:
columns:
Expand Down Expand Up @@ -445,14 +446,14 @@ default: &default
with: :well
Plate 1:
type: :model
value: plate.sequencing_kit_box_barcode
value: sequencing_kit_box_barcode_plate_1
populate:
for:
- :well
with: :well
Plate 2:
type: :string
value: null
type: :model
value: sequencing_kit_box_barcode_plate_2
populate:
for:
- :well
Expand Down
Binary file modified erd-pacbio.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
179 changes: 178 additions & 1 deletion spec/csv_generator/pacbio_sample_sheet_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

require 'rails_helper'

# See additional sample sheet specs at 'spec/pipelines/pacbio/sample_sheet_spec.rb'

RSpec.describe PacbioSampleSheet, type: :model do
describe '#generate' do
subject(:csv_string) { csv.generate }
Expand Down Expand Up @@ -288,7 +290,6 @@
]
sample_expectations.each do |sample_data, well|
expect(sample_data).to eq([

'',
'',
'false', # well.collection?
Expand Down Expand Up @@ -402,5 +403,181 @@
end
end
end

context 'v12_revio' do
let(:smrt_link_version) { create(:pacbio_smrt_link_version, name: 'v12_revio', default: true) }

context 'when the libraries are tagged' do
let(:well1) do
create(
:pacbio_well_with_pools,
pre_extension_time: 2,
generate_hifi: 'In SMRT Link',
ccs_analysis_output: 'Yes'
)
end
let(:well2) do
create(
:pacbio_well_with_pools,
pre_extension_time: 2,
generate_hifi: 'In SMRT Link',
ccs_analysis_output: 'No'
)
end

it 'must return a csv string' do
expect(csv_string.class).to eq String
end

it 'must have the correct headers' do
headers = parsed_csv[0]

expected_headers = Pipelines.pacbio.sample_sheet.columns.map(&:first)
expect(headers).to eq(expected_headers)
end

it 'must have the correct well header rows' do
well_data_1 = parsed_csv[1]
well_data_2 = parsed_csv[7]
# iterate through the wells under test
well_expectations = [
[well_data_1, well1],
[well_data_2, well2]
]
well_expectations.each do |well_data, well|
expect(well_data).to eq([
'Standard', # library type
'1', # reagent plate
well.plate.run.sequencing_kit_box_barcode,
nil, # plate 2: sequencing_kit_box_barcode
well.plate.run.name,
well.plate.run.system_name,
well.plate.run.comments,
'true', # well.collection?
well.position_leading_zero,
well.pool_barcode,
well.movie_acquisition_time.to_s,
well.include_base_kinetics.to_s,
well.library_concentration.to_s,
well.polymerase_kit,
well.automation_parameters,
well.barcode_set,
'', # barcode name - does not apply
'' # sample name - does not apply
])
end
end

it 'must have the correct sample rows' do
# Note the increment in the parsed_csv index
sample_data_1 = parsed_csv[2]
sample_data_2 = parsed_csv[8]

# iterate through the samples under test
sample_expectations = [
[sample_data_1, well1],
[sample_data_2, well2]
]
sample_expectations.each do |sample_data, well|
expect(sample_data).to eq([
'',
'1', # reagent plate
'',
'',
'',
'',
'',
'false', # well.collection?
well.position,
'',
'',
'',
'',
'',
'',
'',
well.libraries.first.barcode_name,
well.libraries.first.request.sample_name
])
end
end
end

context 'when the libraries are untagged' do
let(:pool1) { create_list(:pacbio_pool, 1, :untagged) }
let(:pool2) { create_list(:pacbio_pool, 1, :untagged) }
let(:well1) do
create(:pacbio_well, pre_extension_time: 2, generate_hifi: 'Do Not Generate',
ccs_analysis_output: 'Yes', pools: pool1)
end
let(:well2) do
create(:pacbio_well, generate_hifi: 'On Instrument', ccs_analysis_output: 'No',
pools: pool2)
end
let(:plate) { create(:pacbio_plate, wells: [well1, well2]) }

it 'must return a csv string' do
expect(csv_string).to be_a String
end

it 'must have the correct headers' do
headers = parsed_csv[0]

expected_headers = Pipelines.pacbio.sample_sheet.columns.map(&:first)
expect(headers).to eq(expected_headers)
end

it 'must have the correct well header rows' do
well_data_1 = parsed_csv[1]
well_data_2 = parsed_csv[2]
# iterate through the wells under test
well_expectations = [
[well_data_1, well1],
[well_data_2, well2]
]
well_expectations.each do |well_data, well|
expect(well_data).to eq([
'Standard', # library type
'1', # reagent plate
well.plate.run.sequencing_kit_box_barcode,
nil, # plate 2: sequencing_kit_box_barcode
well.plate.run.name,
well.plate.run.system_name,
well.plate.run.comments,
'true', # well.collection?
well.position_leading_zero,
well.pool_barcode,
well.movie_acquisition_time.to_s,
well.include_base_kinetics.to_s,
well.library_concentration.to_s,
well.polymerase_kit,
well.automation_parameters,
well.barcode_set,
'', # barcode name - does not apply
well.find_sample_name
])
end
end

it 'must not have sample rows' do
expect(parsed_csv.size).to eq 3
end
end

context 'with lots of wells in unpredictable orders' do
let(:pool1) { create_list(:pacbio_pool, 1, :untagged) }
let(:pool2) { create_list(:pacbio_pool, 1, :untagged) }
let(:pool3) { create_list(:pacbio_pool, 1, :untagged) }
let(:well1) { create(:pacbio_well, pools: pool1, row: 'A', column: 10) }
let(:well2) { create(:pacbio_well, pools: pool2, row: 'A', column: 5) }
let(:well3) { create(:pacbio_well, pools: pool3, row: 'B', column: 1) }
let(:plate) { create(:pacbio_plate, wells: [well1, well2, well3]) }

it 'sorts the wells by column' do
sorted_well_positions = parsed_csv[1..].pluck(8)
expect(sorted_well_positions).to eq(%w[B01 A05 A10])
end
end
end
end
end
9 changes: 7 additions & 2 deletions spec/factories/pacbio/runs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@ def build_wells_by_position(positions)
end

system_name { 'Revio' }
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))] }
plates do
[
build(:pacbio_plate, plate_number: 1, wells: build_wells_by_position(well_positions_plate_1)),
build(:pacbio_plate, plate_number: 2, wells: build_wells_by_position(well_positions_plate_2))
]
end
end

factory :pacbio_sequel_run do
system_name { 'Sequel IIe' }
plates { build_list(:pacbio_plate, 1, wells: [build(:pacbio_well)]) }
plates { build_list(:pacbio_plate, 1, plate_number: 1, wells: [build(:pacbio_well)]) }
end
end
end
Loading

0 comments on commit e24d58d

Please sign in to comment.