diff --git a/ontobio/ontol_factory.py b/ontobio/ontol_factory.py index 9ba6d444..fb7fff32 100644 --- a/ontobio/ontol_factory.py +++ b/ontobio/ontol_factory.py @@ -13,6 +13,7 @@ import os import subprocess import hashlib +import fastobo # TODO @@ -155,6 +156,13 @@ def translate_file_to_ontology(handle, **args): logging.info("RdfMapper: {}".format(args)) m = RdfMapper(**args) return m.convert(handle,'ttl') + elif handle.endswith(".obo"): + doc = fastobo.load(handle) + with tempfile.TemporaryFile() as tmp: + fastobo.dump_graph(doc, tmp) + tmp.seek(0) + g = obograph_util.convert_json_object(json.load(tmp), **args) + return Ontology(handle=handle, payload=g) else: if not (handle.endswith(".obo") or handle.endswith(".owl")): logging.info("Attempting to parse non obo or owl file with owltools: "+handle) diff --git a/requirements.txt b/requirements.txt index 2945466c..245b5f49 100644 --- a/requirements.txt +++ b/requirements.txt @@ -19,4 +19,5 @@ pydotplus>=0.0 plotly==2.0.7 pyyaml yamldown>=0.1.7 -click \ No newline at end of file +fastobo~=0.3.1 +click diff --git a/setup.py b/setup.py index 6ea86d1c..1faf816c 100644 --- a/setup.py +++ b/setup.py @@ -56,7 +56,8 @@ 'pandas==0.24.2', 'click==7.0', 'yamldown', - 'dataclasses' + 'dataclasses', + 'fastobo~=0.3.1', ], # List additional groups of dependencies here (e.g. development