Class: Pacbio::Well

Inherits:
ApplicationRecord show all
Includes:
Aliquotable, Uuidable
Defined in:
app/models/pacbio/well.rb

Overview

Pacbio::Well A well can have many libraries

Constant Summary collapse

GENERIC_KIT_BARCODE =
'Lxxxxx100938900123199'

Instance Method Summary collapse

Methods included from Aliquotable

#used_aliquots_volume

Methods included from Uuidable

#add_uuid

Instance Method Details

#adaptive_loading_checkBoolean

Returns true if loading_target_p1_plus_p2 is present.

Returns:

  • (Boolean)

    true if loading_target_p1_plus_p2 is present



116
117
118
# File 'app/models/pacbio/well.rb', line 116

def adaptive_loading_check
  loading_target_p1_plus_p2.present?
end

#aliquots_to_show_per_rowObject

Returns libraries only if they should be shown per row



161
162
163
164
165
# File 'app/models/pacbio/well.rb', line 161

def aliquots_to_show_per_row
  return unless show_row_per_sample?

  base_used_aliquots
end

#automation_parametersString

Set the automation parameters

Examples:

ExtensionTime=double:#5|ExtendFirst=boolean:True

Returns:

  • (String)

    Returns nil if pre_extension_time is 0 or nil



208
209
210
211
212
# File 'app/models/pacbio/well.rb', line 208

def automation_parameters
  return if pre_extension_time == 0 || pre_extension_time.nil?

  "ExtensionTime=double:#{pre_extension_time}|ExtendFirst=boolean:True"
end

#barcode_setObject

Barcode Set field



147
148
149
150
151
# File 'app/models/pacbio/well.rb', line 147

def barcode_set
  return if tag_set.hidden_sample_sheet_behaviour?

  tag_set.uuid
end

#base_used_aliquotsObject

A collection of all the used_aliquots for given libraries and pools in a well



61
62
63
64
# File 'app/models/pacbio/well.rb', line 61

def base_used_aliquots
  used_aliquots.reject(&:marked_for_destruction?)
               .collect(&:source).collect(&:used_aliquots).flatten
end

#bio_sample_nameObject

Sample bio Name field Returns nil if sample is barcoded otherwise returns the sample names for all of the aliquots



216
217
218
# File 'app/models/pacbio/well.rb', line 216

def bio_sample_name
  sample_is_barcoded ? nil : sample_names
end

#collection?Boolean

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

Returns:

  • (Boolean)


111
112
113
# File 'app/models/pacbio/well.rb', line 111

def collection?
  true
end

#formatted_bio_sample_nameObject

Returns the formatted bio sample name. If the sample is barcoded, it returns nil. Otherwise, it returns the sample names with colons replaced by hyphens.



223
224
225
# File 'app/models/pacbio/well.rb', line 223

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

#get_plate(plate_number) ⇒ Object

find the plate given the plate_number returns nil if no plate found



175
176
177
# File 'app/models/pacbio/well.rb', line 175

def get_plate(plate_number)
  plate.run.plates.filter { |plate| plate.plate_number == plate_number }.first
end

#insert_sizeString

Returns the insert_size of the first used_by aliqout.

Returns:

  • (String)

    the insert_size of the first used_by aliqout



106
107
108
# File 'app/models/pacbio/well.rb', line 106

def insert_size
  base_used_aliquots.first.used_by.insert_size
end

#libraries?Boolean

Returns true if the well has any libraries.

Returns:

  • (Boolean)

    true if the well has any libraries



96
97
98
# File 'app/models/pacbio/well.rb', line 96

def libraries?
  libraries.present?
end

#plate_well_positionObject

Sample Plate Well field



142
143
144
# File 'app/models/pacbio/well.rb', line 142

def plate_well_position
  "#{plate.plate_number}_#{position_leading_zero}"
end

#pools?Boolean

Returns true if the well has any pools.

Returns:

  • (Boolean)

    true if the well has any pools



91
92
93
# File 'app/models/pacbio/well.rb', line 91

def pools?
  pools.present?
end

#positionObject



52
53
54
# File 'app/models/pacbio/well.rb', line 52

def position
  "#{row}#{column}"
end

#position_leading_zeroObject

Sample Well field



137
138
139
# File 'app/models/pacbio/well.rb', line 137

def position_leading_zero
  "#{row}#{column.rjust(2, '0')}"
