Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use fastobo to load ontologies from OBO files #360

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions ontobio/ontol_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import os
import subprocess
import hashlib
import fastobo


# TODO
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ pydotplus>=0.0
plotly==2.0.7
pyyaml
yamldown>=0.1.7
click
fastobo~=0.3.1
click
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down