Class: Api::V2::PlateResource

Inherits:
BaseResource
  • Object
show all
Includes:
SharedBehaviour::Labware
Defined in:
app/resources/api/v2/plate_resource.rb

Overview

Note:

This resource cannot be modified after creation: its endpoint will not accept PATCH requests.

Note:

Access this resource via the /api/v2/plates/ endpoint.

Provides a JSON:API representation of Plate which is plastic labware containing Wells. The plate has a purpose like all labware and this denotes which pipeline it is being used in and what type of samples it holds / how it will be processed. Plates are not typically created directly using this resource, although they can be. Rather they are created via resources such as PlateCreationResource.

}

For more information about JSON:API see the JSON:API Specifications or look at the JSONAPI::Resources package for Sequencescape's implementation of the JSON:API standard.

Examples:

POST request

POST /api/v2/plates/
{
  "data": {
      "type": "plates",
      "attributes": {
          "size": 96
      },
      "relationships": {
          "purpose": {
              "data": { "type": "purposes", "id": 1 }
          },
          "wells": {
              "data": [{ "type": "wells", "id": 4481 }]
          },
          "poly_metadata": {
           "data": [{ "type": "poly_metadata", "id": 10 }]
         }
    }
  }

GET request for all Plate resources

GET /api/v2/plates/

GET request for a Plate with ID 123

GET /api/v2/plates/123/

PATCH request to update metadata for a plate

PATCH /api/v2/plates/123/
{
  "data": {
    "type": "plates",
    "id": "123",
    "relationships": {
      "poly_metadata": {
        "data": [{ "type": "poly_metadata", "id": "456" }]
      }
    }
  }
}

Instance Attribute Summary collapse

Method Summary

Methods included from SharedBehaviour::Labware

#labware_barcode

Methods inherited from BaseResource

apply_includes, creatable_fields, default_includes, #fetchable_fields, inclusions, resolve_relationship_names_to_relations, updatable_fields

Instance Attribute Details

#number_of_columnsInt (readonly)

Returns The number of columns on the plate. This is determined by the AssetShape assigned to the plate by its purpose.

Returns:

  • (Int)

    The number of columns on the plate. This is determined by the AssetShape assigned to the plate by its purpose.



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'app/resources/api/v2/plate_resource.rb', line 87

 do
  # NOTE: The following attribute is not required for Microarray Genotyping.
  # I think this might be broken and suggests that there should be separate classes for project: one for
  # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping
  # that doesn't.
  include ProjectManager::Associations
  include BudgetDivision::Associations

  custom_attribute(:project_cost_code, required: true)
  custom_attribute(:funding_comments)
  custom_attribute(:collaborators)
  custom_attribute(:external_funding_source)
  custom_attribute(:sequencing_budget_cost_centre)
  custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS)
  custom_attribute(:gt_committee_tracking_id)

  before_validation do |record|
    record.project_cost_code = nil if record.project_cost_code.blank?
    record.project_funding_model = nil if record.project_funding_model.blank?
  end
end

#number_of_rowsInt (readonly)

Returns The number of rows on the plate. This is determined by the AssetShape assigned to the plate by its purpose.

Returns:

  • (Int)

    The number of rows on the plate. This is determined by the AssetShape assigned to the plate by its purpose.



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'app/resources/api/v2/plate_resource.rb', line 82

 do
  # NOTE: The following attribute is not required for Microarray Genotyping.
  # I think this might be broken and suggests that there should be separate classes for project: one for
  # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping
  # that doesn't.
  include ProjectManager::Associations
  include BudgetDivision::Associations

  custom_attribute(:project_cost_code, required: true)
  custom_attribute(:funding_comments)
  custom_attribute(:collaborators)
  custom_attribute(:external_funding_source)
  custom_attribute(:sequencing_budget_cost_centre)
  custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS)
  custom_attribute(:gt_committee_tracking_id)

  before_validation do |record|
    record.project_cost_code = nil if record.project_cost_code.blank?
    record.project_funding_model = nil if record.project_funding_model.blank?
  end
end

#poly_metadataPolyMetadatumResource (readonly)

Note:

This is a one-to-many relationship, where a Labware can have multiple pieces of metadata.

Note:

The poly_metadata must already exist in the database before it can be associated with a Labware.

Returns The associated metadata for the Labware.

Returns:

See Also:



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'app/resources/api/v2/plate_resource.rb', line 73

 do
  # NOTE: The following attribute is not required for Microarray Genotyping.
  # I think this might be broken and suggests that there should be separate classes for project: one for
  # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping
  # that doesn't.
  include ProjectManager::Associations
  include BudgetDivision::Associations

  custom_attribute(:project_cost_code, required: true)
  custom_attribute(:funding_comments)
  custom_attribute(:collaborators)
  custom_attribute(:external_funding_source)
  custom_attribute(:sequencing_budget_cost_centre)
  custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS)
  custom_attribute(:gt_committee_tracking_id)

  before_validation do |record|
    record.project_cost_code = nil if record.project_cost_code.blank?
    record.project_funding_model = nil if record.project_funding_model.blank?
  end
end

#pooling_metadataHash (readonly)

Returns A hash containing submission UUIDs and corresponding pooling metadata.

Examples:

Hash representation

