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


70
71
72
# File 'lib/working_setup/standard_seeder.rb', line 70

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

#plates_of_purpose(name, number) ⇒ Object


45
46
47
48
49
50
51
52
53
# File 'lib/working_setup/standard_seeder.rb', line 45

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

#projectObject


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

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

#seedObject


35
36
37
38
39
40
41
42
43
# File 'lib/working_setup/standard_seeder.rb', line 35

def seed
  sample_registrar
  Sample.all.each { |s| study_b.samples << s }
  create_purposes

  Robot.create!(name: 'Picking robot', location: 'In a lab').tap do |robot|
    robot.create_max_plates_property(value: 10)
  end
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


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

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


55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/working_setup/standard_seeder.rb', line 55

def tag_plates(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


74
75
76
# File 'lib/working_setup/standard_seeder.rb', line 74

def user
  @user ||= create_or_find_user
end