Class: SampleManifest::GenerateWellsJob
- Inherits:
-
Struct
- Object
- Struct
- SampleManifest::GenerateWellsJob
- Defined in:
- app/jobs/sample_manifest/generate_wells_job.rb
Overview
Generates wells and sample manifest assets, for a plate sample manifest.
Instance Attribute Summary collapse
-
#map_ids_to_sanger_sample_ids ⇒ Object
Returns the value of attribute map_ids_to_sanger_sample_ids.
-
#plate_id ⇒ Object
Returns the value of attribute plate_id.
-
#sample_manifest_id ⇒ Object
Returns the value of attribute sample_manifest_id.
Instance Method Summary collapse
- #create_sample_manifest_assets(well, sanger_sample_ids) ⇒ Object
- #create_well(map_id, sanger_sample_ids) ⇒ Object
- #perform ⇒ Object
- #plate ⇒ Object
- #sample_manifest ⇒ Object
Instance Attribute Details
#map_ids_to_sanger_sample_ids ⇒ Object
Returns the value of attribute map_ids_to_sanger_sample_ids
3 4 5 |
# File 'app/jobs/sample_manifest/generate_wells_job.rb', line 3 def map_ids_to_sanger_sample_ids @map_ids_to_sanger_sample_ids end |
#plate_id ⇒ Object
Returns the value of attribute plate_id
3 4 5 |
# File 'app/jobs/sample_manifest/generate_wells_job.rb', line 3 def plate_id @plate_id end |
#sample_manifest_id ⇒ Object
Returns the value of attribute sample_manifest_id
3 4 5 |
# File 'app/jobs/sample_manifest/generate_wells_job.rb', line 3 def sample_manifest_id @sample_manifest_id end |
Instance Method Details
#create_sample_manifest_assets(well, sanger_sample_ids) ⇒ Object
23 24 25 26 27 |
# File 'app/jobs/sample_manifest/generate_wells_job.rb', line 23 def create_sample_manifest_assets(well, sanger_sample_ids) sanger_sample_ids.each do |sanger_sample_id| SampleManifestAsset.create(sanger_sample_id: sanger_sample_id, asset: well, sample_manifest: sample_manifest) end end |
#create_well(map_id, sanger_sample_ids) ⇒ Object
15 16 17 |
# File 'app/jobs/sample_manifest/generate_wells_job.rb', line 15 def create_well(map_id, sanger_sample_ids) plate.wells.create!(map: Map.find(map_id)) { |well| create_sample_manifest_assets(well, sanger_sample_ids) } end |
#perform ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'app/jobs/sample_manifest/generate_wells_job.rb', line 5 def perform ActiveRecord::Base.transaction do map_ids_to_sanger_sample_ids.each { |map_id, sanger_sample_id| create_well(map_id, sanger_sample_id) } RequestFactory.create_assets_requests(plate.wells, sample_manifest.study) plate.events.created_using_sample_manifest!(sample_manifest.user) end end |
#plate ⇒ Object
19 20 21 |
# File 'app/jobs/sample_manifest/generate_wells_job.rb', line 19 def plate Plate.find(plate_id) end |
#sample_manifest ⇒ Object
29 30 31 |
# File 'app/jobs/sample_manifest/generate_wells_job.rb', line 29 def sample_manifest SampleManifest.find(sample_manifest_id) end |