end

#request_librariesObject

collection of all of the requests for a library useful for messaging

Raises:

  • (StandardError)


68
69
70
# File 'app/models/pacbio/well.rb', line 68

def request_libraries
  raise StandardError, 'Unsupported, fix this'
end

#same_barcodes_on_both_ends_of_sequenceObject

Are the left and right adapters the same? Returns True if tagged, nil otherwise See Aliquot#adapter field method below and adapter and adapter2 fields in pacbio.yml



201
202
203
# File 'app/models/pacbio/well.rb', line 201

def same_barcodes_on_both_ends_of_sequence
  tagged? || nil
end

#sample_is_barcodedObject

Used to indicate to the sample sheet whether it should treat a sample as barcoded

Note: This doesn’t actually indicate that a sample is barcoded, as :hidden

tag sets (such as IsoSeq) lie.



194
195
196
# File 'app/models/pacbio/well.rb', line 194

def sample_is_barcoded
  tag_set.default_sample_sheet_behaviour?
end

#sample_names(separator = ':') ⇒ Object

a collection of all the sample names for a particular well useful for comments



74
75
76
# File 'app/models/pacbio/well.rb', line 74

def sample_names(separator = ':')
  base_used_aliquots.collect(&:source).collect(&:sample_name).join(separator)
end

#sequencing_kit_box_barcode_plate_1Object

return the sequencing_kit_box_barcode of plate 1 used for 2-plate sample sheets



181
182
183
# File 'app/models/pacbio/well.rb', line 181

def sequencing_kit_box_barcode_plate_1
  get_plate(1)&.sequencing_kit_box_barcode
end

#sequencing_kit_box_barcode_plate_2Object

return the sequencing_kit_box_barcode of plate 2 used for 2-plate sample sheets



187
188
189
# File 'app/models/pacbio/well.rb', line 187

def sequencing_kit_box_barcode_plate_2
  get_plate(2)&.sequencing_kit_box_barcode
end

#show_row_per_sample?Boolean

Determines rendering of a row-per sample

Returns:

  • (Boolean)


154
155
156
157
158
# File 'app/models/pacbio/well.rb', line 154

def show_row_per_sample?
  return false if tag_set.hidden_sample_sheet_behaviour?

  base_used_aliquots.any?(&:tag_id?)
end

#summaryObject



56
57
58
# File 'app/models/pacbio/well.rb', line 56

def summary
  "#{sample_names} #{comment}".strip
end

#tag_setTagSet | NullTagSet

Returns the tag set for the first aliquot or null tag set.

Returns:



48
49
50
# File 'app/models/pacbio/well.rb', line 48

def tag_set
  base_used_aliquots.collect(&:tag_set).first || NullTagSet.new
end

#tagged?Boolean

check if any of the aliquots or libraries in the well are tagged a convenience method for the sample sheet

Returns:

  • (Boolean)


80
81
82
# File 'app/models/pacbio/well.rb', line 80

def tagged?
  base_used_aliquots.collect(&:tagged?).any?
end

#tagsObject

a collection of all the tags for a well useful to check whether they are unique



86
87
88
# File 'app/models/pacbio/well.rb', line 86

def tags
  base_used_aliquots.collect(&:tag_id)
end

#template_prep_kit_box_barcodeString

Returns the template_prep_kit_box_barcode of the first aliquot.

Returns:

  • (String)

    the template_prep_kit_box_barcode of the first aliquot



101
102
103
# File 'app/models/pacbio/well.rb', line 101

def template_prep_kit_box_barcode
  base_used_aliquots.first.used_by.template_prep_kit_box_barcode
end

#tube_barcodeObject

Sample Name field



168
169
170
171
# File 'app/models/pacbio/well.rb', line 168

def tube_barcode
  # Gets the first barcode which will either be the pool barcode or the library barcode
  base_used_aliquots.first.used_by.tube.barcode
end

This method is used to update the smrt_link_options for a well It takes a hash of options and updates the smrt_link_options store field with the new values we do a save! at the end to ensure that the changes are persisted it is better to update the smrt link options in the well as it uses a private method

Parameters:

  • options (Hash)

    a hash of options to update



126
127
128
129
130
131
# File 'app/models/pacbio/well.rb', line 126

def update_smrt_link_options(options)
  options.each do |key, value|
    write_store_attribute(:smrt_link_options, key, value)
  end
  save!
end