Class: SampleManifestExcel::Tags::ExampleData

Inherits:
Object
  • Object
show all
Defined in:
app/sample_manifest_excel/sample_manifest_excel/tags/example_data.rb

Overview

Used for testing purposes. Creates a multidimensional array of tag and tag2 oligos which can be inserted into a download spreadsheet based on row numbers.

Constant Summary collapse

BASES =
%w[A C G T].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeExampleData

Returns a new instance of ExampleData.



14
15
16
# File 'app/sample_manifest_excel/sample_manifest_excel/tags/example_data.rb', line 14

def initialize
  create_products
end

Instance Attribute Details

#i5sObject (readonly)

Returns the value of attribute i5s.



12
13
14
# File 'app/sample_manifest_excel/sample_manifest_excel/tags/example_data.rb', line 12

def i5s
  @i5s
end

#i7sObject (readonly)

Returns the value of attribute i7s.



12
13
14
# File 'app/sample_manifest_excel/sample_manifest_excel/tags/example_data.rb', line 12

def i7s
  @i7s
end

Instance Method Details

#take(first, last, duplicate = false) ⇒ Object

Take a certain section of the data based on the number of rows needed for a particular download. If duplicate is set to true the tags will be invalid for a multiplexed library tube.



23
24
25
26
27
28
# File 'app/sample_manifest_excel/sample_manifest_excel/tags/example_data.rb', line 23

def take(first, last, duplicate = false)
  {}.tap do |hsh|
    (first..last).each_with_index { |n, i| hsh[n] = { i7: i7s[i].join, i5: i5s[i].join } }
    hsh[last] = hsh[first] if duplicate
  end
end

#take_as_groups_and_indexes(first, last, duplicate = false) ⇒ Object

Version of take method for creating Tag group and Index column values for older style multiplex tube manifest uploads. If duplicate is set to true the tag groups and indexes will be invalid for a multiplexed library tube.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/sample_manifest_excel/sample_manifest_excel/tags/example_data.rb', line 35

def take_as_groups_and_indexes(first, last, duplicate = false) # rubocop:todo Metrics/AbcSize
  tag_groups = FactoryBot.create_list(:tag_group, 2, tag_count: (last - first) + 1)

  {}.tap do |hsh|
    (first..last).each_with_index do |n, i|
      hsh[n] = {
        tag_group: tag_groups[0].name,
        tag_index: tag_groups[0].tags[i].map_id.to_s,
        tag2_group: tag_groups[1].name,
        tag2_index: tag_groups[1].tags[i].map_id.to_s
      }
    end
    hsh[last] = hsh[first] if duplicate
  end
end