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
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.

['[SAMPLES]'],
  %w[SampleName Index1 Index2 Lane Project],
  %w[PhiX_Third ATGTCGCTAG CTAGCTCGTA],
  %w[PhiX_Third CACAGATCGT ACGAGAGTCT],
  %w[PhiX_Third GCACATAGTC GACTACTAGC],
  %w[PhiX_Third TGTGTCGACA TGTCTGACAG]
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(batch) ⇒ Generator

Returns a new instance of Generator.



50
51
52
# File 'app/controllers/aviti_sample_sheet/sample_sheet_generator.rb', line 50

def initialize(batch)
  @batch = batch
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.



59
60
61
62
63
64
65
# File 'app/controllers/aviti_sample_sheet/sample_sheet_generator.rb', line 59

def generate
  CSV.generate(row_sep: "\r\n") do |csv|
    SETTINGS_SECTION.each { |row| csv << row }
    adjusted_phix_indexes.each { |row| csv << row }
    append_samples_section(csv)
  end
end