From 240ea0ab82dc74ad3aeb22ba6c1102be9085571f Mon Sep 17 00:00:00 2001 From: Katy Taylor Date: Fri, 3 Nov 2023 14:45:43 +0000 Subject: [PATCH 1/4] Switch to controlling autodetection of studies and projects independently - this requires an API change in Sequencescape, so is dependent on a new SS release --- .../labware_creators/multi_stamp_tubes.rb | 10 ++++-- .../scrna_core_cell_extraction.wip.yml | 3 +- .../multi_stamp_tubes_spec.rb | 31 +++++++++++++++---- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/app/models/labware_creators/multi_stamp_tubes.rb b/app/models/labware_creators/multi_stamp_tubes.rb index 66e49e3ff..20dd12838 100644 --- a/app/models/labware_creators/multi_stamp_tubes.rb +++ b/app/models/labware_creators/multi_stamp_tubes.rb @@ -139,8 +139,12 @@ def asset_uuids # Otherwise, Project and Study can be specified explicitly on the Submission Template # (submission_parameters field) if autodetection is not appropriate (for instance in Cardinal, # where one tube will contain samples from multiple different studies). - def autodetect_studies_project - configured_params[:autodetect_studies_project] || false + def autodetect_studies + configured_params[:autodetect_studies] || false + end + + def autodetect_projects + configured_params[:autodetect_projects] || false end # Creates a submission in Sequencescape based on the parent tubes @@ -148,7 +152,7 @@ def create_submission_from_parent_tubes sequencescape_submission_parameters = { template_name: configured_params[:template_name], request_options: configured_params[:request_options], - asset_groups: [{ assets: asset_uuids, autodetect_studies_projects: autodetect_studies_project }], + asset_groups: [{ assets: asset_uuids, autodetect_studies: autodetect_studies, autodetect_projects: autodetect_projects }], api: api, user: user_uuid } diff --git a/config/purposes/scrna_core_cell_extraction.wip.yml b/config/purposes/scrna_core_cell_extraction.wip.yml index ac6db152d..a2a9047a2 100644 --- a/config/purposes/scrna_core_cell_extraction.wip.yml +++ b/config/purposes/scrna_core_cell_extraction.wip.yml @@ -44,7 +44,8 @@ LRC Blood Bank: fragment_size_required_from: '200' fragment_size_required_to: '800' allowed_extra_barcodes: false - autodetect_studies_project: false + autodetect_studies: true + autodetect_projects: false :file_links: - name: 'Download Scanned Tube Layout for LRC Blood Bank Plate' id: scrna_core_cell_extraction_sample_arraying_tube_layout diff --git a/spec/models/labware_creators/multi_stamp_tubes_spec.rb b/spec/models/labware_creators/multi_stamp_tubes_spec.rb index 1a3b1b356..c76b65110 100644 --- a/spec/models/labware_creators/multi_stamp_tubes_spec.rb +++ b/spec/models/labware_creators/multi_stamp_tubes_spec.rb @@ -145,22 +145,41 @@ end end - describe '#autodetect_studies_project' do + describe '#autodetect_studies' do it 'returns true when specified in the config' do expect(subject).to receive(:configured_params).and_return( - { autodetect_studies_project: true, request_options: {} } + { autodetect_studies: true, request_options: {} } ) - expect(subject.send(:autodetect_studies_project)).to eq(true) + expect(subject.send(:autodetect_studies)).to eq(true) end it 'returns false when specified in the config' do expect(subject).to receive(:configured_params).and_return( - { autodetect_studies_project: false, request_options: {} } + { autodetect_studies: false, request_options: {} } ) - expect(subject.send(:autodetect_studies_project)).to eq(false) + expect(subject.send(:autodetect_studies)).to eq(false) end it 'returns false if not specified in the config' do expect(subject).to receive(:configured_params).and_return({ request_options: {} }) - expect(subject.send(:autodetect_studies_project)).to eq(false) + expect(subject.send(:autodetect_studies)).to eq(false) + end + end + + describe '#autodetect_projects' do + it 'returns true when specified in the config' do + expect(subject).to receive(:configured_params).and_return( + { autodetect_projects: true, request_options: {} } + ) + expect(subject.send(:autodetect_projects)).to eq(true) + end + it 'returns false when specified in the config' do + expect(subject).to receive(:configured_params).and_return( + { autodetect_projects: false, request_options: {} } + ) + expect(subject.send(:autodetect_projects)).to eq(false) + end + it 'returns false if not specified in the config' do + expect(subject).to receive(:configured_params).and_return({ request_options: {} }) + expect(subject.send(:autodetect_projects)).to eq(false) end end end From b0ce226bbce7bc4c8f4d8c57967131c7972a18f2 Mon Sep 17 00:00:00 2001 From: Katy Taylor Date: Fri, 3 Nov 2023 14:52:34 +0000 Subject: [PATCH 2/4] prettier & rubocop --- app/models/labware_creators/multi_stamp_tubes.rb | 6 ++++-- spec/models/labware_creators/multi_stamp_tubes_spec.rb | 4 +--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/labware_creators/multi_stamp_tubes.rb b/app/models/labware_creators/multi_stamp_tubes.rb index 20dd12838..37c0e458c 100644 --- a/app/models/labware_creators/multi_stamp_tubes.rb +++ b/app/models/labware_creators/multi_stamp_tubes.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module LabwareCreators - class MultiStampTubes < Base # rubocop:todo Style/Documentation + class MultiStampTubes < Base # rubocop:todo Style/Documentation, Metrics/ClassLength include LabwareCreators::CustomPage include SupportParent::TubeOnly @@ -152,7 +152,9 @@ def create_submission_from_parent_tubes sequencescape_submission_parameters = { template_name: configured_params[:template_name], request_options: configured_params[:request_options], - asset_groups: [{ assets: asset_uuids, autodetect_studies: autodetect_studies, autodetect_projects: autodetect_projects }], + asset_groups: [ + { assets: asset_uuids, autodetect_studies: autodetect_studies, autodetect_projects: autodetect_projects } + ], api: api, user: user_uuid } diff --git a/spec/models/labware_creators/multi_stamp_tubes_spec.rb b/spec/models/labware_creators/multi_stamp_tubes_spec.rb index c76b65110..5d2439f82 100644 --- a/spec/models/labware_creators/multi_stamp_tubes_spec.rb +++ b/spec/models/labware_creators/multi_stamp_tubes_spec.rb @@ -147,9 +147,7 @@ describe '#autodetect_studies' do it 'returns true when specified in the config' do - expect(subject).to receive(:configured_params).and_return( - { autodetect_studies: true, request_options: {} } - ) + expect(subject).to receive(:configured_params).and_return({ autodetect_studies: true, request_options: {} }) expect(subject.send(:autodetect_studies)).to eq(true) end it 'returns false when specified in the config' do From 6fbbf16cd2295a406ef8df69e263dc399a7c39c6 Mon Sep 17 00:00:00 2001 From: Katy Taylor Date: Mon, 6 Nov 2023 10:50:09 +0000 Subject: [PATCH 3/4] Fix test mocking --- spec/models/labware_creators/multi_stamp_tubes_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/models/labware_creators/multi_stamp_tubes_spec.rb b/spec/models/labware_creators/multi_stamp_tubes_spec.rb index 5d2439f82..9cb244efa 100644 --- a/spec/models/labware_creators/multi_stamp_tubes_spec.rb +++ b/spec/models/labware_creators/multi_stamp_tubes_spec.rb @@ -265,7 +265,8 @@ assets: parent_receptacle_uuids, request_options: purpose_config[:submission_options]['Cardinal library prep']['request_options'], user: user_uuid, - autodetect_studies_projects: false + autodetect_studies: false, + autodetect_projects: false } }, body: '{"order":{"uuid":"order-uuid"}}' From 54a9a1af387c3c38bfcabe2b445477390b05eb15 Mon Sep 17 00:00:00 2001 From: Katy Taylor Date: Wed, 8 Nov 2023 15:55:45 +0000 Subject: [PATCH 4/4] Replace usage of autodetect_studies_projects with the individual versions - so that we can remove it from the API and simplify the code --- app/models/presenters/submission_plate_presenter.rb | 2 +- app/models/sequencescape_submission.rb | 2 +- spec/models/presenters/submission_plate_presenter_spec.rb | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/presenters/submission_plate_presenter.rb b/app/models/presenters/submission_plate_presenter.rb index a9aaa1234..e7907d554 100644 --- a/app/models/presenters/submission_plate_presenter.rb +++ b/app/models/presenters/submission_plate_presenter.rb @@ -57,7 +57,7 @@ def asset_groups .wells .compact_blank .group_by(&:order_group) - .map { |_, wells| { assets: wells.map(&:uuid), autodetect_studies_projects: true } } + .map { |_, wells| { assets: wells.map(&:uuid), autodetect_studies: true, autodetect_projects: true } } end end end diff --git a/app/models/sequencescape_submission.rb b/app/models/sequencescape_submission.rb index bc4a5fb5d..fa53d444b 100644 --- a/app/models/sequencescape_submission.rb +++ b/app/models/sequencescape_submission.rb @@ -110,7 +110,7 @@ def asset_groups=(asset_groups) def asset_groups_for_orders_creation return asset_groups unless (asset_groups.length == 1) && extra_barcodes - [{ assets: [assets, extra_assets].flatten.compact, autodetect_studies_projects: true }] + [{ assets: [assets, extra_assets].flatten.compact, autodetect_studies: true, autodetect_projects: true }] end private diff --git a/spec/models/presenters/submission_plate_presenter_spec.rb b/spec/models/presenters/submission_plate_presenter_spec.rb index 86003e7d0..07b31d1df 100644 --- a/spec/models/presenters/submission_plate_presenter_spec.rb +++ b/spec/models/presenters/submission_plate_presenter_spec.rb @@ -45,7 +45,7 @@ request_options: { 'option' => 1 }, - asset_groups: [{ assets: wells_with_aliquots, autodetect_studies_projects: true }] + asset_groups: [{ assets: wells_with_aliquots, autodetect_studies: true, autodetect_projects: true }] ) ) ], @@ -57,7 +57,7 @@ request_options: { 'option' => 2 }, - asset_groups: [{ assets: wells_with_aliquots, autodetect_studies_projects: true }] + asset_groups: [{ assets: wells_with_aliquots, autodetect_studies: true, autodetect_projects: true }] ) ) ]