Class: V1::Pacbio::RunResource

Inherits:
JSONAPI::Resource
  • Object
show all
Defined in:
app/resources/v1/pacbio/run_resource.rb

Overview

Provides a JSON:API representation of Pacbio::Run.

Filters:

  • name

  • state

Primary relationships:

Relationship trees:

  • plates.wells.used_aliquots

  • smrt_link_version.smrt_link_option_versions

  • annotations

curl -X POST localhost:3100/v1/pacbio/runs \ -H “Content-Type: application/vnd.api+json” \ -H “Accept: application/vnd.api+json” \ -d ‘{ “data”: { “type”: “runs”, “attributes”: { “dna_control_complex_box_barcode”: “Lxxxxx101717600123191”, “system_name”: “Sequel II”, “pacbio_smrt_link_version_id”: 130, “plates_attributes”: [ { “sequencing_kit_box_barcode”: “DM0001100861800123121”, “plate_number”: 1, “wells_attributes”: [ { “row”: “A”, “column”: “1”, “movie_acquisition_time”: 30, “library_concentration”: 8.35, “pre_extension_time”: “2”, “include_base_kinetics”: “True”, “polymerase_kit”: “ABC123”, “used_aliquots_attributes”: [ { “source_id”: 408, “source_type”: “Pacbio::Pool”, “volume”: 10, “concentration”: 20, “aliquot_type”: “derived”, “template_prep_kit_box_barcode”: “033000000000000000000” } ], “annotations_attributes”: null } ] } ] } }’

curl -X PATCH “localhost:3100/v1/pacbio/runs/1” \ -H “Content-Type: application/vnd.api+json” -H “Accept: application/vnd.api+json” -d ‘{ “data”: { “type”: “runs”, “id”: “1”, “attributes”: { “annotations_attributes”: [ { “comment”: “annotation comment”, “annotation_type_id”: “1”, “user”: “user1” } ] } } }’

curl -X PATCH “localhost:3100/v1/pacbio/runs/1” \ -H “Content-Type: application/vnd.api+json” \ -H “Accept: application/vnd.api+json” \ -d ‘{ “data”: { “type”: “runs”, “id”: “1”, “attributes”: { “plates_attributes”: [ { “id”: 1, “type”: “plates”, “wells_attributes”: [ { “id”: 1, “type”: “wells”, “annotations_attributes”: [ { “comment”: “annotation comment”, “annotation_type_id”: “1”, “user”: “user1” } ] } ] } ] } } }’

curl -X PATCH “localhost:3100/v1/pacbio/runs/1” \ -H “Content-Type: application/vnd.api+json” \ -H “Accept: application/vnd.api+json” \ -d ‘{ “data”: { “type”: “runs”, “attributes”: { “dna_control_complex_box_barcode”: “Lxxxxx101717600123191”, “system_name”: “Sequel II”, “pacbio_smrt_link_version_id”: 56, “plates_attributes”: [ { “sequencing_kit_box_barcode”: “DM0001100861800123121”, “plate_number”: 1, “wells_attributes”: [ { “row”: “A”, “column”: “1”, “movie_time”: 31, “on_plate_loading_concentration”: 8.35, “pre_extension_time”: “2”, “generate_hifi”: “In SMRT Link”, “ccs_analysis_output”: “Yes”, “binding_kit_box_barcode”: “DM1117100862200111711”, “ccs_analysis_output_include_low_quality_reads”: “Yes”, “include_fivemc_calls_in_cpg_motifs”: “Yes”, “ccs_analysis_output_include_kinetics_information”: “Yes”, “demultiplex_barcodes”: “In SMRT Link”, “used_aliquots_attributes”: [ { “source_id”: 391, “source_type”: “Pacbio::Pool”, “volume”: 10, “concentration”: 20, “aliquot_type”: “derived”, “template_prep_kit_box_barcode”: “033000000000000000000” } ], “annotations_attributes”: [ { “annotation_type_id”: 209, “comment”: “Another test comment”, “user”: “daisy” } ] } ] } ], “annotations_attributes”: [ { “annotation_type_id”: 209, “comment”: “Test comment”, “user”: “dave” } ] } } }’

Examples:

curl -X GET http://localhost:3100/v1/pacbio/runs/
curl -X GET http://localhost:3100/v1/pacbio/runs/1

curl -X GET http://localhost:3100/v1/pacbio/runs/1?include=plates.wells.used_aliquots,smrt_link_version
curl -X GET http://localhost:3100/v1/pacbio/runs/1?include=plates.wells.used_aliquots,plates.wells.libraries.request,plates.wells.pools.requests,plates.wells.pools.libraries.request,plates.wells.pools.used_aliquots.tag,plates.wells.libraries.used_aliquots.tag,smrt_link_version,annotations,plates.wells.annotations

curl -X GET http://localhost:3100/v1/pacbio/runs?filter[name]=TRACTION-RUN-1
curl -X GET http://localhost:3100/v1/pacbio/runs?filter[state]=pending

Constant Summary collapse

PERMITTED_WELL_PARAMETERS =

Well parameters that are permitted for the plates_attributes

%i[
  id row column comment
].concat(Rails.configuration.pacbio_smrt_link_versions.options.keys).freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#adaptive_loadingBoolean (readonly)

Returns whether adaptive loading is used.

Returns:

  • (Boolean)

    whether adaptive loading is used



207
208
209
210
211
# File 'app/resources/v1/pacbio/run_resource.rb', line 207

attributes :name, :dna_control_complex_box_barcode,
:system_name, :created_at, :state,
:pacbio_smrt_link_version_id, :plates_attributes,
:adaptive_loading, :sequencing_kit_box_barcodes,
:annotations_attributes

#barcodes_and_concentrationsString (readonly)

Returns the barcodes and concentrations of the run.

Returns:

  • (String)

    the barcodes and concentrations of the run



215
# File 'app/resources/v1/pacbio/run_resource.rb', line 215

attribute :barcodes_and_concentrations, readonly: true

#created_atString

Returns the creation time of the run.

Returns:

  • (String)

    the creation time of the run



# File 'app/resources/v1/pacbio/run_resource.rb', line 188

#dna_control_complex_box_barcodeString

Returns the barcode of the DNA control complex box.

Returns:

  • (String)

    the barcode of the DNA control complex box



# File 'app/resources/v1/pacbio/run_resource.rb', line 188

#nameString

Returns the name of the run.

Returns:

  • (String)

    the name of the run



# File 'app/resources/v1/pacbio/run_resource.rb', line 188

Returns the ID of the PacBio SMRT Link version.

Returns:

  • (Integer)

    the ID of the PacBio SMRT Link version



207
208
209
210
211
# File 'app/resources/v1/pacbio/run_resource.rb', line 207

attributes :name, :dna_control_complex_box_barcode,
:system_name, :created_at, :state,
:pacbio_smrt_link_version_id, :plates_attributes,
:adaptive_loading, :sequencing_kit_box_barcodes,
:annotations_attributes

#plates_attributesArray<Hash>

Returns the attributes of the plates.

Returns:

  • (Array<Hash>)

    the attributes of the plates



207
208
209
210
211
# File 'app/resources/v1/pacbio/run_resource.rb', line 207

attributes :name, :dna_control_complex_box_barcode,
:system_name, :created_at, :state,
:pacbio_smrt_link_version_id, :plates_attributes,
:adaptive_loading, :sequencing_kit_box_barcodes,
:annotations_attributes

#sequencing_kit_box_barcodesArray<String> (readonly)

Returns the barcodes of the sequencing kits.

Returns:

  • (Array<String>)

    the barcodes of the sequencing kits



207
208
209
210
211
# File 'app/resources/v1/pacbio/run_resource.rb', line 207

attributes :name, :dna_control_complex_box_barcode,
:system_name, :created_at, :state,
:pacbio_smrt_link_version_id, :plates_attributes,
:adaptive_loading, :sequencing_kit_box_barcodes,
:annotations_attributes

#stateString

Returns the state of the run.

Returns:

  • (String)

    the state of the run



# File 'app/resources/v1/pacbio/run_resource.rb', line 188

#system_nameString

Returns the name of the system.

Returns:

  • (String)

    the name of the system



# File 'app/resources/v1/pacbio/run_resource.rb', line 188

Class Method Details

.creatable_fields(context) ⇒ Object



268
269
270
# File 'app/resources/v1/pacbio/run_resource.rb', line 268

def self.creatable_fields(context)
  super - %i[adaptive_loading sequencing_kit_box_barcodes]
end

.default_sortObject



235
236
237
# File 'app/resources/v1/pacbio/run_resource.rb', line 235

def self.default_sort
  [{ field: 'created_at', direction: :desc }]
end

.resource_klass_for(type) ⇒ Object

JSON API Resources builds up a representation of the relationships on a give resource. Whilst doing to it asks the associated resource for its type, before using this method on the parent resource to attempt to look up the model. Unfortunately this results in V1::Pacbio::PlateResource by default. We should probably consider renaming Runs::Plate to something like Runs::PacBioPlate thereby updating the type. However this will also need updates to routes, and the front end. i.e. this is needed for GET /v1/pacbio/runs?include=plate



252
253
254
255
256
257
258
259
260
# File 'app/resources/v1/pacbio/run_resource.rb', line 252

def self.resource_klass_for(type)
  if type == 'plates'
    super('runs/plates')
  elsif type == 'annotations'
    super('runs/annotations')
  else
    super
  end
end

.updatable_fields(context) ⇒ Object



272
273
274
# File 'app/resources/v1/pacbio/run_resource.rb', line 272

def self.updatable_fields(context)
  super - %i[adaptive_loading sequencing_kit_box_barcodes]
end

Instance Method Details

#publish_messagesObject



262
263
264
265
266
# File 'app/resources/v1/pacbio/run_resource.rb', line 262

def publish_messages
  Messages.publish(@model, Pipelines.pacbio.message)
  Emq::Publisher.publish(@model.aliquots_to_publish_on_run, Pipelines.pacbio,
                         'volume_tracking')
end