Class: AliquotIndexer

Inherits:
Object
  • Object
show all
Defined in:
app/models/aliquot_indexer.rb

Overview

The aliquot indexer is passed a Receptacle (usually a Lane) and generates an index for all aliquots. This is a unique index that NPG use to identify deplexed sequencing data. It replaces the previous role of the map id of tag 1 (the i7) and allows a single identifier to be used to represent both indices. - Aliquots are sorted by the tag_2 map id, then the tag_1 map id. - Tags associated with the PhiX tube are excluded. This includes the default phix tag index (configatron.phix_tag.tag_map_id) [888 at time of writing] as well as the actual index if they happen to differ.

Defined Under Namespace

Modules: AliquotScopes, Indexable

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lane) ⇒ AliquotIndexer

Returns a new instance of AliquotIndexer.



43
44
45
46
# File 'app/models/aliquot_indexer.rb', line 43

def initialize(lane)
  @lane = lane
  @index = 0
end

Instance Attribute Details

#aliquotsArray<Aliquot> (readonly)

Returns all aliquots due to be indexed.

Returns:

  • (Array<Aliquot>)

    An sorted array of aliquots to index



60
61
62
# File 'app/models/aliquot_indexer.rb', line 60

def aliquots
  @aliquots
end

#laneObject (readonly)

Returns the value of attribute lane.



14
15
16
# File 'app/models/aliquot_indexer.rb', line 14

def lane
  @lane
end

Class Method Details

.index(lane) ⇒ Bool

Generate an aliquot index for lane

Parameters:

  • lane (Receptacle)

    The receptacle to index. Probably a lane.

Returns:

  • (Bool)

    Returns true if the index was successful



39
40
41
# File 'app/models/aliquot_indexer.rb', line 39

def self.index(lane)
  new(lane).index
end

Instance Method Details

#indexObject



64
65
66
67
# File 'app/models/aliquot_indexer.rb', line 64

def index
  @lane.aliquot_indicies.build(aliquots.map { |a| { aliquot: a, aliquot_index: next_index } })
  @lane.save
end

#phix_map_idInteger

The actual index of the PhiX used in the lane. Note: PhiX isn’t actually present as an aliquot within the lane, instead the PhiX tube is associated with the Lane as a parent asset.

Returns:

  • (Integer)

    map_id of the PhiX in the lane.



52
53
54
55
56
# File 'app/models/aliquot_indexer.rb', line 52

def phix_map_id
  return nil if lane.spiked_in_buffer.blank?

  @phix_map_id ||= lane.spiked_in_buffer.primary_aliquot.tag.try(:map_id)
end