Skip to content

Commit

Permalink
Add option clause in get_term_by_uri
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryan Bartley committed Apr 19, 2021
1 parent 7024c9a commit 8ed60d2
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions tyto/owlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ def _convert_ontobee_response(response):
response = response.convert() # Convert http response to JSON
for var, binding in zip(response['head']['vars'],
response['results']['bindings']):
converted_response.append(binding[var]['value'])
if var in binding:
converted_response.append(binding[var]['value'])
return converted_response

def _convert_rdflib_response(response):
Expand All @@ -107,8 +108,15 @@ def get_term_by_uri(self, uri):
SELECT distinct ?label
WHERE
{{{{
<{uri}> rdfs:label ?label .
filter langMatches(lang(?label), "en")
optional
{{{{
<{uri}> rdfs:label ?label .
filter langMatches(lang(?label), "en")
}}}}
optional
{{{{
<{uri}> rdfs:label ?label .
}}}}
}}}}
'''.format(uri=uri)
error_msg = '{} not found'.format(uri)
Expand Down Expand Up @@ -212,6 +220,9 @@ def multi_replace(target_uri, old_namespaces, new_namespace):
'http://identifiers.org/so/SO:'],
'http://purl.obolibrary.org/obo/SO_')

SBO = Ontology(path=installation_path('ontologies/SBO_OWL.owl'),
endpoint='http://sparql.hegroup.org/sparql/',
uri='http://purl.obolibrary.org/obo/sbo.owl')
SBO = Ontology(path=installation_path('ontologies/SBO_OWL.owl'),
endpoint='http://sparql.hegroup.org/sparql/',
uri='http://purl.obolibrary.org/obo/sbo.owl')
Expand Down

0 comments on commit 8ed60d2

Please sign in to comment.