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.

For more information about JSON:API see the JSON:API Specifications or look at the JSONAPI::Resources package for the service implementation of the JSON:API standard. This resource represents a Pacbio Run and can return all runs, a single run or multiple runs along with their relationships. It can also create and update runs and their nested relationships via the plates_attributes parameter. These actions also publish run messages to the warehouse.

Filters:

  • name

  • state

Primary relationships:

Relationship trees:

  • plates.wells.used_aliquots

  • smrt_link_version.smrt_link_option_versions

Examples:

curl -X GET http://localhost:3000/v1/pacbio/runs/1
curl -X GET http://localhost:3000/v1/pacbio/runs/
curl -X GET http://localhost:3000/v1/pacbio/runs/1?include=plates.wells.used_aliquots,smrt_link_version

http://localhost:3000/v1/pacbio/runs?filter[name]=TRACTION-RUN-1
http://localhost:3000/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



60
61
62
63
# File 'app/resources/v1/pacbio/run_resource.rb', line 60

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

#barcodes_and_concentrationsString (readonly)

Returns the barcodes and concentrations of the run.

Returns:

  • (String)

    the barcodes and concentrations of the run



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

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 41

#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 41

#nameString

Returns the name of the run.

Returns:

  • (String)

    the name of the run



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

Returns the ID of the PacBio SMRT Link version.

Returns:

  • (Integer)

    the ID of the PacBio SMRT Link version



60
61
62
63
# File 'app/resources/v1/pacbio/run_resource.rb', line 60

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

#plates_attributesArray<Hash>

Returns the attributes of the plates.

Returns:

  • (Array<Hash>)

    the attributes of the plates



60
61
62
63
# File 'app/resources/v1/pacbio/run_resource.rb', line 60

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

#sequencing_kit_box_barcodesArray<String> (readonly)

Returns the barcodes of the sequencing kits.

Returns:

  • (Array<String>)

    the barcodes of the sequencing kits



60
61
62
63
# File 'app/resources/v1/pacbio/run_resource.rb', line 60

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

#stateString

Returns the state of the run.

Returns:

  • (String)

    the state of the run



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

#system_nameString

Returns the name of the system.

Returns:

  • (String)

    the name of the system



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

Class Method Details

.creatable_fields(context) ⇒ Object



116
117
118
# File 'app/resources/v1/pacbio/run_resource.rb', line 116

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

.default_sortObject



85
86
87
# File 'app/resources/v1/pacbio/run_resource.rb', line 85

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



102
103
104
105
106
107
108
# File 'app/resources/v1/pacbio/run_resource.rb', line 102

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

.updatable_fields(context) ⇒ Object



120
121
122
# File 'app/resources/v1/pacbio/run_resource.rb', line 120

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

Instance Method Details

#publish_messagesObject



110
111
112
113
114
# File 'app/resources/v1/pacbio/run_resource.rb', line 110

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