Module: Pipelines

Defined in:
app/pipelines/pipelines.rb,
app/pipelines/pipelines/configuration.rb

Overview

Pipelines A Pipeline is a series of steps that are required to prepare sample material for sequencing

Defined Under Namespace

Classes: Configuration

Constant Summary collapse

NAMES =

In a number of models we associate records with a pipeline, via an enum In order to maintain consistent numbering, this has been pulled out into a constant. Please do not remove entries from this list, as it could result in legacy data being reassigned to the incorrect pipelines

Note: Saphyr is deprecated. This is still kept as legacy data in this hash.

{ pacbio: 0, ont: 1, saphyr: 2, qc_result: 3, reception: 4, extraction: 5, sample_qc: 6,
hic: 7, bio_nano: 8 }.freeze
HANDLERS =
{
  pacbio: Pacbio,
  ont: Ont,
  qc_result: QcResult
}.with_indifferent_access.freeze
PIPELINES_DIR =
'config/pipelines'

Class Method Summary collapse

Class Method Details

.configurationObject

memoization. Will load configuration on first use



67
68
69
# File 'app/pipelines/pipelines.rb', line 67

def self.configuration
  @configuration ||= Configuration.new(load_yaml)
end

.configure(pipelines) ⇒ Object

Creates a configuration instance which is attached to the module as a class method e.g. Pipelines.pacbio configuration not necessary for production but useful to reload configuration for transparency purposes

Parameters:

  • pipelines (Hash)

    list of all the pipelines with their respective



39
40
41
42
43
44
45
# File 'app/pipelines/pipelines.rb', line 39

def self.configure(pipelines)
  Configuration.new(pipelines).tap do |configuration|
    configuration.pipelines.each do |pipeline|
      self.class.send(:define_method, pipeline, proc { configuration.send(pipeline) })
    end
  end
end

.find(pipeline) ⇒ Object

Finds the pipeline configuration module based on its name synctatic sugar for send

Parameters:

  • pipeline (String)

    name of the pipeline to be found



50
51
52
# File 'app/pipelines/pipelines.rb', line 50

def self.find(pipeline)
  send(pipeline.to_s.downcase)
end

.handler(pipeline) ⇒ Object



22
23
24
25
26
# File 'app/pipelines/pipelines.rb', line 22

def self.handler(pipeline)
  HANDLERS.fetch(pipeline) do
    raise "Unknown pipeline #{pipeline}"
  end
end

.load_yamlObject

Load config files that match the name of a pipeline and merge them into the config hash



55
56
57
58
59
60
61
62
63
64
# File 'app/pipelines/pipelines.rb', line 55

def self.load_yaml
  config = {}
  Dir.glob("#{PIPELINES_DIR}/*.yml").each do |pipeline_file|
    pipeline_name = File.basename(pipeline_file, '.*')
    next unless NAMES.keys.include?(pipeline_name.to_sym)

    config.merge!(YAML.load_file(pipeline_file, aliases: true)[Rails.env].symbolize_keys)
  end
  config
end