Skip to content

Commit

Permalink
print protein in api
Browse files Browse the repository at this point in the history
  • Loading branch information
pverscha committed Mar 7, 2024
1 parent beee804 commit fa07648
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/controllers/api/api_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def pept2prot
end
else
@result = Hash.new { |h, k| h[k] = Set.new }
@sequences.pluck(:sequence, 'uniprot_entries.uniprot_accession_number', 'uniprot_entries.name', 'uniprot_entries.taxon_id').each do |sequence, uniprot_id, protein_name, taxon_id|
@result[sequence] << [uniprot_id, protein_name, taxon_id]
@sequences.pluck(:sequence, 'uniprot_entries.uniprot_accession_number', 'uniprot_entries.name', 'uniprot_entries.taxon_id', 'uniprot_entries.protein').each do |sequence, uniprot_id, protein_name, taxon_id, protein|
@result[sequence] << [uniprot_id, protein_name, taxon_id, protein]
end
end

Expand Down
4 changes: 3 additions & 1 deletion app/views/api/api/pept2prot.json.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
v.map do |u|
{ "peptide" => k,
"uniprot_id" => u.uniprot_accession_number,

"protein_name" => u.name,
"taxon_id" => u.taxon_id,
"taxon_name" => u.taxon.try(:name),
Expand All @@ -20,11 +21,12 @@
@input_order.map do |k|
seq_index = @equate_il ? k.gsub(/I/,'L') : k
v = @result[seq_index]
v.map do |uni,name,tax|
v.map do |uni,name,tax,prot|
{ "peptide" => k,
"uniprot_id" => uni,
"protein_name" => name,
"taxon_id" => tax,
"protein" => prot
}
end
end.flatten).html_safe
Expand Down

0 comments on commit fa07648

Please sign in to comment.