Class: V1::Pacbio::PoolResource

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

Overview

TODO:

Add POST and PATCH examples

Note:

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

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

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 Pool and can return all pools, a single pool or multiple pools along with their relationships.

Filters:

  • sample_name

  • barcode

Primary relationships:

Relationship trees:

  • used_aliquots.tag.tag_set

  • requests.tube,tube

  • libraries.tube

  • libraries.request

  • requests.plate.wells.requests

Examples:

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

https://locahost:3000/v1/pacbio/pools?filter[sample_name]=sample_name

https://locahost:3000/v1/pacbio/pools?filter[barcode]=TRAC-2-12068

https://locahost:3000/v1/pacbio/pools?filter[barcode]=TRAC-2-12068,TRAC-2-12066,TRAC-2-12067

https://localhost:3000/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



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

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)



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

attribute :barcode, readonly: true

#concentrationFloat

Returns the concentration of the pool.

Returns:

  • (Float)

    the concentration of the pool



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



108
109
110
# File 'app/resources/v1/pacbio/pool_resource.rb', line 108

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

.records_for_populate(*_args) ⇒ Object



142
143
144
# File 'app/resources/v1/pacbio/pool_resource.rb', line 142

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

Instance Method Details

#fetchable_fieldsObject



138
139
140
# File 'app/resources/v1/pacbio/pool_resource.rb', line 138

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

#publish_messages_on_creationObject



154
155
156
# File 'app/resources/v1/pacbio/pool_resource.rb', line 154

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

#publish_messages_on_updateObject



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

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