Class: SampleManifest::MultiplexedLibraryBehaviour::Core

Inherits:
SharedTubeBehaviour::Base show all
Includes:
CoreBehaviour::LibraryAssets
Defined in:
app/models/sample_manifest/multiplexed_library_behaviour.rb

Constant Summary collapse

MxLibraryTubeException =

for #multiplexed_library_tube

Class.new(ActiveRecord::RecordNotFound)

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from CoreBehaviour::LibraryAssets

#generate_sample_and_aliquot, #stocks?

Methods inherited from SharedTubeBehaviour::Base

#details_array, #updated_by!

Methods included from CoreBehaviour::Shared

#details, #generate_sanger_ids, included

Constructor Details

#initialize(manifest) ⇒ Core

Returns a new instance of Core.



11
12
13
# File 'app/models/sample_manifest/multiplexed_library_behaviour.rb', line 11

def initialize(manifest)
  @manifest = manifest
end

Instance Attribute Details

#library_tubesObject

Returns the value of attribute library_tubes.



9
10
11
# File 'app/models/sample_manifest/multiplexed_library_behaviour.rb', line 9

def library_tubes
  @library_tubes
end

Instance Method Details

#acceptable_purposesObject



38
39
40
# File 'app/models/sample_manifest/multiplexed_library_behaviour.rb', line 38

def acceptable_purposes
  Purpose.none
end

#default_purposeObject



42
43
44
# File 'app/models/sample_manifest/multiplexed_library_behaviour.rb', line 42

def default_purpose
  Tube::Purpose.standard_library_tube
end

#generateObject



15
16
17
18
# File 'app/models/sample_manifest/multiplexed_library_behaviour.rb', line 15

def generate
  @library_tubes = generate_tubes(Tube::Purpose.standard_library_tube)
  @mx_tube = generate_mx_library
end

#generate_mx_libraryObject



20
21
22
23
24
# File 'app/models/sample_manifest/multiplexed_library_behaviour.rb', line 20

def generate_mx_library
  Tube::Purpose.standard_mx_tube.create!.tap do |mx_tube|
    RequestFactory.create_external_multiplexed_library_creation_requests(@library_tubes, mx_tube, study)
  end
end

#included_resourcesObject



76
77
78
# File 'app/models/sample_manifest/multiplexed_library_behaviour.rb', line 76

def included_resources
  [{ sample: :sample_metadata, asset: [:barcodes, :aliquots, { requests: :target_asset }] }]
end

#io_samplesObject



26
27
28
29
30
31
32
33
34
35
36
# File 'app/models/sample_manifest/multiplexed_library_behaviour.rb', line 26

def io_samples
  samples.map do |sample|
    {
      sample: sample,
      container: {
        barcode: sample.primary_receptacle.human_barcode
      },
      library_information: sample.primary_receptacle.library_information
    }
  end
end

#labwareObject



68
69
70
# File 'app/models/sample_manifest/multiplexed_library_behaviour.rb', line 68

def labware
  [multiplexed_library_tube]
end

#labware=(labware) ⇒ Object

Raises:

  • (ArgumentError)


62
63
64
65
66
# File 'app/models/sample_manifest/multiplexed_library_behaviour.rb', line 62

def labware=(labware)
  raise ArgumentError, 'labware should contain only one element' if labware.count > 1

  @mx_tube = labware.first
end

#multiplexed_library_tubeObject



46
47
48
# File 'app/models/sample_manifest/multiplexed_library_behaviour.rb', line 46

def multiplexed_library_tube
  mx_tube || raise(MxLibraryTubeException.new, 'Mx tube not found')
end

#mx_tubeObject



50
51
52
# File 'app/models/sample_manifest/multiplexed_library_behaviour.rb', line 50

def mx_tube
  @mx_tube ||= mx_tube_from_manifest_asset
end

#mx_tube_from_manifest_assetObject



54
55
56
# File 'app/models/sample_manifest/multiplexed_library_behaviour.rb', line 54

def mx_tube_from_manifest_asset
  @manifest.assets.first&.external_library_creation_requests&.first&.target_asset
end

#pending_external_library_creation_requestsObject



58
59
60
# File 'app/models/sample_manifest/multiplexed_library_behaviour.rb', line 58

def pending_external_library_creation_requests
  multiplexed_library_tube.requests_as_target.for_state('pending')
end

#printablesObject



72
73
74
# File 'app/models/sample_manifest/multiplexed_library_behaviour.rb', line 72

def printables
  multiplexed_library_tube.labware
end