Class: Pipeline::BSI::Importer::AddBatch
Instance Attribute Summary collapse
#client, #id, #properties, #specimens
Instance Method Summary
collapse
Constructor Details
#initialize(client, batch_properties) ⇒ AddBatch
Returns a new instance of AddBatch.
19
20
21
|
# File 'lib/bsi-pipeline/importer.rb', line 19
def initialize(client, batch_properties)
super client, 'A', batch_properties
end
|
Instance Attribute Details
#seminal_parents ⇒ Object
Returns the value of attribute seminal_parents.
17
18
19
|
# File 'lib/bsi-pipeline/importer.rb', line 17
def seminal_parents
@seminal_parents
end
|
Instance Method Details
#add_specimens(specimens) ⇒ Object
27
28
29
30
31
32
|
# File 'lib/bsi-pipeline/importer.rb', line 27
def add_specimens(specimens)
@specimens = specimens
format
@bsi.batch.addVials( @id, @specimens.map{ |s| s.to_bfh } )
nil
end
|
#commit ⇒ Object
76
77
78
|
# File 'lib/bsi-pipeline/importer.rb', line 76
def commit
@bsi.batch.commit(@id)
end
|
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/bsi-pipeline/importer.rb', line 34
def format
num_seminal_parents = @specimens.map{|s| [s.date_drawn, s.specimen_type]}.uniq.length
fails = 0
begin
@sample_id_pool = @bsi.batch.reserveAvailableBsiIds( @id, 'LAA000000', num_seminal_parents ).map{|i| i[0..-6]} if num_seminal_parents > 0
rescue NoMethodError
fails += 1
retry if fails < 3
end
collection_dates = @specimens.map{|s| s.date_drawn}.uniq
specimen_types = @specimens.map{|s| s.specimen_type}.uniq
collection_dates.each do |date|
specimen_types.each do |type|
specimen_family = @specimens.select{|s| s.date_drawn == date && s.specimen_type == type}
family_sample_id = @sample_id_pool.pop
specimen_family.each_with_index do |spec, i|
spec.sample_id = family_sample_id
unless specimen_family.length == 1
spec.sequence = i+1
else
spec.sequence = 0
end
end
end
end
end
|
73
74
|
# File 'lib/bsi-pipeline/importer.rb', line 73
def perform_edit_checks
end
|
#type ⇒ Object
23
24
25
|
# File 'lib/bsi-pipeline/importer.rb', line 23
def type
'Add'
end
|