Class: V1::Pacbio::PoolResource

Inherits:
JSONAPI::Resource
  • Object
show all
Includes:
Shared::RunSuitability
Defined in:
app/resources/v1/pacbio/pool_resource.rb

Overview

Note:

Access this resource via the /v1/pacbio/pools/ endpoint.

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

Filters:

  • sample_name

  • barcode

Primary relationships:

Relationship trees:

  • used_aliquots.tag.tag_set

  • requests.tube,tube

  • libraries.tube

  • libraries.request

  • requests.plate.wells.requests

curl -X POST “localhost:3100/v1/pacbio/pools” \ -H “accept: application/vnd.api+json” \ -H “Content-Type: application/vnd.api+json” \ -d ‘{ “data”: { “type”: “pools”, “attributes”: { “used_aliquots_attributes”: [ { “template_prep_kit_box_barcode”: “LK1234567”, “volume”: 1.11, “concentration”: 2.22, “insert_size”: 100, “source_id”: 1, “source_type”: “Pacbio::Request”, “tag_id”: 999 }, { “template_prep_kit_box_barcode”: “LK1234567”, “volume”: 1.11, “concentration”: 2.22, “insert_size”: 100, “source_id”: 2, “source_type”: “Pacbio::Request”, “tag_id”: 9999 } ], “primary_aliquot_attributes”: { “volume”: “200”, “concentration”: “22”, “template_prep_kit_box_barcode”: “100”, “insert_size”: “11” } } } }’

curl -X PATCH “localhost:3100/v1/pacbio/pools/1” \ -H “accept: application/vnd.api+json” \ -H “Content-Type: application/vnd.api+json” \ -d ‘{ data: { type: ’pools’, id: 1, attributes: { used_aliquots_attributes: [ { id: 10, source_id: 333, source_type: ‘Pacbio::Library’, template_prep_kit_box_barcode: ‘LK12345’, tag_id: 9999, volume: 1, concentration: 1, insert_size: 100 }, { source_id: 444, source_type: ‘Pacbio::Request’, template_prep_kit_box_barcode: ‘LK12345’, tag_id: 9998, volume: 1, concentration: 1, insert_size: 100 } ], primary_aliquot_attributes: { volume: ‘200’, concentration: ‘22’, template_prep_kit_box_barcode: ‘100’, insert_size: ‘11’ }, volume: ‘200’, concentration: ‘22’, template_prep_kit_box_barcode: ‘100’, insert_size: ‘11’, created_at: ‘2021-08-04T14:35:47.208Z’, updated_at: ‘2021-08-04T14:35:47.208Z’ } } }‘

Examples:

curl -X GET http://localhost:3100/v1/pacbio/pools/1
curl -X GET http://localhost:3100/v1/pacbio/pools/
curl -X GET http://localhost:3100/v1/pacbio/pools/1?include=tube,used_aliquots,primary_aliquot,requests,libraries

curl -X GET https://locahost:3100/v1/pacbio/pools?filter[sample_name]=sample_name
curl -X GET https://locahost:3100/v1/pacbio/pools?filter[barcode]=TRAC-2-12068
curl -X GET https://locahost:3100/v1/pacbio/pools?filter[barcode]=TRAC-2-12068,TRAC-2-12066,TRAC-2-12067
curl -X GET https://localhost:3100/v1/pacbio/pools?filter[barcode]=TRAC-2-12068,TRAC-2-12066,TRAC-2-12067&include=used_aliquots.tag.tag_set,requests.tube,tube,libraries.tube,libraries.request,requests.plate.wells.requests

Direct Known Subclasses

Runs::PoolResource

Constant Summary collapse

ALIQUOT_ATTRIBUTES =
%w[id volume concentration template_prep_kit_box_barcode insert_size
tag_id source_id source_type].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Shared::RunSuitability

#run_suitability

Instance Attribute Details

#available_volumeFloat

Returns the available volume of the pool.

Returns:

  • (Float)

    the available volume of the pool



159
160
161
162
# File 'app/resources/v1/pacbio/pool_resource.rb', line 159

attributes :volume, :concentration, :template_prep_kit_box_barcode,
:insert_size, :created_at, :updated_at,
:library_attributes, :used_aliquots_attributes, :primary_aliquot_attributes,
:used_volume, :available_volume

#barcodeString (readonly)

Returns the barcode of the pool (via tube).

Returns:

  • (String)

    the barcode of the pool (via tube)



170
# File 'app/resources/v1/pacbio/pool_resource.rb', line 170

attribute :barcode, readonly: true

#concentrationFloat

Returns the concentration of the pool.

Returns:

  • (Float)

    the concentration of the pool



159
160
161
162
# File 'app/resources/v1/pacbio/pool_resource.rb', line 159

attributes :volume, :concentration, :template_prep_kit_box_barcode,
:insert_size, :created_at, :updated_at,
:library_attributes, :used_aliquots_attributes, :primary_aliquot_attributes,
:used_volume, :available_volume

#created_atString

Returns the creation time of the pool.

Returns:

  • (String)

    the creation time of the pool



159
160
161
162
# File 'app/resources/v1/pacbio/pool_resource.rb', line 159

