-
Notifications
You must be signed in to change notification settings - Fork 33
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
DPL-823 [Part 1 - download] Import PBMC pool plates into Sequencescape #4017
Changes from 11 commits
cca9a73
c2ed6d7
38119c3
46a0d8c
00ae902
eed57ed
a4be4d2
1dc48a0
ce77810
6563cd1
5361d1e
00d2e26
23628e1
f4afdf7
3f029c1
b2dcbf0
a3ab53f
b56a3af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,17 @@ | |
def perform | ||
ActiveRecord::Base.transaction do | ||
# Ensure the order of the wells are maintained | ||
# Why does the order of the wells matter? Maybe can't use a hash if it does. | ||
# Keep key of hash as map_id and query Maps in the generate_wells_job method? | ||
maps = Map.find(map_ids).index_by(&:id) | ||
well_data = map_ids_to_sample_ids.map { |map_id, sample_id| [maps[map_id], sample_id] } | ||
well_data = {} | ||
map_ids_to_sample_ids.each do |map_id, sample_id| | ||
if well_data[maps[map_id]] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GenerateWellsJob#perform calls 'well_data[maps[map_id]]' 2 times |
||
well_data[maps[map_id]] << sample_id | ||
else | ||
well_data[maps[map_id]] = [sample_id] | ||
end | ||
end | ||
|
||
sample_manifest.core_behaviour.generate_wells_job(well_data, plate) | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
# for the potential samples. It also generates a {SampleManifestExcel} | ||
# spreadsheet which gets sent to the customer. | ||
# | ||
# The labware that gets generate is determined by the {#asset_type} which | ||
# The labware that gets generated is determined by the {#asset_type} which | ||
# switches out the {#core_behaviour} module {SampleManifest::CoreBehaviour}. | ||
# This is concerned with generating {Labware} and {Receptacle receptacles}, | ||
# generating any event specific to the asset type, and setting manifest specific | ||
|
@@ -49,6 +49,7 @@ def self.included(base) | |
has_uploaded_document :generated, differentiator: 'generated' | ||
|
||
attr_accessor :override, :only_first_label | ||
attr_writer :rows_per_well | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SampleManifest#rows_per_well is a writable attribute |
||
|
||
class_attribute :spreadsheet_offset | ||
class_attribute :spreadsheet_header_row | ||
|
@@ -128,6 +129,13 @@ def default_filename | |
"#{study_id}stdy_manifest_#{id}_#{created_at.to_formatted_s(:dmy)}" | ||
end | ||
|
||
# Use a default value of 1 for rows_per_well if not set | ||
def rows_per_well | ||
1 | ||
# TODO: replace above line with below line when we want to turn the 'rows_per_well' feature on | ||
KatyTaylor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# @rows_per_well || 1 | ||
end | ||
|
||
scope :pending_manifests, | ||
-> { | ||
order(id: :desc).includes(:uploaded_document).references(:uploaded_document).where(documents: { id: nil }) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ def generate_wells(well_data, plates) | |
@details_array = | ||
plates.flat_map do |plate| | ||
well_data | ||
.slice!(0, plate.size) | ||
.slice!(0, plate.size * @manifest.rows_per_well) | ||
.map { |map, sample_id| { barcode: plate.human_barcode, position: map.description, sample_id: sample_id } } | ||
end | ||
end | ||
|
@@ -88,12 +88,15 @@ def labware | |
alias printables labware | ||
|
||
# Called by {SampleManifest::GenerateWellsJob} and builds the wells | ||
# wells_for_plate: Hash, Map to list of SangerSampleIds | ||
def generate_wells_job(wells_for_plate, plate) | ||
wells_for_plate.map do |map, sanger_sample_id| | ||
wells_for_plate.map do |map, sanger_sample_ids| | ||
plate | ||
.wells | ||
.create!(map: map) do |well| | ||
SampleManifestAsset.create(sanger_sample_id: sanger_sample_id, asset: well, sample_manifest: @manifest) | ||
sanger_sample_ids.each do |sanger_sample_id| | ||
SampleManifestAsset.create(sanger_sample_id: sanger_sample_id, asset: well, sample_manifest: @manifest) | ||
end | ||
end | ||
end | ||
RequestFactory.create_assets_requests(plate.wells, study) | ||
|
@@ -107,7 +110,7 @@ def generate_wells_job(wells_for_plate, plate) | |
# truncate the data. | ||
def generate_wells_for_plates(well_data, plates) | ||
cloned_well_data = well_data.dup | ||
plates.each { |plate| yield(cloned_well_data.slice!(0, plate.size), plate) } | ||
plates.each { |plate| yield(cloned_well_data.slice!(0, plate.size * @manifest.rows_per_well), plate) } | ||
end | ||
|
||
def labware_from_barcodes | ||
|
@@ -126,13 +129,15 @@ def generate_plates(purpose) # rubocop:todo Metrics/AbcSize | |
plates = Array.new(count) { purpose.create!(:without_wells) }.sort_by(&:human_barcode) | ||
|
||
plates.each do |plate| | ||
sanger_sample_ids = generate_sanger_ids(plate.size) | ||
sanger_sample_ids = generate_sanger_ids(plate.size * @manifest.rows_per_well) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SampleManifest::PlateBehaviour::Base#generate_plates calls '@manifest.rows_per_well' 2 times |
||
|
||
plate.maps.in_column_major_order.each do |well_map| | ||
sanger_sample_id = sanger_sample_ids.shift | ||
generated_sanger_sample_id = SangerSampleId.generate_sanger_sample_id!(study_abbreviation, sanger_sample_id) | ||
@manifest.rows_per_well.times do | ||
sanger_sample_id = sanger_sample_ids.shift | ||
generated_sanger_sample_id = SangerSampleId.generate_sanger_sample_id!(study_abbreviation, sanger_sample_id) | ||
|
||
well_data << [well_map, generated_sanger_sample_id] | ||
well_data << [well_map, generated_sanger_sample_id] | ||
end | ||
end | ||
end | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
# scRNA Core pipeline purposes | ||
# Most are defined in the Limber config, but the below also need to be defined in Sequencescape. | ||
# They are in a separate file so it can be 'feature flagged off' until needed. | ||
--- | ||
# The 'LRC PBMC Pools' purpose is controlled by Limber. However, it has been | ||
# added here to create submission and request type records for scRNA Core cDNA | ||
# Prep stage. | ||
--- | ||
LRC PBMC Pools: | ||
stock_plate: false | ||
cherrypickable_target: false | ||
# The 'LRC PBMC Pools Input' purpose is included here so that it's available for | ||
# sample manifests. | ||
LRC PBMC Pools Input: | ||
stock_plate: true | ||
cherrypickable_target: false |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# frozen_string_literal: true | ||
class AddRowsPerWellToSampleManifests < ActiveRecord::Migration[6.0] | ||
def change | ||
add_column :sample_manifests, :rows_per_well, :integer | ||
end | ||
end |
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.
GenerateWellsJob#perform calls 'maps[map_id]' 3 times