Class: WorkingSetup::StandardSeeder
- Inherits:
-
Object
- Object
- WorkingSetup::StandardSeeder
- Defined in:
- lib/working_setup/standard_seeder.rb
Overview
Class WorkingSetup::WorkingSetupSeeder provides tools to assist with automatic creation of plates etc. for development
Instance Attribute Summary collapse
-
#program ⇒ Object
readonly
Returns the value of attribute program.
Instance Method Summary collapse
-
#create_purposes ⇒ Object
rubocop:enable Metrics/AbcSize.
-
#initialize(purposes = []) ⇒ StandardSeeder
constructor
A new instance of StandardSeeder.
- #phi_x_study ⇒ Object
-
#plates_of_purpose(name, number) ⇒ Object
rubocop:todo Metrics/AbcSize.
- #project ⇒ Object
- #seed ⇒ Object
- #study ⇒ Object
- #study_b ⇒ Object
- #supplier ⇒ Object
-
#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.
- #user ⇒ Object
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
#program ⇒ Object (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_purposes ⇒ Object
rubocop:enable Metrics/AbcSize
89 90 91 |
# File 'lib/working_setup/standard_seeder.rb', line 89 def create_purposes @purposes.each { || plates_of_purpose(*) } end |
#phi_x_study ⇒ Object
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.}_#{w.map.description}", studies: [study, study_b]) ) end puts "#{name}: #{plate.}-#{plate.}" end end end |
#project ⇒ Object
31 32 33 |
# File 'lib/working_setup/standard_seeder.rb', line 31 def project @project ||= create_project('A project') end |
#seed ⇒ Object
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 |
#study ⇒ Object
19 20 21 |
# File 'lib/working_setup/standard_seeder.rb', line 19 def study @study ||= create_study('A study') end |
#study_b ⇒ Object
23 24 25 |
# File 'lib/working_setup/standard_seeder.rb', line 23 def study_b @study_b ||= create_study('B study') end |
#supplier ⇒ Object
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.}" end end |
#user ⇒ Object
93 94 95 |
# File 'lib/working_setup/standard_seeder.rb', line 93 def user @user ||= create_or_find_user end |