Class: Api::V2::RequestMetadataResource

Inherits:
BaseResource
  • Object
show all
Defined in:
app/resources/api/v2/request_metadata_resource.rb

Overview

TODO:

Figure out how to send a POST for a request with request metadata association. Currently, it is possible to create a request and request metadata seperately, but they are not associated with each other. How do you create the association, either in one request or after the individual requests?

Note:

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

Provides a JSON:API representation of Metadata::Metadata. which is a class derived from app/models/metadata.rb

The RequestMetadataResource provides metadata information for requests, specifically including details like number_of_pools and cells_per_chip_well, which are critical for the scRNA Core pipeline. It is associated with a request.

For more details on JSON:API, see the JSON:API Specifications or check out the JSONAPI::Resources package for Sequencescape's implementation.

Examples:

GET request to retrieve all request metadata

GET /api/v2/request_metadata/

POST request to create new request metadata

POST /api/v2/request_metadata/
{
  "data": {
      "id": 1,
    "type": "request_metadata",
    "attributes": {
      // "number_of_pools": 5,
      // "cells_per_chip_well": 200
    },
    "relationships": {
      "request": {
        "data": {
          "type": "requests",
          "id": 1265
        }
      }
    }
  }
}

PATCH request to update existing request metadata

PATCH /api/v2/request_metadata/1
{
  "data": {
    "id": "1",
    "type": "request_metadata",
    "attributes": {
    }
  }
}

Instance Attribute Summary collapse

Method Summary

Methods inherited from BaseResource

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

Instance Attribute Details

#allowance_bandString (readonly)

Returns the allowance_band requested in the Submission. As used in the scRNA Core pipeline, it is specified at the Study-Project level: it will have the same value for all Requests that share the same Study and Project.

Returns:

  • (String)

    the allowance_band requested in the Submission. As used in the scRNA Core pipeline, it is specified at the Study-Project level: it will have the same value for all Requests that share the same Study and Project.



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

 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

#cells_per_chip_wellInt

Returns the cells_per_chip_well requested in the Submission. As used in the scRNA Core pipeline, it is specified at the Study-Project level: it will have the same value for all Requests that share the same Study and Project. It is used for volume calculations for pooling.

Returns:

  • (Int)

    the cells_per_chip_well requested in the Submission. As used in the scRNA Core pipeline, it is specified at the Study-Project level: it will have the same value for all Requests that share the same Study and Project. It is used for volume calculations for pooling.



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

 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_poolsInt

Returns the number_of_pools requested in the Submission. As used in the scRNA Core pipeline, it is specified at the Study-Project level: it will have the same value for all Requests that share the same Study and Project. It is used in the pooling algorithm.

Returns:

  • (Int)

    the number_of_pools requested in the Submission. As used in the scRNA Core pipeline, it is specified at the Study-Project level: it will have the same value for all Requests that share the same Study and Project. It is used in the pooling algorithm.



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'app/resources/api/v2/request_metadata_resource.rb', line 76

 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