Class: SequencingPipeline

Inherits:
Pipeline show all
Defined in:
app/models/sequencing_pipeline.rb

Constant Summary

Constants inherited from Pipeline

Pipeline::ALWAYS_SHOW_RELEASE_ACTIONS

Instance Method Summary collapse

Methods inherited from Pipeline

#all_requests_from_submissions_selected?, #allow_tag_collision_on_tagging_task?, #completed_request_as_part_of_release_batch, #extract_requests_from_input_params, #has_controls?, #input_labware, #output_labware, #post_finish_batch, #request_types_including_controls, #robot_verified!, #update_detached_request

Methods included from SharedBehaviour::Named

included

Methods included from Pipeline::BatchValidation

#validation_of_batch, #validation_of_batch_for_completion

Methods included from Uuid::Uuidable

included, #unsaved_uuid!, #uuid

Methods inherited from ApplicationRecord

convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!

Methods included from Warren::BroadcastMessages

#broadcast, included, #queue_associated_for_broadcast, #queue_for_broadcast, #warren

Instance Method Details

#detach_request_from_batch(batch, request) ⇒ Object

The guys in sequencing want to be able to re-run a request in another batch. What we've agreed is that the request will be failed and then an identical request will be resubmitted to their inbox. The “failed” request should not be charged for.


45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/models/sequencing_pipeline.rb', line 45

def detach_request_from_batch(batch, request)
  request.fail!

  # Note that the request metadata also needs to be cloned for this to work.
  ActiveRecord::Base.transaction do
    request.dup.tap do |request_clone|
      rma = request..attributes.merge(request: request_clone)
      request_clone.update!(state: 'pending', target_asset_id: nil, request_metadata_attributes: rma)
      request_clone.comments.create!(description: "Automatically created clone of request #{request.id} which was removed from Batch #{batch.id} at #{DateTime.now}")
      request.comments.create!(description: "The request #{request_clone.id} is an automatically created clone of this one")
    end
  end
end

#is_read_length_consistent_for_batch?(batch) ⇒ Boolean

Returns:

  • (Boolean)

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/models/sequencing_pipeline.rb', line 23

def is_read_length_consistent_for_batch?(batch)
  if (batch.requests.size == 0) || (batch.requests.first..nil?)
    # No requests selected or the pipeline doesn't contain metadata to check
    return true
  end

  read_length_list = batch.requests.map { |request|
    request..read_length
  }.compact

  # The pipeline doen't contain the read_length attribute
  return true if read_length_list.size == 0

  # There are some requests that don't have the read_length_attribute
  return false if read_length_list.size != batch.requests.size

  (read_length_list.uniq.size == 1)
end

#on_start_batch(batch, user) ⇒ Object


59
60
61
# File 'app/models/sequencing_pipeline.rb', line 59

def on_start_batch(batch, user)
  BroadcastEvent::SequencingStart.create!(seed: batch, user: user, properties: {}, created_at: DateTime.now)
end

#post_release_batch(batch, _user) ⇒ Object


63
64
65
66
67
68
69
70
# File 'app/models/sequencing_pipeline.rb', line 63

def post_release_batch(batch, _user)
  # We call compact to handle ControlRequests which may have no target asset.
  # In practice this isn't required, as we don't use control lanes any more.
  # However some old feature tests still use them, and until this behaviour is completely
  # deprecated we should leave it here.
  batch.assets.compact.uniq.each(&:index_aliquots)
  Messenger.create!(target: batch, template: 'FlowcellIO', root: 'flowcell')
end

#request_actionsObject


19
20
21
# File 'app/models/sequencing_pipeline.rb', line 19

def request_actions
  [:remove]
end