attributes :volume, :concentration, :template_prep_kit_box_barcode,
:insert_size, :created_at, :updated_at,
:library_attributes, :used_aliquots_attributes, :primary_aliquot_attributes,
:used_volume, :available_volume

#insert_sizeInteger

Returns the insert size of the pool.

Returns:

  • (Integer)

    the insert size of the pool



159
160
161
162
# File 'app/resources/v1/pacbio/pool_resource.rb', line 159

attributes :volume, :concentration, :template_prep_kit_box_barcode,
:insert_size, :created_at, :updated_at,
:library_attributes, :used_aliquots_attributes, :primary_aliquot_attributes,
:used_volume, :available_volume

#library_attributesHash

Returns the attributes of the library.

Returns:

  • (Hash)

    the attributes of the library



159
160
161
162
# File 'app/resources/v1/pacbio/pool_resource.rb', line 159

attributes :volume, :concentration, :template_prep_kit_box_barcode,
:insert_size, :created_at, :updated_at,
:library_attributes, :used_aliquots_attributes, :primary_aliquot_attributes,
:used_volume, :available_volume

#primary_aliquot_attributesHash

Returns the attributes of the primary aliquot.

Returns:

  • (Hash)

    the attributes of the primary aliquot



159
160
161
162
# File 'app/resources/v1/pacbio/pool_resource.rb', line 159

attributes :volume, :concentration, :template_prep_kit_box_barcode,
:insert_size, :created_at, :updated_at,
:library_attributes, :used_aliquots_attributes, :primary_aliquot_attributes,
:used_volume, :available_volume

#source_identifierString (readonly)

Returns the source identifier of the pool.

Returns:

  • (String)

    the source identifier of the pool



166
# File 'app/resources/v1/pacbio/pool_resource.rb', line 166

attribute :source_identifier, readonly: true

#template_prep_kit_box_barcodeString

Returns the barcode of the template prep kit box.

Returns:

  • (String)

    the barcode of the template prep kit box



159
160
161
162
# File 'app/resources/v1/pacbio/pool_resource.rb', line 159

attributes :volume, :concentration, :template_prep_kit_box_barcode,
:insert_size, :created_at, :updated_at,
:library_attributes, :used_aliquots_attributes, :primary_aliquot_attributes,
:used_volume, :available_volume

#updated_atString

Returns the last update time of the pool.

Returns:

  • (String)

    the last update time of the pool



159
160
161
162
# File 'app/resources/v1/pacbio/pool_resource.rb', line 159

attributes :volume, :concentration, :template_prep_kit_box_barcode,
:insert_size, :created_at, :updated_at,
:library_attributes, :used_aliquots_attributes, :primary_aliquot_attributes,
:used_volume, :available_volume

#used_aliquots_attributesArray<Hash>

Returns the attributes of the used aliquots.

Returns:

  • (Array<Hash>)

    the attributes of the used aliquots



159
160
161
162
# File 'app/resources/v1/pacbio/pool_resource.rb', line 159

attributes :volume, :concentration, :template_prep_kit_box_barcode,
:insert_size, :created_at, :updated_at,
:library_attributes, :used_aliquots_attributes, :primary_aliquot_attributes,
:used_volume, :available_volume

#used_volumeFloat

Returns the used volume of the pool.

Returns:

  • (Float)

    the used volume of the pool



159
160
161
162
# File 'app/resources/v1/pacbio/pool_resource.rb', line 159

attributes :volume, :concentration, :template_prep_kit_box_barcode,
:insert_size, :created_at, :updated_at,
:library_attributes, :used_aliquots_attributes, :primary_aliquot_attributes,
:used_volume, :available_volume

#volumeFloat

Returns the volume of the pool.

Returns:

  • (Float)

    the volume of the pool



159
160
161
162
# File 'app/resources/v1/pacbio/pool_resource.rb', line 159

attributes :volume, :concentration, :template_prep_kit_box_barcode,
:insert_size, :created_at, :updated_at,
:library_attributes, :used_aliquots_attributes, :primary_aliquot_attributes,
:used_volume, :available_volume

Class Method Details

.default_sortObject



177
178
179
# File 'app/resources/v1/pacbio/pool_resource.rb', line 177

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

.records_for_populate(*_args) ⇒ Object



213
214
215
# File 'app/resources/v1/pacbio/pool_resource.rb', line 213

def self.records_for_populate(*_args)
  super.preload(source_wells: :plate)
end

Instance Method Details

#fetchable_fieldsObject



209
210
211
# File 'app/resources/v1/pacbio/pool_resource.rb', line 209

def fetchable_fields
  super - %i[library_attributes used_aliquots_attributes primary_aliquot_attributes]
end

#publish_messages_on_creationObject



225
226
227
# File 'app/resources/v1/pacbio/pool_resource.rb', line 225

def publish_messages_on_creation
  Emq::Publisher.publish(@model.primary_aliquot, Pipelines.pacbio, 'volume_tracking')
end

#publish_messages_on_updateObject



229
230
231
232
# File 'app/resources/v1/pacbio/pool_resource.rb', line 229

def publish_messages_on_update
  Messages.publish(@model.sequencing_runs, Pipelines.pacbio.message)
  Emq::Publisher.publish(@model.primary_aliquot, Pipelines.pacbio, 'volume_tracking')
end