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.


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

def catalogue
  @catalogue
end

#cherrypicked=(value) ⇒ Object (writeonly)

Sets the attribute cherrypicked


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

def cherrypicked=(value)
  @cherrypicked = value
end

#nameObject


108
109
110
# File 'lib/limber/helper.rb', line 108

def name
  @name || prefix
end

#pipelineString

Prefix before submission template names. Defaults to PIPELINE


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

def pipeline
  @pipeline || PIPELINE
end

#prefixObject

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


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

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


136
137
138
# File 'lib/limber/helper.rb', line 136

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


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

def role
  @role || prefix
end

#sequencing_keys=(value) ⇒ Object (writeonly)

Sets the attribute sequencing_keys


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

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


146
147
148
# File 'lib/limber/helper.rb', line 146

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.


94
95
96
97
98
99
100
101
# File 'lib/limber/helper.rb', line 94

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:


181
182
183
184
185
186
# File 'lib/limber/helper.rb', line 181

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

#name_for(cherrypick, sequencing_request_type) ⇒ String

The name of the SubmissionTemplate for the given options.


168
169
170
# File 'lib/limber/helper.rb', line 168

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


156
157
158
159
160
# File 'lib/limber/helper.rb', line 156

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