Skip to content

Commit

Permalink
Merge pull request #1449 from sanger/develop
Browse files Browse the repository at this point in the history
Merging develop to master - v7.13.1
  • Loading branch information
seenanair authored Oct 7, 2024
2 parents 3cecf15 + 90c357b commit 3837956
Show file tree
Hide file tree
Showing 51 changed files with 533 additions and 77 deletions.
2 changes: 1 addition & 1 deletion .release-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.13.0
7.13.1
12 changes: 6 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ GEM
globalid (1.2.1)
activesupport (>= 6.1)
hashdiff (1.1.0)
i18n (1.14.5)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
io-console (0.7.2)
irb (1.14.0)
Expand Down Expand Up @@ -187,7 +187,7 @@ GEM
psych (5.1.2)
stringio
public_suffix (6.0.0)
puma (6.4.2)
puma (6.4.3)
nio4r (~> 2.0)
racc (1.8.1)
rack (2.2.9)
Expand Down Expand Up @@ -279,12 +279,12 @@ GEM
parser (>= 3.3.1.0)
rubocop-factory_bot (2.26.1)
rubocop (~> 1.61)
rubocop-rails (2.26.1)
rubocop-rails (2.26.2)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.52.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rspec (3.0.4)
rubocop-rspec (3.0.5)
rubocop (~> 1.61)
ruby-graphviz (1.2.5)
rexml
Expand Down Expand Up @@ -315,13 +315,13 @@ GEM
timeout (0.4.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
unicode-display_width (2.6.0)
useragent (0.16.10)
webmock (3.23.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
webrick (1.8.1)
webrick (1.8.2)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
Expand Down
28 changes: 18 additions & 10 deletions app/exchanges/volume_tracking/message_builder.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
# frozen_string_literal: true

module VolumeTracking
# Message::Message
# Creates a message in the correct structure for the warehouse
# @example
# {
# "limsId"=>"Traction",
# "messageCreateDateUtc"=>Mon, 15 Jul 2024 15:16:54.877858000 UTC +00:00,
# "messageUuid"=>"0a62ee15-bbf6-46f0-ba95-01d42622d076",
# "recordedAt"=>Mon, 15 Jul 2024 15:16:54.867713000 UTC +00:00,
# "volume"=>1.5,
# "concentration"=>10.0,
# "insertSize"=>100,
# "aliquotType"=>"primary",
# "aliquotUuid"=>"",
# "sourceType"=>"library",
# "sourceBarcode"=>"TRAC-2-35805",
# "sampleName"=>"Sample1",
# "usedByBarcode"=>"TRAC-2-35806",
# "usedByType"=>"pool"
# }
#
class MessageBuilder < Message::Message
# Produces the message in the correct format
# Example:
# {"limsId"=>"Traction",
# "messageCreateDateUtc"=>Mon, 15 Jul 2024 15:16:54.877858000 UTC +00:00,
# "messageUuid"=>"0a62ee15-bbf6-46f0-ba95-01d42622d076",
# "recordedAt"=>Mon, 15 Jul 2024 15:16:54.867713000 UTC +00:00,
# "volume"=>1.5, "concentration"=>10.0, "insertSize"=>100, "aliquotType"=>"primary",
# "aliquotUuid"=>"", "sourceType"=>"library", "sourceBarcode"=>"TRAC-2-35805",
# "sampleName"=>"Sample1", "usedByBarcode"=>"TRAC-2-35806", "usedByType"=>"pool"}}
def publish_data
@publish_data ||= generate_publish_data
end
Expand Down
5 changes: 3 additions & 2 deletions app/messages/emq/publishing_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ def initialize
@bunny_config = PublishingJob.deep_open_struct(Rails.configuration.bunny)
end

##
# Publish a message to the EMQ
# @param [Object] objects the object or objects to publish
# @param [Object] the pipeline configuration to construct
# the message to publish from the given object(s)
# @param [Object] message_config the pipeline configuration to construct the message
# to publish from the given object(s)
# @param [String] schema_key the key of the schema to validate the message against
# Note:-
# The schema_key must exist within the subjects hash of the bunny configuration and
Expand Down
5 changes: 4 additions & 1 deletion app/models/aliquot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ def sample_sheet_behaviour
#
# @return [Boolean] Returns true if the aliquot is tagged, false otherwise.
def tagged?
tag.present?
# This feels like a bit of a hack but I wasn't exactly sure where the best place to
# it. I tried to follow the sample sheet behaviour but got lost.
# it looks like the only place this is used is in the sample sheet generation
tag.present? && tag_set&.sample_sheet_behaviour != 'hidden'
end

# Generic method used by pacbio sample sheet generation to
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/dual_sourced_pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def source_identifier
end.join(',')
formatted_tubes = source_tubes.pluck(:barcode).join(',')
# Combines the two outputs checking neither are empty
[formatted_wells, formatted_tubes].filter(&:present?).join(',')
[formatted_wells, formatted_tubes].compact_blank.join(',')
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/multi_sourced_pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def source_identifier
formatted_tubes = source_tubes.pluck(:barcode).join(',')
formatted_libraries = libraries.collect(&:tube).pluck(:barcode).join(',')
# Combines the two outputs checking neither are empty
[formatted_wells, formatted_tubes, formatted_libraries].filter(&:present?).join(',')
[formatted_wells, formatted_tubes, formatted_libraries].compact_blank.join(',')
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/nested_validation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def add_errors(nested, record, attribute, index)
#
# Records of this class will call valid? on any associations provided
# as attr_names. Errors on these records will be propagated out
# @param *attr_names [Symbol] One or more associations to validate
# @param attr_names [Symbol] One or more associations to validate
#
# @return [NestedValidator]
def validates_nested(*attr_names)
Expand Down
10 changes: 6 additions & 4 deletions app/models/pacbio/run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ class Run < ApplicationRecord
# Sequel II and Sequel I are now deprecated
enum :system_name, { 'Sequel II' => 0, 'Sequel I' => 1, 'Sequel IIe' => 2, 'Revio' => 3 }

# before_create :generate_comment, unless: -> { wells.nil? }

# We want to generate comments before the run was created
# but tube barcodes aren't generated until the run is created.

Expand All @@ -33,6 +31,7 @@ class Run < ApplicationRecord

validates :system_name, presence: true

# Uses the configuration provided in `config/pacbio_instrument_types.yml`
validates_with InstrumentTypeValidator,
instrument_types: Rails.configuration.pacbio_instrument_types,
if: lambda {
Expand All @@ -49,8 +48,11 @@ class Run < ApplicationRecord
# If plate/well data is required via the run, use ?include=plates.wells
attr_reader :plates_attributes

# if comments are nil this blows up so add try.

# combines the library concentration or on plate loading concentration
# with the tube barcode to generate a comment
# for each well in the run
# @example
# TRAC-2-10850 304pM TRAC-2-10851 273pM TRAC-2-10852 301pM TRAC-2-10853 315pM
def generate_comment
comment = wells.collect do |well|
concentration = well.library_concentration || well.on_plate_loading_concentration
Expand Down
1 change: 1 addition & 0 deletions app/models/pacbio/well.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Well < ApplicationRecord
# See https://api.rubyonrails.org/classes/ActiveRecord/Store.html
# We now get the accessors from configuration
store :smrt_link_options

# using store_accessor allows you to lazy load the accessors
store_accessor :smrt_link_options, Rails.configuration.pacbio_smrt_link_versions.options.keys

Expand Down
9 changes: 4 additions & 5 deletions app/models/qc_results_upload_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class QcResultsUploadFactory

delegate :csv_data, :used_by, to: :qc_results_upload

# @param [csv] csv rows
# creates data from the initial csv
def rows
return unless qc_results_upload
Expand All @@ -39,7 +38,7 @@ def create_entities!
true
end

# @param [Object] CSV row e.g. { col_header_1: row_1_col_1 }
# @param row_object [Object] csv row e.g. { col_header_1: row_1_col_1 }
def create_data(row_object)
# 1. Create QC Decisions
qc_decisions = create_qc_decisions(row_object)
Expand All @@ -66,8 +65,8 @@ def create_qc_decisions(row_object)
{ lr_qc_decision:, tol_qc_decision: }
end

# @returns [List] of created QcResults
# @param [Object] CSV row e.g. { col_header_1: row_1_col_1 }
# @return [List] of created QcResults
# @param row_object [Object] csv row e.g. { col_header_1: row_1_col_1 }
def create_qc_results(row_object)
# Get relevant QcAssayTypes, for used_by
qc_assay_types = QcAssayType.where(used_by:)
Expand Down Expand Up @@ -128,7 +127,7 @@ def create_qc_decision_result!(qc_result, qc_decision)
QcDecisionResult.create!(qc_result:, qc_decision:)
end

# @returns [List] of all QcResultMessages - a different one is needed for each decision point
# @return [List] of all QcResultMessages - a different one is needed for each decision point
def messages
@messages ||= []
end
Expand Down
2 changes: 1 addition & 1 deletion app/resources/v1/ont/plate_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Ont
#
# @note Access this resource via the `/v1/ont/plates/` endpoint.
#
# Provides a JSON:API representation of {Ont::Plate}.
# Provides a JSON:API representation of {Plate}.
#
# 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
Expand Down
2 changes: 1 addition & 1 deletion app/resources/v1/ont/tag_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Ont
#
# @note Access this resource via the `/v1/ont/tags/` endpoint.
#
# Provides a JSON:API representation of {Ont::Tag}. This is a resource to return all of the ONT
# Provides a JSON:API representation of {Tag}. This is a resource to return all of the ONT
# tags.
#
# For more information about JSON:API see the [JSON:API Specifications](https://jsonapi.org/format/)
Expand Down
2 changes: 1 addition & 1 deletion app/resources/v1/pacbio/smrt_link_version_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Pacbio
#
# @note Access this resource via the `/v1/pacbio/smrt_link_versions/` endpoint.
#
# Provides a JSON:API representation of {Pacbio::Pacbio::SmrtLinkVersion}. Returns the SMRT Link
# Provides a JSON:API representation of {Pacbio::SmrtLinkVersion}. Returns the SMRT Link
# Versions.
#
# For more information about JSON:API see the [JSON:API Specifications](https://jsonapi.org/format/)
Expand Down
2 changes: 1 addition & 1 deletion app/resources/v1/printer_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module V1
#
# @note Access this resource via the `/v1/printer_types` endpoint.
#
# Provides a JSON:API representation of {PrinterType} and exposes valid library type options
# Provides a JSON:API representation of {Printer} and exposes valid library type options
# for use by the UI.
#
# For more information about JSON:API see the [JSON:API Specifications](https://jsonapi.org/format/)
Expand Down
2 changes: 1 addition & 1 deletion app/validators/has_filters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def exclude_marked_for_destruction

private

# @param [ActiveRecord::Base] record
# @param records [ActiveRecord::Base]
# @return [Array]
# filter out records which are marked for destruction
def filtered(records)
Expand Down
14 changes: 8 additions & 6 deletions app/validators/instrument_type_validator.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# frozen_string_literal: true

# Validator for InstrumentType
# Validates the InstrumentType and its associated Plates and Wells
# Validates the presence of required attributes
# Validates the number of Plates and Wells
# Validates the positions of Wells
# Validates the combinations of Wells
##
# Validator for Pacbio InstrumentType:
#
# - Validates the InstrumentType and its associated Plates and Wells
# - Validates the presence of required attributes
# - Validates the number of Plates and Wells
# - Validates the positions of Wells
# - Validates the combinations of Wells
class InstrumentTypeValidator < ActiveModel::Validator
attr_reader :instrument_types, :instrument_type

Expand Down
22 changes: 12 additions & 10 deletions app/validators/smrt_link_options_validator.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
# frozen_string_literal: true

# validate SmrtLinkOptions by version
# This allows more flexible modification of fields by version
# each version will have a set of validations
# on validate it will loop through each of those validations
# build a validator and validate the record for each specified attribute
# the validations are standard ActiveRecord ones with specified options
##
# validate SmrtLinkOptions by version:
#
# - This allows more flexible modification of fields by version
# - each version will have a set of validations
# - on validate it will loop through each of those validations
# - build a validator and validate the record for each specified attribute
# - the validations are standard ActiveRecord ones with specified options
# @example
# smrt_link_option = { key: attribute_1, validations: { required: {},
# numericality: { greater_than_equal_to: 0,
# less_than_or_equal_to: 1}} }
# This will then run each validator against the specified key
# - This will then run each validator against the specified key
# @example
# ActiveModel::Validations::NumericalityValidator.new(attributes: attribute_1,
# greater_than_equal_to: 0, less_than_or_equal_to: 1).validate(record)
# Any errors will be added to the record
# The validator must be a recognised validator as per
# - Any errors will be added to the record
# - The validator must be a recognised validator as per
# https://github.com/rails/rails/tree/main/activemodel/lib/active_model/validations
# Or you need to create your own validator as per
# - Or you need to create your own validator as per
# https://api.rubyonrails.org/classes/ActiveModel/Validator.html
class SmrtLinkOptionsValidator < ActiveModel::Validator
def validate(record)
Expand Down
2 changes: 1 addition & 1 deletion config/pipelines/reception.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ default: &default
last_updated: *timestamp
id_sample_lims:
type: :model
value: id
value: name
uuid_sample_lims:
type: :model
value: external_id
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class DropPacbioRequestLibrariesTable < ActiveRecord::Migration[7.2]
def change
drop_table :pacbio_request_libraries
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class RemoveSequencingKitBoxBarcodeColumnFromPacbioRuns < ActiveRecord::Migration[7.2]
def change
remove_column :pacbio_runs, :sequencing_kit_box_barcode
end
end
14 changes: 1 addition & 13 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.2].define(version: 2024_09_09_163449) do
ActiveRecord::Schema[7.2].define(version: 2024_09_27_074531) do
create_table "aliquots", charset: "utf8mb3", force: :cascade do |t|
t.float "volume"
t.float "concentration"
Expand Down Expand Up @@ -216,17 +216,6 @@
t.index ["tube_id"], name: "index_pacbio_pools_on_tube_id"
end

create_table "pacbio_request_libraries", charset: "utf8mb3", force: :cascade do |t|
t.bigint "pacbio_request_id"
t.bigint "pacbio_library_id"
t.bigint "tag_id"
t.index ["pacbio_library_id"], name: "index_pacbio_request_libraries_on_pacbio_library_id"
t.index ["pacbio_request_id", "pacbio_library_id"], name: "index_rl_request_library", unique: true
t.index ["pacbio_request_id"], name: "index_pacbio_request_libraries_on_pacbio_request_id"
t.index ["tag_id", "pacbio_library_id"], name: "index_rl_tag_library", unique: true
t.index ["tag_id"], name: "index_pacbio_request_libraries_on_tag_id"
end

create_table "pacbio_requests", charset: "utf8mb3", force: :cascade do |t|
t.string "library_type"
t.string "estimate_of_gb_required"
Expand All @@ -240,7 +229,6 @@

create_table "pacbio_runs", charset: "utf8mb3", force: :cascade do |t|
t.string "name"
t.string "sequencing_kit_box_barcode"
t.string "dna_control_complex_box_barcode"
t.text "comments"
t.string "uuid"
Expand Down
Loading

0 comments on commit 3837956

Please sign in to comment.