-
Notifications
You must be signed in to change notification settings - Fork 34
Y25-687 - Aviti additional information #5657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
BenTopping
wants to merge
4
commits into
develop
Choose a base branch
from
Y25-687-aviti-additional-information
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a47badf
feat(aviti): adds custom primer kit used field to batch task
BenTopping 820bbb1
feat(aviti): adds quant method used field to batch task
BenTopping 438386f
feat(eseq_flowcell): adds custom eseq flowcell class
BenTopping 9eb3c76
feat(eseq_flowcell): adds controls
BenTopping File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # frozen_string_literal: true | ||
| # Generates warehouse messages describing an Element Aviti flowcell. | ||
| # This is a subset of FlowcellIo containing only fields required by Eseq. | ||
| class Api::Messages::EseqFlowcellIo < Api::Base | ||
| self.includes = { | ||
| requests: [ | ||
| { | ||
| target_asset: { | ||
| aliquots: [ | ||
| :library, | ||
| :bait_library, | ||
| :primer_panel, | ||
| { tag: :tag_group, tag2: :tag_group, sample: :uuid_object, study: :uuid_object } | ||
| ] | ||
| } | ||
| }, | ||
| :batch_request | ||
| ] | ||
| } | ||
|
|
||
| # The following modules add methods onto the relevant models, which are used below in generation of the | ||
| # eseq flowcel MLWH message. | ||
| # Included in SequencingRequest model | ||
| module LaneExtensions | ||
| def self.included(base) | ||
| base.class_eval do | ||
| def quant_method_used | ||
| detect_descriptor('Quant method used') | ||
| end | ||
|
|
||
| def custom_primer_kit_used | ||
| detect_descriptor('Custom primer kit used') | ||
| end | ||
| end | ||
| end | ||
| end | ||
|
|
||
| renders_model(::Batch) | ||
|
|
||
| map_attribute_to_json_attribute(:id, 'flowcell_id') | ||
| map_attribute_to_json_attribute(:updated_at) | ||
|
|
||
| with_nested_has_many_association(:requests, as: :lanes) do | ||
| map_attribute_to_json_attribute(:position, 'lane') | ||
| map_attribute_to_json_attribute(:mx_library, 'id_pool_lims') | ||
| map_attribute_to_json_attribute(:lane_identifier, 'entity_id_lims') | ||
| map_attribute_to_json_attribute(:request_purpose, 'purpose') | ||
| map_attribute_to_json_attribute(:quant_method_used) | ||
| map_attribute_to_json_attribute(:custom_primer_kit_used) | ||
|
|
||
| with_nested_has_many_association(:lane_samples, as: :samples) do | ||
| with_association(:tag) { map_attribute_to_json_attribute(:oligo, 'tag_sequence') } | ||
| with_association(:tag2) { map_attribute_to_json_attribute(:oligo, 'tag2_sequence') } | ||
| map_attribute_to_json_attribute(:library_type, 'pipeline_id_lims') | ||
| with_association(:bait_library) { map_attribute_to_json_attribute(:name, 'bait_name') } | ||
| map_attribute_to_json_attribute(:insert_size_from, 'requested_insert_size_from') | ||
| map_attribute_to_json_attribute(:insert_size_to, 'requested_insert_size_to') | ||
| with_association(:sample) { map_attribute_to_json_attribute(:uuid, 'sample_uuid') } | ||
| with_association(:study) { map_attribute_to_json_attribute(:uuid, 'study_uuid') } | ||
| with_association(:primer_panel) { map_attribute_to_json_attribute(:name, 'primer_panel') } | ||
| with_association(:library) { map_attribute_to_json_attribute(:external_identifier, 'id_library_lims') } | ||
| map_attribute_to_json_attribute(:aliquot_type, 'entity_type') | ||
| end | ||
|
|
||
| # The following methods come from the Aliquot model or the relevant module above. | ||
| # They are included in the MLWH message under 'controls'. | ||
| with_nested_has_many_association(:controls) do | ||
| with_association(:tag) { map_attribute_to_json_attribute(:oligo, 'tag_sequence') } | ||
| with_association(:tag2) { map_attribute_to_json_attribute(:oligo, 'tag2_sequence') } | ||
| map_attribute_to_json_attribute(:library_type, 'pipeline_id_lims') | ||
| with_association(:sample) { map_attribute_to_json_attribute(:uuid, 'sample_uuid') } | ||
| with_association(:study) { map_attribute_to_json_attribute(:uuid, 'study_uuid') } | ||
| with_association(:library) { map_attribute_to_json_attribute(:external_identifier, 'id_library_lims') } | ||
| map_attribute_to_json_attribute(:control_aliquot_type, 'entity_type') | ||
| end | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,158 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require 'rails_helper' | ||
|
|
||
| RSpec.describe Api::Messages::EseqFlowcellIo do | ||
| let(:message) { described_class.to_hash(sequencing_batch.reload) } | ||
|
|
||
| context 'with a batch' do | ||
| let(:sequencing_pipeline) { create(:element_aviti_sequencing_pipeline) } | ||
| let(:sequencing_batch) { create(:sequencing_batch, pipeline: sequencing_pipeline) } | ||
|
|
||
| let!(:request) do | ||
| create( | ||
| :complete_sequencing_request, | ||
| asset: mx_tube1, | ||
| batch: sequencing_batch, | ||
| target_asset: lane1, | ||
| request_type: request_type, | ||
| event_descriptors: request_data | ||
| ) | ||
| end | ||
|
|
||
| let(:mx_tube1) { create(:multiplexed_library_tube, sample_count: 1) } | ||
| let(:request_type) { sequencing_pipeline.request_types.first } | ||
|
|
||
| let(:lane1) do | ||
| create(:lane, aliquots: mx_tube1.aliquots.map(&:dup)).tap do |lane| | ||
| lane.labware.parents << phix | ||
| lane.index_aliquots | ||
| end | ||
| end | ||
|
|
||
| let(:phix) { create(:spiked_buffer, :tube_barcode, tag_option: 'Dual') } | ||
|
|
||
| let(:tags) { lane1.aliquots.map(&:tag) } | ||
| let(:tag2s) { lane1.aliquots.map(&:tag2) } | ||
| let(:aliquots) { lane1.aliquots } | ||
|
|
||
| let(:expected_json) do | ||
| { | ||
| 'flowcell_id' => sequencing_batch.id, | ||
| 'lanes' => [ | ||
| { | ||
| 'lane' => 1, | ||
| 'id_pool_lims' => mx_tube1.human_barcode, | ||
| 'entity_id_lims' => lane1.id, | ||
| 'purpose' => 'standard', | ||
| 'quant_method_used' => 'Tapestation', | ||
| 'custom_primer_kit_used' => 'No', | ||
| 'samples' => [ | ||
| { | ||
| 'tag_sequence' => tags[0].oligo, | ||
| 'tag2_sequence' => tag2s[0].oligo, | ||
| 'pipeline_id_lims' => 'Standard', | ||
| 'bait_name' => aliquots[0].bait_library.name, | ||
| 'requested_insert_size_from' => 100, | ||
| 'requested_insert_size_to' => 200, | ||
| 'sample_uuid' => aliquots[0].sample.uuid, | ||
| 'study_uuid' => aliquots[0].study.uuid, | ||
| 'primer_panel' => aliquots[0].primer_panel.name, | ||
| 'id_library_lims' => aliquots[0].library.human_barcode, | ||
| 'entity_type' => 'library_indexed' | ||
| } | ||
| ], | ||
| 'controls' => [ | ||
| { | ||
| 'tag_sequence' => 'TGTGCAGC', | ||
| 'tag2_sequence' => 'ACTGATGT', | ||
| 'pipeline_id_lims' => nil, | ||
| 'sample_uuid' => phix.aliquots[0].sample.uuid, | ||
| 'id_library_lims' => phix.human_barcode, | ||
| 'entity_type' => 'library_indexed_spike' | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| end | ||
|
|
||
| let(:request_data) do | ||
| { | ||
| 'Quant method used' => 'Tapestation', | ||
| 'Custom primer kit used' => 'No' | ||
| } | ||
| end | ||
|
|
||
| context 'with all request data' do | ||
| it 'generates valid json' do | ||
| expect(message.as_json).to include_json(expected_json) | ||
| end | ||
| end | ||
|
|
||
| context 'with some missing request data' do | ||
| let(:request_data) do | ||
| { | ||
| 'Quant method used' => 'Tapestation', | ||
| 'Custom primer kit used' => nil | ||
| } | ||
| end | ||
|
|
||
| it 'generates valid json' do | ||
| # Should have an empty primer kit used | ||
| expected_json['lanes'][0]['custom_primer_kit_used'] = nil | ||
|
|
||
| expect(message.as_json).to include_json(expected_json) | ||
| end | ||
| end | ||
|
|
||
| context 'with updated events' do | ||
| before do | ||
| create( | ||
| :lab_event, | ||
| eventful: request, | ||
| batch: request.batch, | ||
| descriptors: { | ||
| 'Quant method used' => 'Tapestation & qPCR', | ||
| 'Custom primer kit used' => 'Yes' | ||
| } | ||
| ) | ||
| end | ||
|
|
||
| let(:expected_json) do | ||
| { | ||
| 'flowcell_id' => sequencing_batch.id, | ||
| 'lanes' => [ | ||
| { | ||
| 'lane' => 1, | ||
| 'id_pool_lims' => mx_tube1.human_barcode, | ||
| 'entity_id_lims' => lane1.id, | ||
| 'purpose' => 'standard', | ||
| 'quant_method_used' => 'Tapestation & qPCR', | ||
| 'custom_primer_kit_used' => 'Yes', | ||
| 'samples' => [ | ||
| { | ||
| 'tag_sequence' => tags[0].oligo, | ||
| 'tag2_sequence' => tag2s[0].oligo, | ||
| 'pipeline_id_lims' => 'Standard', | ||
| 'bait_name' => aliquots[0].bait_library.name, | ||
| 'requested_insert_size_from' => 100, | ||
| 'requested_insert_size_to' => 200, | ||
| 'sample_uuid' => aliquots[0].sample.uuid, | ||
| 'study_uuid' => aliquots[0].study.uuid, | ||
| 'primer_panel' => aliquots[0].primer_panel.name, | ||
| 'id_library_lims' => aliquots[0].library.human_barcode, | ||
| 'entity_type' => 'library_indexed' | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| end | ||
|
|
||
| it 'generates valid json' do | ||
| expect(message.as_json).to include_json(expected_json) | ||
| end | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im unsure if element aviti actually has controls? I didnt want to cause regression as the previous flowcell_io template does but I cant see a way to add phix on batch creation for aviti.