-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4367 from sanger/y24-313-scrna-pooling-v2
Y24-313 scRNA pooling calculation
- Loading branch information
Showing
17 changed files
with
221 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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,12 @@ | ||
# frozen_string_literal: true | ||
|
||
module Api | ||
module V2 | ||
# Provides a JSON API controller for RequestMetadata | ||
# See: http://jsonapi-resources.com/ for JSONAPI::Resource documentation | ||
class RequestMetadataController < JSONAPI::ResourceController | ||
# By default JSONAPI::ResourceController provides most the standard | ||
# behaviour, and in many cases this file may be left empty. | ||
end | ||
end | ||
end |
This file contains 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,9 @@ | ||
# frozen_string_literal: true | ||
|
||
# A class for customer requests that need the extra metadata fields used for PBMC pooling calculations | ||
class PbmcPoolingCustomerRequest < CustomerRequest | ||
has_metadata as: Request do | ||
custom_attribute(:number_of_samples_per_pool, integer: true, required: false, default: nil) | ||
custom_attribute(:cells_per_chip_well, integer: true, required: false, default: nil) | ||
end | ||
end |
This file contains 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,48 @@ | ||
# frozen_string_literal: true | ||
|
||
module Api | ||
module V2 | ||
# @todo This documentation does not yet include a detailed description of what this resource represents. | ||
# @todo This documentation does not yet include detailed descriptions for relationships, attributes and filters. | ||
# @todo This documentation does not yet include any example usage of the API via cURL or similar. | ||
# | ||
# @note Access this resource via the `/api/v2/requests_metadata/` endpoint. | ||
# | ||
# Provides a JSON:API representation of {Request::Metadata}. | ||
# | ||
# For more information about JSON:API see the [JSON:API Specifications](https://jsonapi.org/format/) | ||
# or look at the [JSONAPI::Resources](http://jsonapi-resources.com/) package for Sequencescape's implementation | ||
# of the JSON:API standard. | ||
class RequestMetadataResource < BaseResource | ||
# NB. request_metadata has been added to config/initializers/inflections.rb to make this class name | ||
# work otherwise it expects RequestMetadatumResource | ||
|
||
# Sets add_model_hint true by default, this allows updates from Limber, otherwise get a | ||
# 500 error as it looks for resource Api::V2::MetadatumResource | ||
model_name 'Request::Metadata' | ||
|
||
# Associations: | ||
has_one :request | ||
|
||
### | ||
# Attributes | ||
### | ||
|
||
# @!attribute [r] number_of_samples_per_pool | ||
# @return [Int] the number_of_samples_per_pool. | ||
attribute :number_of_samples_per_pool, readonly: true | ||
|
||
# @!attribute [r] cells_per_chip_well | ||
# @return [Int] the cells_per_chip_well. | ||
attribute :cells_per_chip_well, readonly: true | ||
|
||
# Filters | ||
|
||
# Custom methods | ||
# These shouldn't be used for business logic, and a more about | ||
# I/O and isolating implementation details. | ||
|
||
# Class method overrides | ||
end | ||
end | ||
end |
This file contains 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 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 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 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 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 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 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
7 changes: 7 additions & 0 deletions
7
db/migrate/20240917133813_addsc_rna_fields_to_request_metadata.rb
This file contains 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,7 @@ | ||
# frozen_string_literal: true | ||
class AddscRnaFieldsToRequestMetadata < ActiveRecord::Migration[6.1] | ||
def change | ||
add_column :request_metadata, :number_of_samples_per_pool, :integer, null: true | ||
add_column :request_metadata, :cells_per_chip_well, :integer, null: true | ||
end | ||
end |
This file contains 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 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 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 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 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 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,81 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
describe UatActions::TubeSubmission do | ||
context 'with valid options' do | ||
let(:tube) { create :sample_tube, purpose: create(:sample_tube_purpose) } | ||
let(:tube_barcode) { tube.barcodes.last.barcode } | ||
let(:submission_template) { create :pbmc_pooling_submission_template } | ||
let(:parameters) { { submission_template_name: submission_template.name, tube_barcodes: tube_barcode } } | ||
let(:uat_action) { described_class.new(parameters) } | ||
let(:report) do | ||
# A report is a hash of key value pairs which get returned to the user. | ||
# It should include information such as barcodes and identifiers | ||
{ 'tube_barcodes' => [tube_barcode] } | ||
end | ||
|
||
it 'can be performed' do | ||
expect(uat_action.perform).to be true | ||
expect(uat_action.report['tube_barcodes']).to eq report['tube_barcodes'] | ||
expect(uat_action.report['submission_id']).to be_a Integer | ||
end | ||
|
||
context 'with optional library type supplied' do | ||
let(:parameters) do | ||
{ | ||
submission_template_name: submission_template.name, | ||
tube_barcodes: tube_barcode, | ||
library_type_name: 'Standard' | ||
} | ||
end | ||
|
||
it 'can be performed' do | ||
expect(uat_action.perform).to be true | ||
expect(uat_action.report['tube_barcodes']).to eq report['tube_barcodes'] | ||
expect(uat_action.report['submission_id']).to be_a Integer | ||
expect(uat_action.report['library_type']).to eq 'Standard' | ||
end | ||
end | ||
|
||
context 'with optional number of samples per pool supplied' do | ||
let(:num_samples) { 15 } | ||
let(:parameters) do | ||
{ | ||
submission_template_name: submission_template.name, | ||
tube_barcodes: tube_barcode, | ||
number_of_samples_per_pool: num_samples | ||
} | ||
end | ||
|
||
it 'can be performed' do | ||
expect(uat_action.perform).to be true | ||
expect(uat_action.report['tube_barcodes']).to eq report['tube_barcodes'] | ||
expect(uat_action.report['submission_id']).to be_a Integer | ||
expect(uat_action.report['number_of_samples_per_pool']).to eq num_samples | ||
end | ||
end | ||
|
||
context 'with optional cells per chip well supplied' do | ||
let(:num_cells) { 20_000 } | ||
let(:parameters) do | ||
{ | ||
submission_template_name: submission_template.name, | ||
tube_barcodes: tube_barcode, | ||
cells_per_chip_well: num_cells | ||
} | ||
end | ||
|
||
it 'can be performed' do | ||
expect(uat_action.perform).to be true | ||
expect(uat_action.report['tube_barcodes']).to eq report['tube_barcodes'] | ||
expect(uat_action.report['submission_id']).to be_a Integer | ||
expect(uat_action.report['cells_per_chip_well']).to eq num_cells | ||
end | ||
end | ||
end | ||
|
||
it 'returns a default' do | ||
expect(described_class.default).to be_a described_class | ||
end | ||
end |