Class: AvitiSampleSheet::SampleSheetGenerator::Generator

Inherits:
Object
  • Object
show all
Defined in:
app/controllers/aviti_sample_sheet/sample_sheet_generator.rb

Constant Summary collapse

SETTINGS_SECTION =

These settings are defined in the Aviti sample sheet template used in our lab - check Confluence for details. They specify parameters for Bases2Fastq execution and are fixed for lab usage. The 'Lane' value of '1+2' indicates that the settings apply to both lanes. Users may manually update this section if necessary.

[
  ['[SETTINGS]'],
  %w[SettingName Value Lane],
  ['# Replace the example adapters below with the adapter used in the kit.'],
  %w[R1Adapter AAAAAAAAAAAAAAAAAAA 1+2],
  %w[R1AdapterTrim FALSE 1+2],
  %w[R2Adapter TTTTTTTTTTTTTTTTTTT 1+2],
  %w[R2AdapterTrim FALSE 1+2]
].freeze
SAMPLE_SECTION_HEADERS =
[
  ['[SAMPLES]'],
  %w[SampleName Index1 Index2 Lane Project]
].freeze
ELEMENT_PHIX_SECTION =

The values are set according to the official documentation from Element Biosciences. This section is static because metadata for control samples is not tracked in the Aviti pipeline. Users can manually modify this section if necessary.

[
  ['PhiX_Third', 'ATGTCGCTAG', 'CTAGCTCGTA', '1+2', nil],
  ['PhiX_Third', 'CACAGATCGT', 'ACGAGAGTCT', '1+2', nil],
  ['PhiX_Third', 'GCACATAGTC', 'GACTACTAGC', '1+2', nil],
  ['PhiX_Third', 'TGTGTCGACA', 'TGTCTGACAG', '1+2', nil]
].freeze
COMP_PHIX_SECTION =

'Comp PhiX' values, particularly for runs using custom primers. This section is used instead of 'Element PhiX' section according to the PhiX type selection in the Loading task. Note that index1 and index2 values may be truncated to match those of the samples within the sheet.

[
  ['Comp_PhiX', 'TGTAGTAAAT', 'AACGTTGCCA', '1+2', nil]
].freeze
PHIX_TYPE_TASK_NAME =

The name of the task where PhiX type is selected.

'Loading'
PHIX_TYPE_DESCRIPTOR_NAME =

The name of the descriptor for PhiX type selection.

'PhiX type'
ELEMENT_PHIX_TYPE =

Possible values for PhiX type selection.

'Element PhiX'
COMP_PHIX_TYPE =
'Comp PhiX'

Instance Method Summary collapse

Constructor Details

#initialize(batch) ⇒ Generator

Returns a new instance of Generator.



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'app/controllers/aviti_sample_sheet/sample_sheet_generator.rb', line 72

 do
  # NOTE: The following attribute is not required for Microarray Genotyping.
  # I think this might be broken and suggests that there should be separate classes for project: one for
  # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping
  # that doesn't.
  include ProjectManager::Associations
  include BudgetDivision::Associations

  custom_attribute(:project_cost_code, required: true)
  custom_attribute(:funding_comments)
  custom_attribute(:collaborators)
  custom_attribute(:external_funding_source)
  custom_attribute(:sequencing_budget_cost_centre)
  custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS)
  custom_attribute(:gt_committee_tracking_id)

  before_validation do |record|
    record.project_cost_code = nil if record.project_cost_code.blank?
    record.project_funding_model = nil if record.project_funding_model.blank?
  end
end

Instance Method Details

#generateString

Generates the full sample sheet CSV string for the given batch. It includes static [SETTINGS] and PhiX control sample sections, followed by a dynamically built sample section based on the batch requests.

Returns:

  • (String)

    the CSV content as a string with CRLF line endings.



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'app/controllers/aviti_sample_sheet/sample_sheet_generator.rb', line 81

 do
  # NOTE: The following attribute is not required for Microarray Genotyping.
  # I think this might be broken and suggests that there should be separate classes for project: one for
  # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping
  # that doesn't.
  include ProjectManager::Associations
  include BudgetDivision::Associations

  custom_attribute(:project_cost_code, required: true)
  custom_attribute(:funding_comments)
  custom_attribute(:collaborators)
  custom_attribute(:external_funding_source)
  custom_attribute(:sequencing_budget_cost_centre)
  custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS)
  custom_attribute(:gt_committee_tracking_id)

  before_validation do |record|
    record.project_cost_code = nil if record.project_cost_code.blank?
    record.project_funding_model = nil if record.project_funding_model.blank?
  end
end