From aa525c434a94e1931a3e85fb20130ab94f945610 Mon Sep 17 00:00:00 2001 From: Bryan Bartley Date: Mon, 25 Apr 2022 09:08:31 -0700 Subject: [PATCH 1/2] Support PAML --- .gitmodules | 3 +++ setup.py | 6 ++++-- test/test_ontology.py | 4 ++++ tyto/__init__.py | 2 ++ tyto/ontologies/paml | 1 + tyto/paml.py | 6 ++++++ tyto/uml.py | 6 ++++++ 7 files changed, 26 insertions(+), 2 deletions(-) create mode 160000 tyto/ontologies/paml create mode 100644 tyto/paml.py create mode 100644 tyto/uml.py diff --git a/.gitmodules b/.gitmodules index 7264e4c..b89ab87 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "tyto/ontologies/sbol-owl"] path = tyto/ontologies/sbol-owl url = https://github.com/dissys/sbol-owl.git +[submodule "tyto/ontologies/paml"] + path = tyto/ontologies/paml + url = git@github.com:bioprotocols/paml.git diff --git a/setup.py b/setup.py index e08afa1..f0b61af 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ from setuptools import setup, find_packages setup(name='tyto', - version='1.1', + version='1.2', description='Automatically generates Python symbols for ontology terms', python_requires='>=3.6', url='https://github.com/SynBioDex/tyto', @@ -33,7 +33,9 @@ 'ontologies/*.rdf', 'ontologies/*.ttl', 'ontologies/sbol-owl3/sbolowl3.rdf', - 'ontologies/sbol-owl/sbol.rdf']}, + 'ontologies/sbol-owl/sbol.rdf', + 'ontologies/paml/paml/paml.ttl', + 'ontologies/paml/uml/uml.ttl']}, include_package_data=True, install_requires=[ 'rdflib>=5.0', diff --git a/test/test_ontology.py b/test/test_ontology.py index a4e8ce0..200c0c7 100644 --- a/test/test_ontology.py +++ b/test/test_ontology.py @@ -181,6 +181,10 @@ def test_pubchem(self): # Ambiguous term matches many SIDs PubChem['water'] +class TestPAML(unittest.TestCase): + + def test_paml(self): + self.assertEqual(PAML.SampleArray, 'http://bioprotocols.org/paml#SampleArray') if __name__ == '__main__': unittest.main() diff --git a/tyto/__init__.py b/tyto/__init__.py index e13accd..3fec9f1 100644 --- a/tyto/__init__.py +++ b/tyto/__init__.py @@ -9,3 +9,5 @@ from .sbol3 import SBOL3 from .edam import EDAM from .pubchem import PubChem +from .paml import PAML +from .uml import UML diff --git a/tyto/ontologies/paml b/tyto/ontologies/paml new file mode 160000 index 0000000..96fdd66 --- /dev/null +++ b/tyto/ontologies/paml @@ -0,0 +1 @@ +Subproject commit 96fdd666991a68a34db1f71774fb7f72952ac93a diff --git a/tyto/paml.py b/tyto/paml.py new file mode 100644 index 0000000..430cd0a --- /dev/null +++ b/tyto/paml.py @@ -0,0 +1,6 @@ +from .tyto import Ontology, installation_path + + +PAML = Ontology(path=installation_path('ontologies/paml/paml/paml.ttl'), + uri='http://bioprotocols.org/paml#') + diff --git a/tyto/uml.py b/tyto/uml.py new file mode 100644 index 0000000..2fcf390 --- /dev/null +++ b/tyto/uml.py @@ -0,0 +1,6 @@ +from .tyto import Ontology, installation_path + + +UML = Ontology(path=installation_path('ontologies/paml/uml/uml.ttl'), + uri='http://bioprotocols.org/uml#') + From 83afcc055c569b93095c55e361a553c42e5739e0 Mon Sep 17 00:00:00 2001 From: Bryan Bartley Date: Mon, 25 Apr 2022 09:28:11 -0700 Subject: [PATCH 2/2] Configure GraphEndpoint to parse turtle --- tyto/endpoint/endpoint.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tyto/endpoint/endpoint.py b/tyto/endpoint/endpoint.py index a1bf08b..d86335e 100644 --- a/tyto/endpoint/endpoint.py +++ b/tyto/endpoint/endpoint.py @@ -242,7 +242,10 @@ def is_loaded(self): return bool(self.graph) def load(self): - self.graph.parse(self.path) + if self.path.split('.')[-1] == 'ttl': + self.graph.parse(self.path, format='ttl') + else: + self.graph.parse(self.path) def query(self, ontology, sparql, err_msg): sparql_final = sparql.format(from_clause='') # Because only one ontology per file, delete the from clause