Skip to content

Commit

Permalink
test output
Browse files Browse the repository at this point in the history
  • Loading branch information
tibvdm committed Apr 15, 2024
1 parent 2384a4a commit ce71c48
Showing 1 changed file with 31 additions and 29 deletions.
60 changes: 31 additions & 29 deletions app/controllers/mpa/pept2data_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,36 @@ def pept2data
# Request the suffix array search service
search_results = search(peptides, @equate_il)

proteins = Set.new
search_results["result"].each do |result|
proteins.merge(result['uniprot_accessions'])
end

entries = UniprotEntry.where(uniprot_accession_number: proteins.to_a.uniq)

# Convert the retrieved entries to a hash (for easy retrieval)
accession_to_protein = Hash.new
entries.each do |entry|
accession_to_protein[entry.uniprot_accession_number] = entry
end

taxa = []
search_results["result"].each do |result|
uniprot_entries = result["uniprot_accessions"].map { |acc| accession_to_protein[acc] }
result["fa"] = UniprotEntry.summarize_fa(uniprot_entries)
@response[result["sequence"]] = result
taxa.append(result["lca"])
end

looked_up_lineages = Lineage.find(taxa)
looked_up_lineages.each do |lineage|
@lineages[lineage.taxon_id] = lineage.to_a_idx
end

@response.each do |_, entry|
entry["lineage"] = @lineages[entry["lca"].to_i]
end
@response = search_results

# proteins = Set.new
# search_results["result"].each do |result|
# proteins.merge(result['uniprot_accessions'])
# end

# entries = UniprotEntry.where(uniprot_accession_number: proteins.to_a.uniq)

# # Convert the retrieved entries to a hash (for easy retrieval)
# accession_to_protein = Hash.new
# entries.each do |entry|
# accession_to_protein[entry.uniprot_accession_number] = entry
# end

# taxa = []
# search_results["result"].each do |result|
# uniprot_entries = result["uniprot_accessions"].map { |acc| accession_to_protein[acc] }
# result["fa"] = UniprotEntry.summarize_fa(uniprot_entries)
# @response[result["sequence"]] = result
# taxa.append(result["lca"])
# end

# looked_up_lineages = Lineage.find(taxa)
# looked_up_lineages.each do |lineage|
# @lineages[lineage.taxon_id] = lineage.to_a_idx
# end

# @response.each do |_, entry|
# entry["lineage"] = @lineages[entry["lca"].to_i]
# end
end
end

0 comments on commit ce71c48

Please sign in to comment.