Skip to content

Commit

Permalink
making sources section work for graphs with and without biolink prefi…
Browse files Browse the repository at this point in the history
…x on knowledge sources
  • Loading branch information
EvanDietzMorris committed Apr 3, 2024
1 parent 5382c77 commit 7fc2903
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion PLATER/services/util/question.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ def compile_cypher(self, **kwargs):
# TRAPI dictionaries, and assigns the proper upstream ids to each resource. It does not currently attempt to avoid
# duplicate aggregator results, which probably shouldn't ever occur.
def _construct_sources_tree(self, sources):
# TODO - The transpiler currently returns some null resource ids, partially due to the cypher call
# implementation and partially due to currently supporting knowledge source attributes with and
# without biolink prefixes. In the future it would be more efficient to remove the following two checks
# remove null or empty string resources
sources = [source for source in sources if source['resource_id']]
# remove biolink prefix if it exists
for source in sources:
source['resource_role'] = source['resource_role'].removeprefix('biolink:')

# first find the primary knowledge source, there should always be one
primary_knowledge_source = None
formatted_sources = None
Expand All @@ -88,7 +97,7 @@ def _construct_sources_tree(self, sources):
for source in sources:
# this looks weird but the idea is that you could have a few parallel lists like:
# aggregator_knowledge_source, aggregator_knowledge_source_2, aggregator_knowledge_source_3
if source['resource_role'].startswith("aggregator_knowledge_source") and source['resource_id']:
if source['resource_role'].startswith("aggregator_knowledge_source"):
aggregator_list_sources.append(source)
# walk through the aggregator lists and construct the chains of provenance
terminal_aggregators = set()
Expand Down

0 comments on commit 7fc2903

Please sign in to comment.