From b4865b50308c32c9db356780b51e7772e7978394 Mon Sep 17 00:00:00 2001 From: Pieter Verschaffelt Date: Tue, 4 Jul 2023 10:42:00 +0200 Subject: [PATCH] Fix equate I/L not returning results in API --- app/controllers/mpa_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/mpa_controller.rb b/app/controllers/mpa_controller.rb index 5c7d87c..a43e2c2 100644 --- a/app/controllers/mpa_controller.rb +++ b/app/controllers/mpa_controller.rb @@ -9,14 +9,14 @@ def pept2data @equate_il = params[:equate_il].nil? ? true : params[:equate_il] # If equate_il is set, we have to replace all I's by and L in the input peptides. - equalized_pepts = peptides.map { |p| p.gsub('I', 'L') } if @equate_il + equalized_pepts = @equate_il ? peptides.map { |p| p.gsub('I', 'L') } : peptides @peptides = Sequence .includes(Sequence.lca_t_relation_name(@equate_il) => :lineage) .where(sequence: equalized_pepts) .where.not(Sequence.lca_t_relation_name(@equate_il) => nil) if missed - @peptides += peptides + @peptides += equalized_pepts .to_set.subtract(@peptides.map(&:sequence)) .map { |p| Sequence.missed_cleavage(p, @equate_il) } .compact @@ -34,7 +34,7 @@ def pept2data @original_pep_fas = {} peptides.each do |original_seq| - equalized_seq = original_seq.gsub('I', 'L') + equalized_seq = @equate_il ? original_seq.gsub('I', 'L') : original_seq if eq_seq_to_info.key? equalized_seq @original_pep_results[original_seq] = eq_seq_to_info[equalized_seq] @original_pep_fas[original_seq] = eq_seq_to_fa[equalized_seq]