Class: SampleManifest::MultiplexedLibraryBehaviour::Core

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

Overview

rubocop:todo Style/Documentation

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

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.


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

def initialize(manifest)
  @manifest = manifest
end

Instance Attribute Details

#library_tubesObject

Returns the value of attribute library_tubes


7
8
9
# File 'app/models/sample_manifest/multiplexed_library_behaviour.rb', line 7

def library_tubes
  @library_tubes
end

Instance Method Details

#acceptable_purposesObject


36
37
38
# File 'app/models/sample_manifest/multiplexed_library_behaviour.rb', line 36

def acceptable_purposes
  Purpose.none
end

#default_purposeObject


40
41
42
# File 'app/models/sample_manifest/multiplexed_library_behaviour.rb', line 40

def default_purpose
  Tube::Purpose.standard_library_tube
end

#generateObject


13
14
15
16
# File 'app/models/sample_manifest/multiplexed_library_behaviour.rb', line 13

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

#generate_mx_libraryObject


18
19
20
21
22
# File 'app/models/sample_manifest/multiplexed_library_behaviour.rb', line 18

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


74
75
76
# File 'app/models/sample_manifest/multiplexed_library_behaviour.rb', line 74

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

#io_samplesObject


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

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


66
67
68
# File 'app/models/sample_manifest/multiplexed_library_behaviour.rb', line 66

def labware
  [multiplexed_library_tube]
end

#labware=(labware) ⇒ Object

Raises:

  • (ArgumentError)

60
61
62
63
64
# File 'app/models/sample_manifest/multiplexed_library_behaviour.rb', line 60

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

  @mx_tube = labware.first
end

#multiplexed_library_tubeObject


44
45
46
# File 'app/models/sample_manifest/multiplexed_library_behaviour.rb', line 44

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

#mx_tubeObject


48
49
50
# File 'app/models/sample_manifest/multiplexed_library_behaviour.rb', line 48

def mx_tube
  @mx_tube ||= mx_tube_from_manifest_asset
end

#mx_tube_from_manifest_assetObject


52
53
54
# File 'app/models/sample_manifest/multiplexed_library_behaviour.rb', line 52

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

#pending_external_library_creation_requestsObject


56
57
58
# File 'app/models/sample_manifest/multiplexed_library_behaviour.rb', line 56

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

#printablesObject


70
71
72
# File 'app/models/sample_manifest/multiplexed_library_behaviour.rb', line 70

def printables
  multiplexed_library_tube.labware
end