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
4 changes: 2 additions & 2 deletions isatools/convert/experimental/nih_dcc_flux.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def nihdcc2isa_convert(json_path, output_path):
material_out.characteristics.append(material_type)

study.assays[0].samples.append(material_in)
study.assays[0].materials["other_material"].append(material_in)
study.assays[0].other_material.append(material_in)
try:
material_separation_process
except NameError:
Expand All @@ -300,7 +300,7 @@ def nihdcc2isa_convert(json_path, output_path):
value=OntologyAnnotation(term=sample_json["type"], term_source=obi),
)
material_in.characteristics.append(material_type)
study.assays[0].materials["other_material"].append(material_in)
study.assays[0].other_material.append(material_in)

data_acq_process = Process(executes_protocol=study.get_prot(sample_json["protocol.id"]))
data_acq_process.name = sample_json["id"]
Expand Down
4 changes: 3 additions & 1 deletion isatools/database/models/ontology_annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,14 @@ def to_sql(self, session):
if oa:
return oa
term_source_id = self.term_source.to_sql(session) if self.term_source else None
comments_objs = [c.to_sql(session) for c in self.comments]

oa = OntologyAnnotation(
ontology_annotation_id=self.id,
annotation_value=self.term,
term_accession=self.term_accession,
term_source_id=term_source_id.ontology_source_id if term_source_id else None,
comments=[comment.to_sql() for comment in self.comments],
comments=comments_objs,
)
session.add(oa)
return oa
Expand Down
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
Loading
Loading