Skip to content

Commit

Permalink
chore: Ensure singles are only add if it is not pe only
Browse files Browse the repository at this point in the history
  • Loading branch information
joshsadam committed Sep 10, 2024
1 parent 2168cd1 commit 6e33f64
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
14 changes: 10 additions & 4 deletions app/components/nextflow/samplesheet/column_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def render_cell_type(property, entry, sample, fields, index) # rubocop:disable M

def render_fastq_cell(sample, property, entry, fields, index)
direction = get_fastq_direction(property)
files = get_fastq_files(sample, direction)
files = get_fastq_files(entry, sample, direction, pe_only: property['pe_only'].present?)
data = get_fastq_data(files, direction, index, property)
render_file_cell(property, entry, fields, files, @required, data, files&.first)
end
Expand All @@ -50,12 +50,18 @@ def get_fastq_direction(property)
property.match(/fastq_(\d+)/)[1].to_i == 1 ? :pe_forward : :pe_reverse
end

def get_fastq_files(sample, direction)
def get_fastq_files(_entry, sample, direction, pe_only: false)
singles = sample.sorted_files[:singles].filter do |file|
file.first.match?(/^\S+\.f(ast)?q(\.gz)?$/)
end || []
files = []
if sample.sorted_files[direction].present?
sample.sorted_files[direction] || []
files = sample.sorted_files[direction] || []
files.concat(singles) unless pe_only
else
[]
files = singles
end
files
end

def get_fastq_data(files, direction, index, property)
Expand Down
4 changes: 4 additions & 0 deletions app/components/nextflow/samplesheet_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ def extract_properties(schema)
@properties[property]['cell_type'] = identify_cell_type(property, entry)
end

if @required_properties.include?('fastq_1') && @required_properties.include?('fastq_2')
@properties['fastq_1']['pe_only'] = true
end

identify_autopopulated_file_properties
end

Expand Down

0 comments on commit 6e33f64

Please sign in to comment.