Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 15 additions & 17 deletions isatools/net/ols.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

def get_ols_ontologies():
"""Returns a list of OntologySource objects according to what's in OLS"""
ontologiesUri = OLS_API_BASE_URI + "/ontologies?size=" + str(OLS_PAGINATION_SIZE)
ontologiesUri = OLS_API_BASE_URI + "/ontologies?" + str(OLS_PAGINATION_SIZE)
log.debug(ontologiesUri)
J = json.loads(urlopen(ontologiesUri).read().decode("utf-8"))
ontology_sources = []
Expand All @@ -43,28 +43,24 @@ def get_ols_ontologies():
return ontology_sources


def get_ols_ontology(ontology_name):
def get_ols_ontology(ontology_name, page: int):
"""Returns a single OntologySource objects according to what's in OLS"""
ontologiesUri = OLS_API_BASE_URI + "/ontologies?size=" + str(OLS_PAGINATION_SIZE)
ontologiesUri = OLS_API_BASE_URI + "/ontologies?page=" + str(page) + "&size=" + str(OLS_PAGINATION_SIZE)
log.debug(ontologiesUri)
J = json.loads(urlopen(ontologiesUri).read().decode("utf-8"))
print("EMBEDDED: ", J["_embedded"]["ontologies"])
ontology_sources = []
for ontology_source_json in J["_embedded"]["ontologies"]:
ontology_sources.append(
OntologySource(
name=ontology_source_json["ontologyId"],
version=ontology_source_json["config"]["version"] if ontology_source_json["config"]["version"] else "",
description=ontology_source_json["config"]["title"] if ontology_source_json["config"]["title"] else "",
file=ontology_source_json["_links"]["self"]["href"],
if ontology_source_json["ontologyId"] == ontology_name:
ontology_sources.append(
OntologySource(
name=ontology_source_json["ontologyId"],
version=ontology_source_json["config"]["version"] if ontology_source_json["config"]["version"] else "",
description=ontology_source_json["config"]["title"] if ontology_source_json["config"]["title"] else "",
file=ontology_source_json["_links"]["self"]["href"],
)
)
)
print("NAME: ", ontology_name)
print("SOURCES: ", [o.name for o in ontology_sources])
hits = [o for o in ontology_sources if o.name == ontology_name]
print("HITS: ", hits)
if len(hits) == 1:
return hits[0]
if len(ontology_sources) == 1:
return ontology_sources[0]
return None


Expand All @@ -80,6 +76,8 @@ def search_ols(term, ontology_source):

query = "{0}&queryFields=label&ontology={1}&exact=True".format(term, os_search)
url += "?q={}".format(query)

#print("OLS_URL", url)
log.debug(url)
import requests

Expand Down
2 changes: 1 addition & 1 deletion tests/convert/test_isatab2sra.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def test_isatab2sra_dump_submission_xml_biis7(self):
actual_submission_xml_biis7 = etree.fromstring(submission_xml)
self.assertTrue(utils.assert_xml_equal(self._expected_submission_xml_biis7, actual_submission_xml_biis7))

@unittest.skip("Not working yet")
# @unittest.skip("Not working yet")
def test_isatab2sra_dump_project_set_xml_biis7(self):
isatab2sra.convert(self._biis7_dir, self._tmp_dir, validate_first=False)
with open(os.path.join(self._tmp_dir, "project_set.xml"), "rb") as ps_fp:
Expand Down
4 changes: 1 addition & 3 deletions tests/isatab/test_isatab.py
Original file line number Diff line number Diff line change
Expand Up @@ -2005,9 +2005,7 @@ def test_isatab_protocol_chain_parsing(self):
for proc in nucleotide_sequencing_assay.process_sequence
if proc.executes_protocol.name == "genomic DNA extraction - standard procedure 4"
)
extract = next(
mat for mat in nucleotide_sequencing_assay.other_material if mat.name == "GSM255770.e1"
)
extract = next(mat for mat in nucleotide_sequencing_assay.other_material if mat.name == "GSM255770.e1")
self.assertTrue(nucl_ac_extraction_process.next_process is gen_dna_extraction_process)
self.assertEqual(len(gen_dna_extraction_process.outputs), 1)
self.assertFalse(nucl_ac_extraction_process.outputs)
Expand Down
Loading
Loading