Class: SampleManifest::PlateBehaviour::Base
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.
9
10
11
12
|
# File 'app/models/sample_manifest/plate_behaviour.rb', line 9
def initialize(manifest)
@manifest = manifest
@plates = []
end
|
Instance Attribute Details
#plates ⇒ Object
Returns the value of attribute plates.
7
8
9
|
# File 'app/models/sample_manifest/plate_behaviour.rb', line 7
def plates
@plates
end
|
Instance Method Details
#acceptable_purposes ⇒ Object
27
28
29
|
# File 'app/models/sample_manifest/plate_behaviour.rb', line 27
def acceptable_purposes
PlatePurpose.for_submissions
end
|
#default_purpose ⇒ Object
#details_array ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'app/models/sample_manifest/plate_behaviour.rb', line 58
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
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'app/models/sample_manifest/plate_behaviour.rb', line 14
def generate
@plates = generate_plates(purpose)
sanger_sample_ids = insert_sanger_sample_ids
well_data = build_well_data(sanger_sample_ids)
build_wells_async(well_data)
@details_array = build_details_array(well_data)
@manifest.update!(barcodes: @plates.map(&:human_barcode))
end
|
#included_resources ⇒ Object
35
36
37
|
# File 'app/models/sample_manifest/plate_behaviour.rb', line 35
def included_resources
[{ sample: :sample_metadata, asset: { plate: :barcodes } }]
end
|
#io_samples ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'app/models/sample_manifest/plate_behaviour.rb', line 39
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
76
77
78
|
# File 'app/models/sample_manifest/plate_behaviour.rb', line 76
def labware
plates | Labware.with_barcode(barcodes)
end
|
#labware=(labware) ⇒ Object
71
72
73
|
# File 'app/models/sample_manifest/plate_behaviour.rb', line 71
def labware=(labware)
@plates = labware
end
|
#updated_by!(user, samples) ⇒ Object
52
53
54
55
56
|
# File 'app/models/sample_manifest/plate_behaviour.rb', line 52
def updated_by!(user, samples)
Plate.with_sample(samples).each { |plate| plate.events.updated_using_sample_manifest!(user) }
end
|