Class: WorkingSetup::StandardSeeder

Inherits:
Object
  • Object
show all
Defined in:
lib/working_setup/standard_seeder.rb

Overview

Class WorkingSetup::WorkingSetupSeeder provides tools to assist with automatic creation of plates etc. for development

Author:

  • Genome Research Ltd.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(purposes = []) ⇒ StandardSeeder

Returns a new instance of StandardSeeder.



14
15
16
17
# File 'lib/working_setup/standard_seeder.rb', line 14

def initialize(purposes = [])
  @program = Program.find_or_create_by!(name: 'General')
  @purposes = purposes
end

Instance Attribute Details

#programObject (readonly)

Returns the value of attribute program.



12
13
14
# File 'lib/working_setup/standard_seeder.rb', line 12

def program
  @program
end

Instance Method Details

#create_purposesObject

rubocop:enable Metrics/AbcSize



89
90
91
# File 'lib/working_setup/standard_seeder.rb', line 89

def create_purposes
  @purposes.each { |options| plates_of_purpose(*options) }
end

#phi_x_studyObject



27
28
29
# File 'lib/working_setup/standard_seeder.rb', line 27

def phi_x_study
  create_study(PhiX.configuration[:default_study_option])
end

#plates_of_purpose(name, number) ⇒ Object

rubocop:todo Metrics/AbcSize



48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/working_setup/standard_seeder.rb', line 48

def plates_of_purpose(name, number) # rubocop:todo Metrics/AbcSize
  purpose = Purpose.find_by!(name:)
  number.times do
    purpose.create!.tap do |plate|
      plate.wells.each do |w|
        w.aliquots.create!(
          sample:
            Sample.create!(name: "sample_#{plate.human_barcode}_#{w.map.description}", studies: [study, study_b])
        )
      end
      puts "#{name}: #{plate.ean13_barcode}-#{plate.human_barcode}"
    end
  end
end

#projectObject



31
32
33
# File 'lib/working_setup/standard_seeder.rb', line 31

def project
  @project ||= create_project('A project')
end

#seedObject



39
40
41
42
43
44
45
46
# File 'lib/working_setup/standard_seeder.rb', line 39

def seed
  Sample.find_each { |s| study_b.samples << s }
  create_purposes

  Robot
    .create!(name: 'Picking robot', location: 'In a lab')
    .tap { |robot| robot.create_max_plates_property(value: 10) }
end

#studyObject



19
20
21
# File 'lib/working_setup/standard_seeder.rb', line 19

def study
  @study ||= create_study('A study')
end

#study_bObject



23
24
25
# File 'lib/working_setup/standard_seeder.rb', line 23

def study_b
  @study_b ||= create_study('B study')
end

#supplierObject



35
36
37
# File 'lib/working_setup/standard_seeder.rb', line 35

def supplier
  Supplier.find_or_create_by!(name: 'Test Supplier')
end

#tag_plates(lot_type: 'IDT Tags', template: 'Sanger_168tags - 10 mer tags in columns ignoring pools (first oligo: ATCACGTT)', size: 30) ⇒ Object

rubocop:todo Metrics/AbcSize



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/working_setup/standard_seeder.rb', line 64

def tag_plates( # rubocop:todo Metrics/MethodLength
  lot_type: 'IDT Tags',
  template: 'Sanger_168tags - 10 mer tags in columns ignoring pools (first oligo: ATCACGTT)',
  size: 30
)
  puts 'Setting up tag plates...'
  lot =
    LotType
      .find_by!(name: lot_type)
      .lots
      .create!(
        lot_number: Time.current.to_i.to_s,
        template: TagLayoutTemplate.find_by!(name: template),
        user: user,
        received_at: Time.current
      )
  qcc = QcableCreator.create!(lot: lot, user: user, count: size)
  qcc.qcables.each do |qcable|
    qcable.update!(state: 'available')
    puts "Tag Plate: #{qcable.asset.ean13_barcode}"
  end
end

#userObject



93
94
95
# File 'lib/working_setup/standard_seeder.rb', line 93

def user
  @user ||= create_or_find_user
end