Skip to content

Commit

Permalink
reject empty arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
tibvdm committed Apr 22, 2024
1 parent 1475d4c commit dd475e4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
24 changes: 1 addition & 23 deletions app/controllers/mpa/pept2filtered_controller.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
class Mpa::Pept2filteredController < Mpa::MpaController
include SuffixArrayHelper

def get_time
Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond)
end

def pept2filtered
total_time = get_time

peptides = (params[:peptides] || []).uniq
missed = params[:missed].nil? ? false : params[:missed]
equate_il = params[:equate_il].nil? ? true : params[:equate_il]
Expand All @@ -21,32 +15,16 @@ def pept2filtered

taxa_filter_ids = (params[:taxa] || []).map(&:to_i)

index_time = get_time

# Request the suffix array search service
@response = search(peptides, equate_il, cutoff)
.select { |result| !result["cutoff_used"] }

end_index_time = get_time - index_time

filter_time = get_time

taxa_filter_ids = taxa_filter_ids.to_set

@response.each do |result|
result["taxa"] = result["taxa"].to_set & taxa_filter_ids
result["taxa"] = result["taxa"].to_set & taxa_filter_ids
end

@response.reject! { |result| result["taxa"].empty? }

end_filter_time = get_time - filter_time

end_total_time = get_time - total_time

@timings = {
index_time: end_index_time,
filter_time: end_filter_time,
total_time: end_total_time
}
end
end
1 change: 0 additions & 1 deletion app/views/mpa/pept2filtered/pept2filtered.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ json.peptides @response do |peptide|
json.data peptide["fa"]["data"]
end
end
json.timings @timings

0 comments on commit dd475e4

Please sign in to comment.