Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
tibvdm committed Apr 16, 2024
1 parent 305baaf commit 829499c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
15 changes: 2 additions & 13 deletions app/controllers/mpa/pept2data_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def pept2data
equate_il = params[:equate_il].nil? ? true : params[:equate_il] == 'true'

@response = Hash.new
@lineages = Hash.new

if peptides.empty?
return
Expand All @@ -22,22 +23,10 @@ def pept2data
end

# Retrieve all lineages at once
@lineages = Hash.new
Lineage.find(taxa).each do |lineage|
@lineages[lineage.taxon_id] = lineage.to_a_idx
end

# Fill the response hash with the search results
search_results["result"].each do |result|
@response[result["sequence"]] = {
sequence: result["sequence"],
lca: result["lca"],
lineage: @lineages[result["lca"].to_i],
fa: {
counts: result["fa"]["counts"],
data: result["fa"]["data"]
}
}
end
@response = search_results["result"]
end
end
10 changes: 9 additions & 1 deletion app/views/mpa/pept2data/pept2data.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
json.peptides(@response.values)
json.peptides @response do |peptide|
json.sequence peptide[:sequence]
json.lca peptide[:lca]
json.lineage @lineages[peptide[:lca].to_i]
json.fa do
json.counts peptide[:fa][:counts]
json.data peptide[:fa][:data]
end
end

0 comments on commit 829499c

Please sign in to comment.