2323
2424def get_ols_ontologies ():
2525 """Returns a list of OntologySource objects according to what's in OLS"""
26- ontologiesUri = OLS_API_BASE_URI + "/ontologies?size= " + str (OLS_PAGINATION_SIZE )
26+ ontologiesUri = OLS_API_BASE_URI + "/ontologies?" + str (OLS_PAGINATION_SIZE )
2727 log .debug (ontologiesUri )
2828 J = json .loads (urlopen (ontologiesUri ).read ().decode ("utf-8" ))
2929 ontology_sources = []
@@ -43,28 +43,24 @@ def get_ols_ontologies():
4343 return ontology_sources
4444
4545
46- def get_ols_ontology (ontology_name ):
46+ def get_ols_ontology (ontology_name , page : int ):
4747 """Returns a single OntologySource objects according to what's in OLS"""
48- ontologiesUri = OLS_API_BASE_URI + "/ontologies?size=" + str (OLS_PAGINATION_SIZE )
48+ ontologiesUri = OLS_API_BASE_URI + "/ontologies?page=" + str ( page ) + "& size=" + str (OLS_PAGINATION_SIZE )
4949 log .debug (ontologiesUri )
5050 J = json .loads (urlopen (ontologiesUri ).read ().decode ("utf-8" ))
51- print ("EMBEDDED: " , J ["_embedded" ]["ontologies" ])
5251 ontology_sources = []
5352 for ontology_source_json in J ["_embedded" ]["ontologies" ]:
54- ontology_sources .append (
55- OntologySource (
56- name = ontology_source_json ["ontologyId" ],
57- version = ontology_source_json ["config" ]["version" ] if ontology_source_json ["config" ]["version" ] else "" ,
58- description = ontology_source_json ["config" ]["title" ] if ontology_source_json ["config" ]["title" ] else "" ,
59- file = ontology_source_json ["_links" ]["self" ]["href" ],
53+ if ontology_source_json ["ontologyId" ] == ontology_name :
54+ ontology_sources .append (
55+ OntologySource (
56+ name = ontology_source_json ["ontologyId" ],
57+ version = ontology_source_json ["config" ]["version" ] if ontology_source_json ["config" ]["version" ] else "" ,
58+ description = ontology_source_json ["config" ]["title" ] if ontology_source_json ["config" ]["title" ] else "" ,
59+ file = ontology_source_json ["_links" ]["self" ]["href" ],
60+ )
6061 )
61- )
62- print ("NAME: " , ontology_name )
63- print ("SOURCES: " , [o .name for o in ontology_sources ])
64- hits = [o for o in ontology_sources if o .name == ontology_name ]
65- print ("HITS: " , hits )
66- if len (hits ) == 1 :
67- return hits [0 ]
62+ if len (ontology_sources ) == 1 :
63+ return ontology_sources [0 ]
6864 return None
6965
7066
@@ -80,6 +76,8 @@ def search_ols(term, ontology_source):
8076
8177 query = "{0}&queryFields=label&ontology={1}&exact=True" .format (term , os_search )
8278 url += "?q={}" .format (query )
79+
80+ #print("OLS_URL", url)
8381 log .debug (url )
8482 import requests
8583
0 commit comments