Class: ReceptionGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/tasks/reception_generator.rb

Overview

Used to generate test data for a given pipeline

Instance Method Summary collapse

Constructor Details

#initialize(number_of_plates:, number_of_tubes:, wells_per_plate:, pipeline:) ⇒ ReceptionGenerator

Returns a new instance of ReceptionGenerator.



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/tasks/reception_generator.rb', line 7

def initialize(number_of_plates:, number_of_tubes:, wells_per_plate:, pipeline:)
  @number_of_plates = number_of_plates
  @number_of_tubes = number_of_tubes
  @wells_per_plate = wells_per_plate
  @pipeline = pipeline
  @timestamp = Time.now.to_i
  @library_types = LibraryType.where(pipeline: @pipeline).pluck(:name).cycle
  @data_types = DataType.where(pipeline: @pipeline).pluck(:name).cycle
  @sample_names = (1..).lazy.map { |id| "GENSAMPLE-#{@timestamp}-#{id}" }
  @barcodes = (1..).lazy.map { |bc| "GEN-#{@timestamp}-#{bc}" }
  @well_positions = (1..12).flat_map { |r| ('A'..'H').map { |c| "#{c}#{r}" } }
end

Instance Method Details

#construct_resources!Object



20
21
22
23
24
# File 'lib/tasks/reception_generator.rb', line 20

def construct_resources!
  # Ensure we've loaded our factories.
  FactoryBot.reload if FactoryBot.factories.count == 0
  reception.construct_resources!
end

#receptionObject



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/tasks/reception_generator.rb', line 26

def reception
  @reception ||= Reception.create!(
    source: 'traction-service.rake-task',
    plates_attributes: [
      *plates
    ],
    tubes_attributes: [
      *tubes
    ]
  )
end