Skip to content

Commit

Permalink
timings
Browse files Browse the repository at this point in the history
  • Loading branch information
tibvdm committed Apr 22, 2024
1 parent 6c389b2 commit 1279d26
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/controllers/mpa/pept2filtered_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
class Mpa::Pept2filteredController < Mpa::MpaController
include SuffixArrayHelper

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

def pept2filtered
peptides = (params[:peptides] || []).uniq
missed = params[:missed].nil? ? false : params[:missed]
Expand All @@ -15,11 +19,15 @@ 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"] }
.each { |result| result["taxa"] = result["taxa"].to_set }

end_index_time = get_time - index_time

taxa_filter_ids.each_slice(5000) do |taxa_slice|
taxa_slice = Taxon.where(id: taxa_slice).where(valid_taxon: 1).pluck(:id).to_set

Expand All @@ -29,5 +37,7 @@ def pept2filtered
result["taxa"] = result["taxa"].select { |taxon_id| taxa_slice.include?(taxon_id) }.uniq
end
end

@timings = end_index_time
end
end
1 change: 1 addition & 0 deletions app/views/mpa/pept2filtered/pept2filtered.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ json.peptides @response do |peptide|
json.data peptide["fa"]["data"]
end
end
json.timings @timings

0 comments on commit 1279d26

Please sign in to comment.