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 Attribute Summary collapse

Instance Method Summary collapse

Methods included from Aliquotable

#used_aliquots_volume

Methods included from Uuidable

#add_uuid

Instance Attribute Details

#annotations_attributesObject (readonly)

Returns the value of attribute annotations_attributes.



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

def annotations_attributes
  @annotations_attributes
end

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



122
123
124
# File 'app/models/pacbio/well.rb', line 122

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



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

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



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

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



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

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



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

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



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

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)


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

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.



229
230
231
# File 'app/models/pacbio/well.rb', line 229

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



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

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



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

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



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

def libraries?
  libraries.present?
end

#plate_well_positionObject

Sample Plate Well field



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

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



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

def pools?
  pools.present?
end

#positionObject



58
59
60
# File 'app/models/pacbio/well.rb', line 58

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

#position_leading_zeroObject

Sample Well field



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

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)


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

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



207
208
209
# File 'app/models/pacbio/well.rb', line 207

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.



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

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



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

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



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

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



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

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)


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

def show_row_per_sample?
  return false if tag_set.hidden_sample_sheet_behaviour?

  base_used_aliquots.any?(&:tag_id?)
end

#summaryObject



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

def summary
  sample_names.to_s
end

#tag_setTagSet | NullTagSet

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

Returns:



54
55
56
# File 'app/models/pacbio/well.rb', line 54

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)


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

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



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

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



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

def template_prep_kit_box_barcode
  base_used_aliquots.first.used_by.template_prep_kit_box_barcode
end

#tube_barcodeObject

Sample Name field



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

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



132
133
134
135
136
137
# File 'app/models/pacbio/well.rb', line 132

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