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.


92
93
94
# File 'lib/limber/helper.rb', line 92

def catalogue
  @catalogue
end

#cherrypicked=(value) ⇒ Object (writeonly)

Sets the attribute cherrypicked

Parameters:

  • value

    the value to set the attribute cherrypicked to.


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

def cherrypicked=(value)
  @cherrypicked = value
end

#nameObject


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

def name
  @name || prefix
end

#pipelineString

Prefix before submission template names. Defaults to PIPELINE

Returns:

  • (String)

    Prefix before submission template names.


133
134
135
# File 'lib/limber/helper.rb', line 133

def pipeline
  @pipeline || PIPELINE
end

#prefixObject

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


92
93
94
# File 'lib/limber/helper.rb', line 92

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


144
145
146
# File 'lib/limber/helper.rb', line 144

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


124
125
126
# File 'lib/limber/helper.rb', line 124

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.


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

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


154
155
156
# File 'lib/limber/helper.rb', line 154

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:


102
103
104
105
106
107
108
109
# File 'lib/limber/helper.rb', line 102

def self.find_for(name, sequencing = nil)
  tc = TemplateConstructor.new(name: name, sequencing: 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:


189
190
191
192
# File 'lib/limber/helper.rb', line 189

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


174
175
176
177
178
# File 'lib/limber/helper.rb', line 174

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


164
165
166
# File 'lib/limber/helper.rb', line 164

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