Class: V1::Pacbio::LibraryResource

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

Overview

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

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 Library and can return all libraries, a single library or multiple libraries along with their relationships.

Filters:

  • sample_name

  • barcode

  • source_identifier

Primary relationships:

Relationship trees:

  • request.sample

  • tube.requests

  • pool.libraries

Examples:

curl -X GET http://localhost:3000/v1/pacbio/libraries/1
curl -X GET http://localhost:3000/v1/pacbio/libraries/
curl -X GET http://localhost:3000/v1/pacbio/libraries/1?include=request,tube,pool

https://localhost:3000/v1/pacbio/libraries?filter[sample_name]=sample_name
https://localhost:3000/v1/pacbio/libraries?filter[barcode]=TRAC-2-12068

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

https://localhost:3000/v1/pacbio/libraries?filter[barcode]=TRAC-2-12068,TRAC-2-12066,TRAC-2-12067&include=request.sample,tube.requests,pool.libraries

Direct Known Subclasses

Runs::LibraryResource

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 library.

Returns:

  • (Float)

    the available volume of the library



75
76
77
78
# File 'app/resources/v1/pacbio/library_resource.rb', line 75

attributes :state, :volume, :concentration, :template_prep_kit_box_barcode,
:insert_size, :created_at, :deactivated_at, :source_identifier,
:pacbio_request_id, :tag_id, :primary_aliquot_attributes,
:used_volume, :available_volume

#barcodeString (readonly)

Returns the barcode of the library (via tube).

Returns:

  • (String)

    the barcode of the library (via tube)



82
# File 'app/resources/v1/pacbio/library_resource.rb', line 82

attribute :barcode, readonly: true

#concentrationFloat

Returns the concentration of the library.

Returns:

  • (Float)

    the concentration of the library



75
76
77
78
# File 'app/resources/v1/pacbio/library_resource.rb', line 75

attributes :state, :volume, :concentration, :template_prep_kit_box_barcode,
:insert_size, :created_at, :deactivated_at, :source_identifier,
:pacbio_request_id, :tag_id, :primary_aliquot_attributes,
:used_volume, :available_volume

#created_atString

Returns the creation time of the library.

Returns:

  • (String)

    the creation time of the library



75
76
77
78
# File 'app/resources/v1/pacbio/library_resource.rb', line 75

attributes :state, :volume, :concentration, :template_prep_kit_box_barcode,
:insert_size, :created_at, :deactivated_at, :source_identifier,
:pacbio_request_id, :tag_id, :primary_aliquot_attributes,
:used_volume, :available_volume

#deactivated_atDateTime?

Returns the deactivation time of the library, or nil if not deactivated.

Returns:

  • (DateTime, nil)

    the deactivation time of the library, or nil if not deactivated



75
76
77
78
# File 'app/resources/v1/pacbio/library_resource.rb', line 75

attributes :state, :volume, :concentration, :template_prep_kit_box_barcode,
:insert_size, :created_at, :deactivated_at, :source_identifier,
:pacbio_request_id, :tag_id, :primary_aliquot_attributes,
:used_volume, :available_volume

#insert_sizeInteger

Returns the insert size of the library.

Returns:

  • (Integer)

    the insert size of the library



75
76
77
78
# File 'app/resources/v1/pacbio/library_resource.rb', line 75

attributes :state, :volume, :concentration, :template_prep_kit_box_barcode,
:insert_size, :created_at, :deactivated_at, :source_identifier,
:pacbio_request_id, :tag_id, :primary_aliquot_attributes,
:used_volume, :available_volume

#pacbio_request_idInteger

Returns the ID of the associated PacBio request.

Returns:

  • (Integer)

    the ID of the associated PacBio request



75
76
77
78
# File 'app/resources/v1/pacbio/library_resource.rb', line 75

attributes :state, :volume, :concentration, :template_prep_kit_box_barcode,
:insert_size, :created_at, :deactivated_at, :source_identifier,
:pacbio_request_id, :tag_id, :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



