Class: SampleManifest::GenerateWellsJob

Inherits:
Struct
  • Object
show all
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

Instance Method Summary collapse

Instance Attribute Details

#map_ids_to_sanger_sample_idsObject

Returns the value of attribute map_ids_to_sanger_sample_ids

Returns:

  • (Object)

    the current value of 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_idObject

Returns the value of attribute plate_id

Returns:

  • (Object)

    the current value of plate_id



3
4
5
# File 'app/jobs/sample_manifest/generate_wells_job.rb', line 3

def plate_id
  @plate_id
end

#sample_manifest_idObject

Returns the value of attribute sample_manifest_id

Returns:

  • (Object)

    the current value of 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

#performObject



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

#plateObject



19
20
21
# File 'app/jobs/sample_manifest/generate_wells_job.rb', line 19

def plate
  Plate.find(plate_id)
end

#sample_manifestObject



29
30
31
# File 'app/jobs/sample_manifest/generate_wells_job.rb', line 29

def sample_manifest
  SampleManifest.find(sample_manifest_id)
end