|
2 | 2 |
|
3 | 3 | require 'rails_helper'
|
4 | 4 |
|
| 5 | +# See additional sample sheet specs at 'spec/pipelines/pacbio/sample_sheet_spec.rb' |
| 6 | + |
5 | 7 | RSpec.describe PacbioSampleSheet, type: :model do
|
6 | 8 | describe '#generate' do
|
7 | 9 | subject(:csv_string) { csv.generate }
|
|
288 | 290 | ]
|
289 | 291 | sample_expectations.each do |sample_data, well|
|
290 | 292 | expect(sample_data).to eq([
|
291 |
| - |
292 | 293 | '',
|
293 | 294 | '',
|
294 | 295 | 'false', # well.collection?
|
|
402 | 403 | end
|
403 | 404 | end
|
404 | 405 | 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 |
405 | 582 | end
|
406 | 583 | end
|
0 commit comments