Skip to content

Commit 7bde062

Browse files
authored
Merge pull request #599 from ISA-tools/ols_fix
fix to get_ols_ontology
2 parents cbd152a + 8e9b4c3 commit 7bde062

File tree

6 files changed

+17411
-34
lines changed

6 files changed

+17411
-34
lines changed

isatools/net/ols.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
def 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

tests/convert/test_isatab2sra.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def test_isatab2sra_dump_submission_xml_biis7(self):
114114
actual_submission_xml_biis7 = etree.fromstring(submission_xml)
115115
self.assertTrue(utils.assert_xml_equal(self._expected_submission_xml_biis7, actual_submission_xml_biis7))
116116

117-
@unittest.skip("Not working yet")
117+
# @unittest.skip("Not working yet")
118118
def test_isatab2sra_dump_project_set_xml_biis7(self):
119119
isatab2sra.convert(self._biis7_dir, self._tmp_dir, validate_first=False)
120120
with open(os.path.join(self._tmp_dir, "project_set.xml"), "rb") as ps_fp:

tests/isatab/test_isatab.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2005,9 +2005,7 @@ def test_isatab_protocol_chain_parsing(self):
20052005
for proc in nucleotide_sequencing_assay.process_sequence
20062006
if proc.executes_protocol.name == "genomic DNA extraction - standard procedure 4"
20072007
)
2008-
extract = next(
2009-
mat for mat in nucleotide_sequencing_assay.other_material if mat.name == "GSM255770.e1"
2010-
)
2008+
extract = next(mat for mat in nucleotide_sequencing_assay.other_material if mat.name == "GSM255770.e1")
20112009
self.assertTrue(nucl_ac_extraction_process.next_process is gen_dna_extraction_process)
20122010
self.assertEqual(len(gen_dna_extraction_process.outputs), 1)
20132011
self.assertFalse(nucl_ac_extraction_process.outputs)

0 commit comments

Comments
 (0)