Skip to content

Commit 62dc649

Browse files
authored
Merge pull request #595 from ISA-tools/develop
closes #598, #591
2 parents 5955677 + 12493c0 commit 62dc649

File tree

15 files changed

+17706
-278
lines changed

15 files changed

+17706
-278
lines changed

isatools/convert/experimental/nih_dcc_flux.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def nihdcc2isa_convert(json_path, output_path):
281281
material_out.characteristics.append(material_type)
282282

283283
study.assays[0].samples.append(material_in)
284-
study.assays[0].materials["other_material"].append(material_in)
284+
study.assays[0].other_material.append(material_in)
285285
try:
286286
material_separation_process
287287
except NameError:
@@ -300,7 +300,7 @@ def nihdcc2isa_convert(json_path, output_path):
300300
value=OntologyAnnotation(term=sample_json["type"], term_source=obi),
301301
)
302302
material_in.characteristics.append(material_type)
303-
study.assays[0].materials["other_material"].append(material_in)
303+
study.assays[0].other_material.append(material_in)
304304

305305
data_acq_process = Process(executes_protocol=study.get_prot(sample_json["protocol.id"]))
306306
data_acq_process.name = sample_json["id"]

isatools/database/models/ontology_annotation.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,14 @@ def to_sql(self, session):
8282
if oa:
8383
return oa
8484
term_source_id = self.term_source.to_sql(session) if self.term_source else None
85+
comments_objs = [c.to_sql(session) for c in self.comments]
86+
8587
oa = OntologyAnnotation(
8688
ontology_annotation_id=self.id,
8789
annotation_value=self.term,
8890
term_accession=self.term_accession,
8991
term_source_id=term_source_id.ontology_source_id if term_source_id else None,
90-
comments=[comment.to_sql() for comment in self.comments],
92+
comments=comments_objs,
9193
)
9294
session.add(oa)
9395
return oa

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

0 commit comments

Comments
 (0)