Class: Limber::Helper::TemplateConstructor

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
lib/limber/helper.rb

Overview

Construct submission templates for the Limber pipeline

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#catalogueObject

The following are optional and change the range of submission templates constructed.



31
32
33
# File 'lib/limber/helper.rb', line 31

def catalogue
  @catalogue
end

#cherrypicked=(value) ⇒ Object (writeonly)

Sets the attribute cherrypicked

Parameters:

  • value

    the value to set the attribute cherrypicked to.



32
33
34
# File 'lib/limber/helper.rb', line 32

def cherrypicked=(value)
  @cherrypicked = value
end

#nameObject



56
57
58
# File 'lib/limber/helper.rb', line 56

def name
  @name || prefix
end

#pipelineString

Prefix before submission template names. Defaults to PIPELINE

Returns:

  • (String)

    Prefix before submission template names.



73
74
75
# File 'lib/limber/helper.rb', line 73

def pipeline
  @pipeline || PIPELINE
end

#prefixObject

The following are optional and change the range of submission templates constructed.



31
32
33
# File 'lib/limber/helper.rb', line 31

def prefix
  @prefix
end

#product_lineString

The name of the ProductLine associated with the submission template.

ProductLine represents the team doing the work. Used primarily to group together submission templates for display, but is also used in downstream reporting.

If #product_line is not specified defaults to PRODUCTLINE

Returns:

  • (String)

    The name of the product line



84
85
86
# File 'lib/limber/helper.rb', line 84

def product_line
  @product_line || PRODUCTLINE
end

#roleString

The name or the OrderRole associated with the submission template. If #role is not specified falls back to #prefix

Returns:

  • (String)

    The name of the order role used for the submission templates



64
65
66
# File 'lib/limber/helper.rb', line 64

def role
  @role || prefix
end

#sequencing_keys=(value) ⇒ Object (writeonly)

Sets the attribute sequencing_keys

Parameters:

  • value

    the value to set the attribute sequencing_keys to.



32
33
34
# File 'lib/limber/helper.rb', line 32

def sequencing_keys=(value)
  @sequencing_keys = value
end

#typeString

The RequestType#key of the RequestType that forms the library creation part of the generated submission templates.

If #type is not specified, defaults to ‘limber_’ followed by #prefix

Returns:

  • (String)

    The key of the library creation RequestType



94
95
96
# File 'lib/limber/helper.rb', line 94

def type
  @type || "limber_#{prefix.downcase.tr(' ', '_')}"
end

Class Method Details

.find_for(name, sequencing = nil) ⇒ Array<SubmissionTemplate>

Finds all submission templates matching the provided name. If sequencing is not specified will find all submission templates.

Parameters:

  • name (String)

    The library creation portion of the SubmissionTemplate name

  • sequencing (Array<String>) (defaults to: nil)

    Array of sequencing RequestType#key to find the templates for.

Returns:



41
42
43
44
45
46
47
48
49
# File 'lib/limber/helper.rb', line 41

def self.find_for(name, sequencing = nil)
  tc = TemplateConstructor.new(name:, sequencing:)
  [true, false].map do |cherrypick|
      tc.sequencing.map do |sequencing_request_type|
        SubmissionTemplate.find_by!(name: tc.name_for(cherrypick, sequencing_request_type))
      end
    end
    .flatten
end

Instance Method Details

#build!Object

Construct a series of submission templates according to the specified options. ).build!

Examples:

Generating PCR Free submission templates

Limber::Helper::RequestTypeConstructor.new(
 'PCR Free',
 library_types: ['HiSeqX PCR free', 'PCR Free 384', 'Chromium single cell CNV', 'DAFT-seq'],
 default_purposes: ['PF Cherrypicked']

See Also:



129
130
131
132
# File 'lib/limber/helper.rb', line 129

def build!
  validate!
  each_submission_template { |config| SubmissionTemplate.create!(config) }
end

#name_for(cherrypick, sequencing_request_type) ⇒ String

The name of the SubmissionTemplate for the given options.

Parameters:

  • cherrypick (Boolean)

    Whether there is a cherrypick component

  • sequencing_request_type (RequestType)

    The sequencing request type

Returns:

  • (String)

    A name for the request type



114
115
116
117
118
# File 'lib/limber/helper.rb', line 114

def name_for(cherrypick, sequencing_request_type)
  "#{pipeline} - #{cherrypick ? 'Cherrypicked - ' : ''}#{name} - #{
    sequencing_request_type.name.gsub(PIPELINE_REGEX, '')
  }"
end

#sequencing_request_typesArray

The RequestType#key of the request types that forms the sequencing part of the generated submission templates.

If sequencing_keys is not specified, defaults to ‘limber_’ followed by #prefix

Returns:

  • (Array)

    All Sequencing RequestTypes for which a SubmissionTemplate will be generated



104
105
106
# File 'lib/limber/helper.rb', line 104

def sequencing_request_types
  @sequencing_request_types ||= @sequencing_keys.map { |request| RequestType.find_by!(key: request) }
end