75
76
77
78
# File 'app/resources/v1/pacbio/library_resource.rb', line 75

attributes :state, :volume, :concentration, :template_prep_kit_box_barcode,
:insert_size, :created_at, :deactivated_at, :source_identifier,
:pacbio_request_id, :tag_id, :primary_aliquot_attributes,
:used_volume, :available_volume

#source_identifierString

Returns the source identifier of the library.

Returns:

  • (String)

    the source identifier of the library



75
76
77
78
# File 'app/resources/v1/pacbio/library_resource.rb', line 75

attributes :state, :volume, :concentration, :template_prep_kit_box_barcode,
:insert_size, :created_at, :deactivated_at, :source_identifier,
:pacbio_request_id, :tag_id, :primary_aliquot_attributes,
:used_volume, :available_volume

#stateString

Returns the state of the library.

Returns:

  • (String)

    the state of the library



75
76
77
78
# File 'app/resources/v1/pacbio/library_resource.rb', line 75

attributes :state, :volume, :concentration, :template_prep_kit_box_barcode,
:insert_size, :created_at, :deactivated_at, :source_identifier,
:pacbio_request_id, :tag_id, :primary_aliquot_attributes,
:used_volume, :available_volume

#tag_idInteger

Returns the ID of the associated tag.

Returns:

  • (Integer)

    the ID of the associated tag



75
76
77
78
# File 'app/resources/v1/pacbio/library_resource.rb', line 75

attributes :state, :volume, :concentration, :template_prep_kit_box_barcode,
:insert_size, :created_at, :deactivated_at, :source_identifier,
:pacbio_request_id, :tag_id, :primary_aliquot_attributes,
:used_volume, :available_volume

#template_prep_kit_box_barcodeString

Returns the barcode of the template prep kit box.

Returns:

  • (String)

    the barcode of the template prep kit box



75
76
77
78
# File 'app/resources/v1/pacbio/library_resource.rb', line 75

attributes :state, :volume, :concentration, :template_prep_kit_box_barcode,
:insert_size, :created_at, :deactivated_at, :source_identifier,
:pacbio_request_id, :tag_id, :primary_aliquot_attributes,
:used_volume, :available_volume

#used_volumeFloat

Returns the used volume of the library.

Returns:

  • (Float)

    the used volume of the library



75
76
77
78
# File 'app/resources/v1/pacbio/library_resource.rb', line 75

attributes :state, :volume, :concentration, :template_prep_kit_box_barcode,
:insert_size, :created_at, :deactivated_at, :source_identifier,
:pacbio_request_id, :tag_id, :primary_aliquot_attributes,
:used_volume, :available_volume

#volumeFloat

Returns the volume of the library.

Returns:

  • (Float)

    the volume of the library



75
76
77
78
# File 'app/resources/v1/pacbio/library_resource.rb', line 75

attributes :state, :volume, :concentration, :template_prep_kit_box_barcode,
:insert_size, :created_at, :deactivated_at, :source_identifier,
:pacbio_request_id, :tag_id, :primary_aliquot_attributes,
:used_volume, :available_volume

Class Method Details

.default_sortObject



101
102
103
# File 'app/resources/v1/pacbio/library_resource.rb', line 101

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

.records_for_populate(*_args) ⇒ Object



129
130
131
132
133
# File 'app/resources/v1/pacbio/library_resource.rb', line 129

def self.records_for_populate(*_args)
  super.preload(source_well: :plate, request: :sample,
                tag: :tag_set,
                container_material: { container: :barcode })
end

Instance Method Details

#fetchable_fieldsObject



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

def fetchable_fields
  super - [:primary_aliquot_attributes]
end

#publish_messagesObject



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

def publish_messages
  Messages.publish(@model.sequencing_runs, Pipelines.pacbio.message)
  publish_volume_tracking_messages
end

#publish_volume_tracking_messagesObject



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

def publish_volume_tracking_messages
  Emq::Publisher.publish([@model.primary_aliquot, *@model.used_aliquots],
                         Pipelines.pacbio, 'volume_tracking')
end