Skip to content

Commit

Permalink
enable search mapping_justification by curie
Browse files Browse the repository at this point in the history
  • Loading branch information
anitacaron committed Sep 12, 2023
1 parent b164840 commit 4576c1d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/database/sparql_implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,19 @@ def get_sssom_mappings_by_curie(self, search_filter: SearchEntity) -> Iterable[M

def get_ui_mappings_by_curie(self, search_filter: SearchEntity) -> Iterable[dict]:
filters = search_filter.dict()

if filters["mapping_justification"] != None:
justifs = filters["mapping_justification"]
filters["mapping_justification"] = [expand_uri(justif) for justif in justifs]

curies = filters.pop("curies")

filters["subject_id"] = [expand_uri(curie) for curie in curies]
bindings = self.get_mappings_by_field(filters)
for row in bindings:
row["subject_id_curie"] = compress_uri(row["subject_id"])
row["predicate_id_curie"] = compress_uri(row["predicate_id"])
row["object_id_curie"] = compress_uri(row["object_id"])
row["mapping_justification_curie"] = compress_uri(row["mapping_justification"])
yield row

filters.pop("subject_id")
Expand All @@ -206,6 +211,7 @@ def get_ui_mappings_by_curie(self, search_filter: SearchEntity) -> Iterable[dict
row["subject_id_curie"] = compress_uri(row["subject_id"])
row["predicate_id_curie"] = compress_uri(row["predicate_id"])
row["object_id_curie"] = compress_uri(row["object_id"])
row["mapping_justification_curie"] = compress_uri(row["mapping_justification"])
yield row

def get_mappings_by_filter(self, filter: Union[List[dict], None]) -> Iterable[dict]:
Expand Down
2 changes: 1 addition & 1 deletion src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def _create_facets(data: Iterable[object]) -> FacetInfo:
confidence=ConfidenceInfo(min=0, max=1)
)
return FacetInfo(
mapping_justification=countby(lambda d: d["mapping_justification"], iter_mj),
mapping_justification=countby(lambda d: compress_uri(d["mapping_justification"]), iter_mj),
predicate_id=countby(lambda d: compress_uri(d["predicate_id"]), iter_pred),
confidence=ConfidenceInfo(
min=min(
Expand Down

0 comments on commit 4576c1d

Please sign in to comment.