Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workflow Execution: Sample Name Cell Component #678

Merged
merged 4 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion app/components/nextflow/samplesheet/column_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ def initialize(namespace_id:, header:, property:, samples:, metadata_fields:, re

# rubocop:enable Metrics/ParameterLists

def render_cell_type(property, entry, sample, fields, index)
def render_cell_type(property, entry, sample, fields, index) # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity
case entry['cell_type']
when 'sample_cell'
render_sample_cell(sample, fields)
when 'sample_name_cell'
render_sample_name_cell(sample, fields)
when 'fastq_cell'
render_fastq_cell(sample, property, entry, fields, index)
when 'file_cell'
Expand Down Expand Up @@ -71,6 +73,10 @@ def render_sample_cell(sample, fields)
render(Samplesheet::SampleCellComponent.new(sample:, fields:))
end

def render_sample_name_cell(sample, fields)
render(Samplesheet::SampleNameCellComponent.new(sample:, fields:))
end

def render_metadata_cell(sample, name, fields)
render(Samplesheet::MetadataCellComponent.new(sample:, name:, form: fields))
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="p-2.5 sticky left-0">
<%= sample.name %>
<%= fields.hidden_field :sample_name, value: sample.name %>
</div>
15 changes: 15 additions & 0 deletions app/components/nextflow/samplesheet/sample_name_cell_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

module Nextflow
module Samplesheet
# Component to render a cell with the sample name into the sample sheet
class SampleNameCellComponent < Component
attr_reader :sample, :fields

def initialize(sample:, fields:)
@sample = sample
@fields = fields
end
end
end
end
2 changes: 2 additions & 0 deletions app/components/nextflow/samplesheet_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def extract_properties(schema)
def identify_cell_type(property, entry)
return 'sample_cell' if property == 'sample'

return 'sample_name_cell' if property == 'sample_name'

return 'fastq_cell' if property.match(/fastq_\d+/)

return 'file_cell' if check_for_file(entry)
Expand Down
3 changes: 2 additions & 1 deletion test/components/nextflow_samplesheet_component_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ class NextflowSamplesheetComponentTest < ApplicationSystemTestCase
visit("/rails/view_components/nextflow_samplesheet_component/default?sample_ids[]=#{sample1.id}&sample_ids[]=#{sample2.id}") # rubocop:disable Layout/LineLength

assert_selector '.samplesheet-table' do |table|
table.assert_selector '.table-header', count: 4
table.assert_selector '.table-header', count: 5
table.assert_selector '.table-column:last-of-type .table-header', text: 'STRANDEDNESS (REQUIRED)'
table.assert_selector '.table-column:first-of-type .table-td', count: 2
table.assert_selector '.table-column:first-of-type .table-td:first-of-type', text: sample1.puid
table.assert_selector '.table-column:nth-of-type(2) .table-td:first-of-type', text: sample1.name
table.assert_selector '.table-column:last-of-type .table-td:first-of-type select option', count: 4
table.assert_selector '.table-column:last-of-type .table-td:first-of-type select option:nth-of-type(2)',
text: 'forward'
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/files/nextflow/samplesheet_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
"pattern": "^\\S+$",
"errorMessage": "Sample name must be provided and cannot contain spaces"
},
"sample_name": {
"type": "string",
"meta": ["name"],
"errorMessage": "Sample name must be provided"
},
"fastq_1": {
"type": "string",
"pattern": "^\\S+\\.f(ast)?q\\.gz$",
Expand Down
7 changes: 6 additions & 1 deletion test/fixtures/files/nextflow/schema_input.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
"pattern": "^\\S+$",
"meta": ["id"],
"unique": true,
"errorMessage": "Sample name must be provided and cannot contain spaces"
"errorMessage": "Sample id must be provided and cannot contain spaces"
},
"sample_name": {
"type": "string",
"meta": ["name"],
"errorMessage": "Sample name must be provided"
},
"fastq_1": {
"type": "string",
Expand Down
Loading