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

  • annotations

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



62
63
64
65
66
# File 'app/resources/v1/pacbio/run_resource.rb', line 62

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



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

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 43

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

#nameString

Returns the name of the run.

Returns:

  • (String)

    the name of the run



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

Returns the ID of the PacBio SMRT Link version.

Returns:

  • (Integer)

    the ID of the PacBio SMRT Link version



62
63
64
65
66
# File 'app/resources/v1/pacbio/run_resource.rb', line 62

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



62
63
64
65
66
# File 'app/resources/v1/pacbio/run_resource.rb', line 62

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



62
63
64
65
66
# File 'app/resources/v1/pacbio/run_resource.rb', line 62

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 43

#system_nameString

Returns the name of the system.

Returns:

  • (String)

    the name of the system



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

Class Method Details

.creatable_fields(context) ⇒ Object



123
124
125
# File 'app/resources/v1/pacbio/run_resource.rb', line 123

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

.default_sortObject



90
91
92
# File 'app/resources/v1/pacbio/run_resource.rb', line 90

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



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

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



127
128
129
# File 'app/resources/v1/pacbio/run_resource.rb', line 127

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

Instance Method Details

#publish_messagesObject



117
118
119
120
121
# File 'app/resources/v1/pacbio/run_resource.rb', line 117

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