Class: SampleManifestExcel::Upload::Processor::Base

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model, SequencescapeExcel::SubclassChecker
Defined in:
app/sample_manifest_excel/sample_manifest_excel/upload/processor/base.rb

Overview

Uploads will be processed slightly differently based on the manifest type.

Direct Known Subclasses

LibraryTube, MultiplexedLibraryTube, OneDTube, Plate

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(upload) ⇒ Base

Returns a new instance of Base


19
20
21
# File 'app/sample_manifest_excel/sample_manifest_excel/upload/processor/base.rb', line 19

def initialize(upload)
  @upload = upload
end

Instance Attribute Details

#uploadObject (readonly)

Returns the value of attribute upload


14
15
16
# File 'app/sample_manifest_excel/sample_manifest_excel/upload/processor/base.rb', line 14

def upload
  @upload
end

Instance Method Details

#aliquots_updated?Boolean

Returns:

  • (Boolean)

70
71
72
73
74
# File 'app/sample_manifest_excel/sample_manifest_excel/upload/processor/base.rb', line 70

def aliquots_updated?
  downstream_aliquots_updated? ||
    no_substitutions? ||
    log_error_and_return_false('Could not update tags in other assets.')
end

#downstream_aliquots_updated?Boolean

Returns:

  • (Boolean)

66
67
68
# File 'app/sample_manifest_excel/sample_manifest_excel/upload/processor/base.rb', line 66

def downstream_aliquots_updated?
  @downstream_aliquots_updated
end

#processed?Boolean

Returns:

  • (Boolean)

44
45
46
# File 'app/sample_manifest_excel/sample_manifest_excel/upload/processor/base.rb', line 44

def processed?
  samples_updated? && sample_manifest_updated? && aliquots_updated?
end

#run(tag_group) ⇒ Object

If the processor is valid the samples and manifest are updated.


25
26
27
28
29
30
# File 'app/sample_manifest_excel/sample_manifest_excel/upload/processor/base.rb', line 25

def run(tag_group)
  return unless valid?

  update_samples_and_aliquots(tag_group)
  update_sample_manifest
end

#sample_manifest_updated?Boolean

Returns:

  • (Boolean)

54
55
56
# File 'app/sample_manifest_excel/sample_manifest_excel/upload/processor/base.rb', line 54

def sample_manifest_updated?
  @sample_manifest_updated
end

#samples_updated?Boolean

Returns:

  • (Boolean)

40
41
42
# File 'app/sample_manifest_excel/sample_manifest_excel/upload/processor/base.rb', line 40

def samples_updated?
  upload.rows.all?(&:sample_skipped_or_updated?) || log_error_and_return_false('Could not update samples')
end

#substitutionsObject


62
63
64
# File 'app/sample_manifest_excel/sample_manifest_excel/upload/processor/base.rb', line 62

def substitutions
  @substitutions ||= []
end

#typeObject


58
59
60
# File 'app/sample_manifest_excel/sample_manifest_excel/upload/processor/base.rb', line 58

def type
  self.class.to_s
end

#update_sample_manifestObject

Override the sample manifest with the raw uploaded data.


50
51
52
# File 'app/sample_manifest_excel/sample_manifest_excel/upload/processor/base.rb', line 50

def update_sample_manifest
  @sample_manifest_updated = upload.sample_manifest.update(uploaded: upload.file)
end

#update_samples_and_aliquots(tag_group) ⇒ Object


32
33
34
35
36
37
38
# File 'app/sample_manifest_excel/sample_manifest_excel/upload/processor/base.rb', line 32

def update_samples_and_aliquots(tag_group)
  upload.rows.each do |row|
    row.update_sample(tag_group, upload.override)
    substitutions << row.aliquot.substitution_hash if row.reuploaded?
  end
  update_downstream_aliquots unless no_substitutions?
end