Skip to content

Commit

Permalink
proteins
Browse files Browse the repository at this point in the history
  • Loading branch information
tibvdm committed Apr 16, 2024
1 parent a8b830b commit 6a2f77b
Showing 1 changed file with 5 additions and 66 deletions.
71 changes: 5 additions & 66 deletions app/controllers/private_api/proteins_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ def proteins

# Request the suffix array search service
search_result = search([ peptide ], equate_il).first
if search_result.nil?
return
end

@lca = search_result["lca"] || -1
@common_lineage = []

# Collect all protein information
if search_result.nil?
return
end

@proteins = UniprotEntry
.includes(:taxon)
.where(uniprot_accession_number: search_result["uniprot_accessions"])
Expand All @@ -44,67 +44,6 @@ def proteins
}
end


# if sequence.present? && sequence.peptides(equate_il).empty?
# @entries = []
# return
# end

# @common_lineage = []

# # get the uniprot entries of every peptide
# # only used for the open in uniprot links
# # and calculate the LCA
# if sequence.nil?
# begin
# # we didn't find the sequence in the database, so let's try to split it
# long_sequences = Sequence.advanced_single_search(seq, equate_il)
# rescue NoMatchesFoundError
# return
# end
# # calculate possible uniprot entries
# temp_entries = long_sequences.map { |s| s.peptides(equate_il).map(&:uniprot_entry).to_set }
# # take the intersection of all sets
# @entries = temp_entries.reduce(:&)
# # check if the protein contains the startsequence
# @entries.select! { |e| e.protein_contains?(seq, equate_il) }

# # Calculate fa summary
# @fa_summary = UniprotEntry.summarize_fa(@entries)

# return if @entries.empty?

# @lineages = @entries.map(&:lineage).compact
# else
# @entries = sequence.peptides(equate_il).map(&:uniprot_entry)
# @lineages = sequence.lineages(equate_il, true).to_a

# # Get FA summary from cache
# @fa_summary = sequence.calculate_fa(equate_il)
# end

# # sort entries
# @entries = @entries.to_a.sort_by { |e| e.taxon.nil? ? '' : e.taxon.name }

# @lca_taxon = Lineage.calculate_lca_taxon(@lineages)
# @root = Node.new(1, 'Organism', nil, 'root') # start constructing the tree
# common_hits = @lineages.map(&:hits).reduce(:+)
# @root.data['count'] = common_hits
# last_node = @root

# # common lineage
# # construct the common lineage in this array
# l = @lca_taxon.lineage
# found = (@lca_taxon.name == 'root')
# while !found && l.has_next?
# t = l.next_t
# next if t.nil?

# found = (@lca_taxon.id == t.id)
# @common_lineage << t
# node = Node.new(t.id, t.name, @root, t.rank)
# node.data['count'] = common_hits
# last_node = last_node.add_child(node)
# end
// TODO: Common lineage calculation
end
end

0 comments on commit 6a2f77b

Please sign in to comment.