-
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 #4010 from sanger/develop
Develop into master
- Loading branch information
Showing
37 changed files
with
1,352 additions
and
17 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 |
---|---|---|
@@ -1 +1 @@ | ||
14.30.0 | ||
14.31.0 |
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,12 @@ | ||
# frozen_string_literal: true | ||
|
||
module Api | ||
module V2 | ||
# Provides a JSON API controller for receptacle | ||
# See: http://jsonapi-resources.com/ for JSONAPI::Resource documentation | ||
class PlatePurposesController < 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,12 @@ | ||
# frozen_string_literal: true | ||
|
||
module Api | ||
module V2 | ||
# Provides a JSON API controller for PolyMetadatum | ||
# See: http://jsonapi-resources.com/ for JSONAPI::Resource documentation | ||
class PolyMetadataController < 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
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,37 @@ | ||
# frozen_string_literal: true | ||
|
||
# | ||
# A polymetadatum is a key value pair store. It is set up such that it can be | ||
# associated with multiple different models (ie. a polymorphic relationship). | ||
# | ||
# It can be linked to any model that has the reverse association set up. | ||
# i.e. add this association line to the model: | ||
# has_many :poly_metadata, as: :metadatable, dependent: :destroy | ||
# and this line to the v2 api resource (if api access needed): | ||
# has_many :poly_metadata, as: :metadatable, class_name: 'PolyMetadatum' | ||
# | ||
# See Request model and associated api v2 resource for an example of how to use this. | ||
# | ||
class PolyMetadatum < ApplicationRecord | ||
# Associations | ||
belongs_to :metadatable, polymorphic: true, optional: false | ||
|
||
# Validations | ||
validates :key, presence: true # otherwise nil is a valid key | ||
validates :value, presence: true | ||
|
||
# Currently we allow the same key to be used for different metadatable objects, | ||
# but it has to be unique for each metadatable object and is case insensitive. | ||
# This is to allow the same key to be used for different models, e.g. a request | ||
# and a sample might both have metadata called 'somename', but the same model cannot | ||
# have two metadata called 'somename' and 'SOMENAME'. | ||
# A metadatable has both a type and an id, so the combination key is unique. | ||
# metadatable_type is the class name of the model, e.g. 'Request' | ||
# metadatable_id is the database id of the model instance | ||
validates :key, uniqueness: { scope: %i[metadatable_type metadatable_id], case_sensitive: false } | ||
|
||
# Methods | ||
def to_h | ||
{ key => value } | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# frozen_string_literal: true | ||
|
||
module Api | ||
module V2 | ||
# Provides a JSON API representation of PlatePurpose | ||
# See: http://jsonapi-resources.com/ for JSONAPI::Resource documentation | ||
class PlatePurposeResource < BaseResource | ||
model_name 'PlatePurpose' | ||
|
||
# This resource is similar to PurposeResource but it was created to | ||
# migrate the registration of plate purposes done by the Limber rake | ||
# task config:generate from API version 1 to API version 2. | ||
|
||
# The following attributes are sent by Limber for a new plate purpose. | ||
|
||
# @!attribute name | ||
# @return [String] the name of the plate purpose | ||
attribute :name | ||
|
||
# @!attribute stock_plate | ||
# @return [Boolean] whether the plates of this purpose are stock plates | ||
attribute :stock_plate | ||
|
||
# @!attribute cherrypickable_target | ||
# @return [Boolean] whether the plates of this purpose are cherrypickable | ||
attribute :cherrypickable_target | ||
|
||
# @!attribute input_plate | ||
# @return [Boolean] whether the plates of this purpose are input plates | ||
attribute :input_plate | ||
|
||
# @!attribute size | ||
# @return [Integer] the size of the plates of this purpose | ||
attribute :size | ||
|
||
# @!attribute asset_shape | ||
# @return [String] the name of the shape of the plates of this purpose | ||
attribute :asset_shape | ||
|
||
# The following attribute is required by Limber to store purposes. | ||
|
||
# @!attribute [r] uuid | ||
# @return [String] the UUID of the plate purpose | ||
attribute :uuid, readonly: true | ||
|
||
# Sets the asset shape of the plate purpose by name if given. | ||
# 'asset_shape' can be given via the Limber purpose configuration and | ||
# defaults to 'Standard' if not provided. If the name is given and not | ||
# found, an error is raised. Note that the name is case-sensitive. | ||
# | ||
# @param name [String] the name of the asset shape | ||
# @return [void] | ||
def asset_shape=(name) | ||
@model.asset_shape = (AssetShape.find_by!(name: name) if name.present?) || AssetShape.default | ||
end | ||
|
||
# Returns the name of the asset shape of the plate purpose. | ||
# The asset_shape association is not utilized in Limber. This method | ||
# returns the name of the asset shape associated with the plate purpose. | ||
# | ||
# @return [String] the name of the asset shape | ||
def asset_shape | ||
@model.asset_shape.name | ||
end | ||
|
||
# Returns the input_plate attribute from the type of the plate purpose. | ||
# This method is the counterpart to the model's attribute writer for | ||
# input_plate. It performs the inverse operation, determining the value | ||
# of input_plate attribute based on the model's type. | ||
# | ||
# @return [Boolean] whether the plate purpose is an input plate | ||
def input_plate | ||
@model.type == 'PlatePurpose::Input' | ||
end | ||
|
||
# Prevents updating existing plate purposes. | ||
# | ||
# @param _context [JSONAPI::Resource::Context] not used | ||
# @return [Array<Symbol>] empty array | ||
def updatable_fields(_context) | ||
[] | ||
end | ||
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,32 @@ | ||
# frozen_string_literal: true | ||
|
||
module Api | ||
module V2 | ||
# Provides a JSON API representation of PolyMetadatum | ||
# See: http://jsonapi-resources.com/ for JSONAPI::Resource documentation | ||
class PolyMetadatumResource < BaseResource | ||
# Constants... | ||
|
||
# immutable # uncomment to make the resource immutable | ||
|
||
# model_name / model_hint if required | ||
|
||
# Associations: | ||
has_one :metadatable, polymorphic: true | ||
|
||
# Attributes | ||
attribute :key | ||
attribute :value | ||
attribute :created_at, readonly: true | ||
attribute :updated_at, 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# This file contains the AssetShape and associated Map records to be created in | ||
# deployment environments by RecordLoader. The loading is triggered by the | ||
# "post_deploy" task. The records are checked against the database by their | ||
# names. If the records already exist, they are not created. AssetShape records | ||
# are created in the "asset_shapes" table, and Map records are created in the | ||
# "maps" table. Each section in this file starts with the name of the AssetShape | ||
# record. The "horizontal_ratio" and "vertical_ratio" options are used to define | ||
# the plate's shape. These options represent the simplest form of the ratio | ||
# between the number of columns and rows (i.e. width / height). Specifically, | ||
# "horizontal_ratio" corresponds to the number of columns (numerator), and | ||
# "vertical_ratio" corresponds to the number of rows (denominator). For | ||
# instance, a "Standard" 96-well plate has a horizontal ratio of 3 and a | ||
# vertical ratio of 2 because it has 12 columns (1 to 12) and 8 rows (A to H). | ||
# The "sizes" option defines different plate sizes with that shape, for example, | ||
# 96 and 384. Each size determines the number of Map records to be created for | ||
# that shape and size. The "description_strategy" option defines the nested | ||
# module in the Map model that is used for handling positions, rows, columns, | ||
# and wells in plate geometry. AssetShapeLoader uses PlateMapGeneration to | ||
# create records in the database. Each "Well" on a "Plate" is associated with a | ||
# "Map". | ||
# | ||
# When configuring a "Purpose", both "asset_shape" and "size" need to be | ||
# specified in that configuration in order to use the correct labware. If not | ||
# specified, they will default to Standard and 96 respectively. For example, | ||
# LRC HT 5p Chip: | ||
# :asset_shape: ChromiumChip | ||
# :size: 16 | ||
# | ||
# The information in this file is duplicated in a couple of places in the | ||
# codebase. When the local development environment is "setup" or "reset", a | ||
# database "seed" is executed. This results in using the maps hash in | ||
# PlateMapGeneration. The same hash is used when the RSpec before suite hook | ||
# calls PlateMapGeneration to create records in the local test environment. | ||
# Plate sizes and number of rows and columns are also defined separately in | ||
# a hash in the Map model, which is used by the nested Coordinate module. | ||
--- | ||
Standard: | ||
horizontal_ratio: 3 | ||
vertical_ratio: 2 | ||
description_strategy: Coordinate | ||
sizes: [96, 384] | ||
|
||
Fluidigm96: | ||
horizontal_ratio: 3 | ||
vertical_ratio: 8 | ||
description_strategy: Sequential | ||
sizes: [96] | ||
|
||
Fluidigm192: | ||
horizontal_ratio: 3 | ||
vertical_ratio: 4 | ||
description_strategy: Sequential | ||
sizes: [192] | ||
|
||
StripTubeColumn: | ||
horizontal_ratio: 1, | ||
vertical_ratio: 8, | ||
description_strategy: Sequential | ||
sizes: [8] | ||
|
||
ChromiumChip: | ||
horizontal_ratio: 4 | ||
vertical_ratio: 1 | ||
description_strategy: Coordinate | ||
sizes: [16] |
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,14 @@ | ||
# frozen_string_literal: true | ||
# | ||
# Add polymorphic metadata table to flexibly hold key value pairs | ||
class CreatePolyMetadata < ActiveRecord::Migration[6.0] | ||
def change | ||
create_table :poly_metadata do |t| | ||
t.string :key, null: false | ||
t.string :value, null: false | ||
t.references :metadatable, polymorphic: true, null: false | ||
|
||
t.timestamps | ||
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
Oops, something went wrong.