app/views/exports/pbmc_bank_tubes_content_report.csv.erb
<%# This is a report of the contents of the tubes in the PBMC Bank plate %>
<%# Based on app/views/exports/hamilton_lrc_pbmc_bank_to_lrc_bank_seq_and_spare.csv.erb %>
<%= CSV.generate_line ['Workflow', @workflow], row_sep: '' %>
<%=
CSV.generate_line [
'Well name',
'Donor ID',
'Stock barcode',
'FluidX barcode',
'Extraction and freeze date',
'Sequencing or contingency',
'Cell count (cells/ml)',
'Viability (%)',
'Volume (µl)',
'Study name',
'Collection site'
],
row_sep: ''
%>
<%
rows_array = []
@plate.wells_in_columns.each do |source_well|
# skip if well empty (not all wells have samples in them)
next if source_well.empty?
# skip if well not in passed state
next unless source_well.passed?
# skip if no downstream tubes for this well (not set up children in Limber yet)
next if source_well.downstream_tubes.empty?
child_tube_v1 = source_well.downstream_tubes.last
child_tube_v2 =
Sequencescape::Api::V2.tube_with_custom_includes(
'custom_metadatum_collection',
nil,
barcode: child_tube_v1.labware_barcode.machine
)
next unless child_tube_v2 && child_tube_v2.custom_metadatum_collection
# get tube metadata from child_tube
metadata = child_tube_v2.custom_metadatum_collection.metadata
next unless metadata
tube_rack_barcode = metadata['tube_rack_barcode']
tube_rack_position = metadata['tube_rack_position']
next unless tube_rack_barcode && tube_rack_position
sample_uuid = source_well.aliquots.first.sample.uuid
source_well_posn = source_well.position['name']
sample_metadata = source_well.aliquots.first.sample.sample_metadata
# donor_id is sourced from the sample metadata provided by Sequencescape
donor_id = sample_metadata.respond_to?(:donor_id) ? sample_metadata.donor_id : nil
child_tube_purpose = child_tube_v2.purpose.name
destination = ((child_tube_purpose == 'LRC Bank Seq') ? 'Sequencing' : 'Contingency')
volume = 125
rows_array << [
source_well.name, # Well name
donor_id, # Donor ID
@ancestor_tubes[sample_uuid].labware_barcode.human, # LRC Blood Vac purpose barcode
child_tube_v2.barcode, # FluidX barcode
child_tube_v2.created_at, # Extraction and freeze date
destination, # Sequencing or contingency
source_well.latest_live_cell_count&.value, # Cell count
source_well.latest_cell_viability&.value, # Viability
volume, # Volume
source_well.aliquots.first.study.name, # Study name
source_well.aliquots.first.sample.sample_metadata&.collected_by # Collection site
]
end
%>
<% rows_array.sort_by{ |a| WellHelpers.well_coordinate(a[0]) }.each do |row| %>
<%= CSV.generate_line(row.map(&:to_s), row_sep: '').html_safe %>
<% end %>