{
  "12345678-1234-1234-1234-1234567890ab": {
    "wells": ["A1", "A2", "A3"],
    "pool_complete": true,
    "insert_size": { "from": 1, "to": 1 },
    "library_type": { "name": "Bioscan" },
    "pcr_cycles": 0,
    "request_type": "limber_bioscan_library_prep",
    "for_multiplexing": false
  },
  "87654321-4321-4321-4321-ba0987654321": {
    "wells": ["B1", "B2", "B3"],
    "pool_complete": true,
    "insert_size": { "from": 1, "to": 1 },
    "library_type": { "name": "Bioscan" },
    "pcr_cycles": 0,
    "request_type": "limber_bioscan_library_prep",
    "for_multiplexing": false
  }
}

Returns:

  • (Hash)

    A hash containing submission UUIDs and corresponding pooling metadata.



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'app/resources/api/v2/plate_resource.rb', line 118

 do
  # NOTE: The following attribute is not required for Microarray Genotyping.
  # I think this might be broken and suggests that there should be separate classes for project: one for
  # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping
  # that doesn't.
  include ProjectManager::Associations
  include BudgetDivision::Associations

  custom_attribute(:project_cost_code, required: true)
  custom_attribute(:funding_comments)
  custom_attribute(:collaborators)
  custom_attribute(:external_funding_source)
  custom_attribute(:sequencing_budget_cost_centre)
  custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS)
  custom_attribute(:gt_committee_tracking_id)

  before_validation do |record|
    record.project_cost_code = nil if record.project_cost_code.blank?
    record.project_funding_model = nil if record.project_funding_model.blank?
  end
end

#sizeInt

Note:

This can only be set once during creation. If it is not set, it will default to 96.

Returns The total number of wells on the plate.

Returns:

  • (Int)

    The total number of wells on the plate.



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'app/resources/api/v2/plate_resource.rb', line 93

 do
  # NOTE: The following attribute is not required for Microarray Genotyping.
  # I think this might be broken and suggests that there should be separate classes for project: one for
  # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping
  # that doesn't.
  include ProjectManager::Associations
  include BudgetDivision::Associations

  custom_attribute(:project_cost_code, required: true)
  custom_attribute(:funding_comments)
  custom_attribute(:collaborators)
  custom_attribute(:external_funding_source)
  custom_attribute(:sequencing_budget_cost_centre)
  custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS)
  custom_attribute(:gt_committee_tracking_id)

  before_validation do |record|
    record.project_cost_code = nil if record.project_cost_code.blank?
    record.project_funding_model = nil if record.project_funding_model.blank?
  end
end

#submission_poolsArray<SubmissionPoolResource> (readonly)

Returns An array of submission pools for this plate.

Returns:



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'app/resources/api/v2/plate_resource.rb', line 130

 do
  # NOTE: The following attribute is not required for Microarray Genotyping.
  # I think this might be broken and suggests that there should be separate classes for project: one for
  # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping
  # that doesn't.
  include ProjectManager::Associations
  include BudgetDivision::Associations

  custom_attribute(:project_cost_code, required: true)
  custom_attribute(:funding_comments)
  custom_attribute(:collaborators)
  custom_attribute(:external_funding_source)
  custom_attribute(:sequencing_budget_cost_centre)
  custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS)
  custom_attribute(:gt_committee_tracking_id)

  before_validation do |record|
    record.project_cost_code = nil if record.project_cost_code.blank?
    record.project_funding_model = nil if record.project_funding_model.blank?
  end
end

#transfers_as_destinationArray<TransferResource> (readonly)

Returns An array of transfers with this plate as the destination.

Returns:

  • (Array<TransferResource>)

    An array of transfers with this plate as the destination.



134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'app/resources/api/v2/plate_resource.rb', line 134

 do
  # NOTE: The following attribute is not required for Microarray Genotyping.
  # I think this might be broken and suggests that there should be separate classes for project: one for
  # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping
  # that doesn't.
  include ProjectManager::Associations
  include BudgetDivision::Associations

  custom_attribute(:project_cost_code, required: true)
  custom_attribute(:funding_comments)
  custom_attribute(:collaborators)
  custom_attribute(:external_funding_source)
  custom_attribute(:sequencing_budget_cost_centre)
  custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS)
  custom_attribute(:gt_committee_tracking_id)

  before_validation do |record|
    record.project_cost_code = nil if record.project_cost_code.blank?
    record.project_funding_model = nil if record.project_funding_model.blank?
  end
end

#wellsArray<WellResource>

Note:

This can only be set once during creation.

Returns An array of wells on this plate.

Returns:

  • (Array<WellResource>)

    An array of wells on this plate.



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'app/resources/api/v2/plate_resource.rb', line 139

 do
  # NOTE: The following attribute is not required for Microarray Genotyping.
  # I think this might be broken and suggests that there should be separate classes for project: one for
  # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping
  # that doesn't.
  include ProjectManager::Associations
  include BudgetDivision::Associations

  custom_attribute(:project_cost_code, required: true)
  custom_attribute(:funding_comments)
  custom_attribute(:collaborators)
  custom_attribute(:external_funding_source)
  custom_attribute(:sequencing_budget_cost_centre)
  custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS)
  custom_attribute(:gt_committee_tracking_id)

  before_validation do |record|
    record.project_cost_code = nil if record.project_cost_code.blank?
    record.project_funding_model = nil if record.project_funding_model.blank?
  end
end