Class: Aliquot

Inherits:
ApplicationRecord show all
Includes:
Uuidable
Defined in:
app/models/aliquot.rb

Overview

A portion of a sample that is used for a library, sample or pool. An aliquot can be a primary aliquot or a derived aliquot. An aliquot can be used to track volumes and concentrations of samples.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Uuidable

#add_uuid

Class Method Details

.publishableObject

Returns a list of all the aliquots that are publishable.



53
54
55
56
57
58
59
# File 'app/models/aliquot.rb', line 53

def self.publishable
  [].tap do |aliquots|
    filtered_aliquots = filter_by_publishable.to_a
    aliquots.concat(filtered_aliquots)
    aliquots.concat(used_by_well_library_aliquots(filtered_aliquots))
  end
end

.used_by_well_library_aliquots(aliquots) ⇒ Object

Find aliquots from a Pacbio::Pool used by a Pacbio::Well and add their source’s used aliquots if from a Pacbio::Library



63
64
65
66
67
68
69
70
71
72
73
74
# File 'app/models/aliquot.rb', line 63

def self.used_by_well_library_aliquots(aliquots)
  well_aliquots = aliquots.select do |aliquot|
    aliquot.source_type == 'Pacbio::Pool' && aliquot.used_by_type == 'Pacbio::Well'
  end
  [].tap do |library_aliquots|
    well_aliquots.each do |aliquot|
      library_aliquots.concat(aliquot.source.used_aliquots.select do |used_aliquot|
        used_aliquot.source_type == 'Pacbio::Library'
      end)
    end
  end
end

Instance Method Details

#adapterObject

Sample Adapter field The same adapter is used for both left and right, see same_barcodes_on_both_ends_of_sequence Returns nil if the tag is nil



130
131
132
# File 'app/models/aliquot.rb', line 130

def adapter
  tag&.group_id
end

#barcode_nameObject

Barcode Name field Deprecated as of SMRT-Link v13.0 See www.pacb.com/wp-content/uploads/SMRT-Link-Release-Notes-v13.0.pdf



121
122
123
124
125
# File 'app/models/aliquot.rb', line 121

def barcode_name
  return if tag_set.hidden_sample_sheet_behaviour?

  "#{tag.group_id}--#{tag.group_id}"
end

#bio_sample_nameObject

Sample bio Name field



105
106
107
108
109
# File 'app/models/aliquot.rb', line 105

def bio_sample_name
  return '' if tag_set.hidden_sample_sheet_behaviour?

  source.sample_name || ''
end

#collection?Boolean

Generic method used by pacbio sample sheet generation to determine whether the data is a collection or not. Assuming false is a simplification used previously for sample-sheets

Returns:

  • (Boolean)


100
101
102
# File 'app/models/aliquot.rb', line 100

def collection?
  false
end

#formatted_bio_sample_nameObject

Returns the formatted bio sample name. Replaces all colons (:) in the bio sample name with hyphens (-).



114
115
116
# File 'app/models/aliquot.rb', line 114

def formatted_bio_sample_name
  bio_sample_name.gsub(':', '-')
end

#tag_setObject

Returns the tag set for the aliquot If the tag_set is nil, it returns a NullTagSet



78
79
80
# File 'app/models/aliquot.rb', line 78

def tag_set
  super || NullTagSet.new
end

#tagged?Boolean

Checks if the aliquot is tagged. An aliquot is considered tagged if it has a non-nil and non-empty tag.

Returns:

  • (Boolean)

    Returns true if the aliquot is tagged, false otherwise.



88
89
90
91
92
93
94
95
# File 'app/models/aliquot.rb', line 88

def tagged?
  # This feels like a bit of a hack but I wasn't exactly sure where the best place to
  # it. I tried to follow the sample sheet behaviour but got lost.
  # it looks like the only place this is used is in the sample sheet generation
  return false if tag.nil?

  tag_set.default_sample_sheet_behaviour?
end