Class: Pacbio::Library

Inherits:
ApplicationRecord show all
Includes:
Aliquotable, DualSourcedLibrary, Librarian, Material, Uuidable
Defined in:
app/models/pacbio/library.rb

Overview

Pacbio::Library A Pacbio Library is capable of being multiplexed i.e. is capable of containing several samples in the form of requests. A library can have many requests but can also belong to many requests A library can be sequenced in more than one well. This is achieved using a has many through relationship

Instance Method Summary collapse

Methods included from DualSourcedLibrary

#source_identifier

Methods included from Aliquotable

#used_aliquots_volume

Methods included from Librarian

#active?, #deactivate, #set_state

Methods included from Uuidable

#add_uuid

Methods included from Material

#container=

Instance Method Details

#collection?Boolean

Always false for libraries, but always true for wells - a gross simplification

Returns:

  • (Boolean)


89
90
91
# File 'app/models/pacbio/library.rb', line 89

def collection?
  false
end

#create_used_aliquotObject



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'app/models/pacbio/library.rb', line 61

def create_used_aliquot
  return if used_aliquots.any?

  used_aliquots.create(
    source: request,
    aliquot_type: :derived,
    volume:,
    concentration:,
    template_prep_kit_box_barcode:,
    insert_size:,
    tag:
  )
end

#sequencing_platesArray

Note - This does not take into account when a library is used in a pool and that pool is used in a run

Returns:

  • (Array)

    of Plates attached to a sequencing run



112
113
114
# File 'app/models/pacbio/library.rb', line 112

def sequencing_plates
  wells&.collect(&:plate)
end

#sequencing_runsArray

Note - This does not take into account when a library is used in a pool and that pool is used in a run

Returns:

  • (Array)

    of Runs that the pool is used in



105
106
107
# File 'app/models/pacbio/library.rb', line 105

def sequencing_runs
  wells&.collect(&:run)&.uniq
end

#tagged?Boolean

Checks if the library is tagged.

An library is considered tagged if it has a non-nil and non-empty tag.

Returns:

  • (Boolean)

    Returns true if the library is tagged, false otherwise.



98
99
100
# File 'app/models/pacbio/library.rb', line 98

def tagged?
  tag.present?
end

#update_used_aliquotsObject

Updates the used aliquots data when the primary aliquot is updated



76
77
78
79
80
81
82
83
84
85
86
# File 'app/models/pacbio/library.rb', line 76

def update_used_aliquots
  used_aliquots.each do |aliquot|
    aliquot.update(
      volume: primary_aliquot.volume,
      concentration: primary_aliquot.concentration,
      template_prep_kit_box_barcode: primary_aliquot.template_prep_kit_box_barcode,
      insert_size: primary_aliquot.insert_size,
      tag: primary_aliquot.tag
    )
  end
end