Class: SampleManifest::PlateBehaviour::Base
Overview
rubocop:todo Style/Documentation
Instance Attribute Summary collapse
Instance Method Summary
collapse
#specialized_fields, #validate_specialized_fields
#details, #generate_sanger_ids, included
Constructor Details
#initialize(manifest) ⇒ Base
Returns a new instance of Base.
8
9
10
11
|
# File 'app/models/sample_manifest/plate_behaviour.rb', line 8
def initialize(manifest)
@manifest = manifest
@plates = []
end
|
Instance Attribute Details
#plates ⇒ Object
Returns the value of attribute plates
6
7
8
|
# File 'app/models/sample_manifest/plate_behaviour.rb', line 6
def plates
@plates
end
|
Instance Method Details
#acceptable_purposes ⇒ Object
17
18
19
|
# File 'app/models/sample_manifest/plate_behaviour.rb', line 17
def acceptable_purposes
PlatePurpose.for_submissions
end
|
#default_purpose ⇒ Object
#details_array ⇒ Object
74
75
76
77
78
79
80
81
82
83
|
# File 'app/models/sample_manifest/plate_behaviour.rb', line 74
def details_array
@details_array ||= sample_manifest_assets.includes(asset: [:map, :aliquots,
{ plate: :barcodes }]).map do |sample_manifest_asset|
{
barcode: sample_manifest_asset.asset.plate.human_barcode,
position: sample_manifest_asset.asset.map_description,
sample_id: sample_manifest_asset.sanger_sample_id
}
end
end
|
#generate ⇒ Object
13
14
15
|
# File 'app/models/sample_manifest/plate_behaviour.rb', line 13
def generate
@plates = generate_plates(purpose)
end
|
#generate_wells(well_data, plates) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'app/models/sample_manifest/plate_behaviour.rb', line 29
def generate_wells(well_data, plates)
generate_wells_for_plates(well_data, plates) do |this_plates_well_data, plate|
generate_wells_asynchronously(
this_plates_well_data.map { |map, sample_id| [map.id, sample_id] },
plate.id
)
end
@plates = plates.sort_by(&:human_barcode)
@details_array = plates.flat_map do |plate|
well_data.slice!(0, plate.size).map do |map, sample_id|
{
barcode: plate.human_barcode,
position: map.description,
sample_id: sample_id
}
end
end
end
|
#generate_wells_job(wells_for_plate, plate) ⇒ Object
Called by GenerateWellsJob and builds the wells
96
97
98
99
100
101
102
103
104
105
106
|
# File 'app/models/sample_manifest/plate_behaviour.rb', line 96
def generate_wells_job(wells_for_plate, plate)
wells_for_plate.map do |map, sanger_sample_id|
plate.wells.create!(map: map) do |well|
SampleManifestAsset.create(sanger_sample_id: sanger_sample_id,
asset: well,
sample_manifest: @manifest)
end
end
RequestFactory.create_assets_requests(plate.wells, study)
plate.events.created_using_sample_manifest!(@manifest.user)
end
|
#included_resources ⇒ Object
25
26
27
|
# File 'app/models/sample_manifest/plate_behaviour.rb', line 25
def included_resources
[{ sample: :sample_metadata, asset: { plate: :barcodes } }]
end
|
#io_samples ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'app/models/sample_manifest/plate_behaviour.rb', line 53
def io_samples
samples.map do |sample|
container = sample.primary_receptacle
{
sample: sample,
container: {
barcode: container.plate.human_barcode,
position: container.map.description.sub(/^([^\d]+)(\d)$/, '\10\2')
}
}
end
end
|
#labware ⇒ Object
Also known as:
printables
We use the barcodes here as we may need to reference the plates before the delayed job has passed
90
91
92
|
# File 'app/models/sample_manifest/plate_behaviour.rb', line 90
def labware
plates | labware_from_barcodes
end
|
#labware=(labware) ⇒ Object
85
86
87
|
# File 'app/models/sample_manifest/plate_behaviour.rb', line 85
def labware=(labware)
@plates = labware
end
|
#updated_by!(user, samples) ⇒ Object
66
67
68
69
70
71
72
|
# File 'app/models/sample_manifest/plate_behaviour.rb', line 66
def updated_by!(user, samples)
Plate.with_sample(samples).each do |plate|
plate.events.updated_using_sample_manifest!(user)
end
end
|