Skip to content

Commit

Permalink
Use SparqlImplementation with local queries for ttl format files.
Browse files Browse the repository at this point in the history
Addresses #49
  • Loading branch information
cmungall authored and pkalita-lbl committed May 2, 2022
1 parent a0123b4 commit b9a9df3
Show file tree
Hide file tree
Showing 7 changed files with 5,323 additions and 159 deletions.
3 changes: 2 additions & 1 deletion docs/selectors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ Examples of scheme-less descriptors, implicit implementation:

- :code:`tests/input/go-nucleus.obo` - local obo format file loaded with pronto
- :code:`tests/input/go-nucleus.json` - local obojson format file loaded with pronto
- :code:`tests/input/go-nucleus.owl` - local OWL rdf/xml format file (loaded with pronto at the moment may change)
- :code:`tests/input/go-nucleus.owl` - local OWL rdf/xml format file (loaded with rdflib at the moment may change)
- :code:`tests/input/go-nucleus.owl.ttl` - local OWL turtle format file (loaded with rdflib at the moment may change)
- :code:`tests/input/go-nucleus.db` - local sqlite3 db loaded with SqlImplementation
- :code:`http://purl.obolibrary.org/obo/pato.obo` - NOT IMPLEMENTED; download locally for now
- :code:`http://purl.obolibrary.org/obo/pato.owl` - NOT IMPLEMENTED; download locally for now
Expand Down
203 changes: 52 additions & 151 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ nxontology = "^0.4.0"
pronto = "^2.4.5"
SPARQLWrapper = "^2.0.0"
SQLAlchemy = "^1.4.32"
linkml-runtime = "^1.3.0rc1"
linkml-runtime = "^1.1.9"
networkx = "^2.7.1"
sssom = "^0.3.8"
ratelimit = "^2.2.1"
appdirs = "^1.4.4"
uvicorn = "^0.17.6"
fastapi = "^0.75.2"

[tool.poetry.dev-dependencies]
pytest = "^5.2"
Expand Down
5 changes: 3 additions & 2 deletions src/oaklib/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ def _shorthand_to_pred_curie(shorthand: str) -> PRED_CURIE:
@click.option("-v", "--verbose", count=True)
@click.option("-q", "--quiet")
@input_option
@input_type_option
@add_option
def main(verbose: int, quiet: bool, input: str, add: List):
def main(verbose: int, quiet: bool, input: str, input_type: str, add: List):
"""Run the oaklib Command Line.
A subcommand must be passed - for example: ancestors, terms, ...
Expand All @@ -134,7 +135,7 @@ def main(verbose: int, quiet: bool, input: str, add: List):

if input:
impl_class: Type[OntologyInterface]
resource = get_resource_from_shorthand(input)
resource = get_resource_from_shorthand(input, format=input_type)
impl_class = resource.implementation_class
logging.info(f'RESOURCE={resource}')
settings.impl = impl_class(resource)
Expand Down
5,257 changes: 5,257 additions & 0 deletions tests/input/go-nucleus.owl.ttl

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ def test_check_definitions(self):

def test_lexmatch_owl(self):
outfile = f'{OUTPUT_DIR}/matcher-test-cli.owl.sssom.tsv'
result = self.runner.invoke(main, ['-i', f'{INPUT_DIR}/matcher-test.owl', 'lexmatch', '-R', f'{INPUT_DIR}/matcher_rules.yaml',
result = self.runner.invoke(main, ['-i', f'pronto:{INPUT_DIR}/matcher-test.owl', 'lexmatch',
'-R', f'{INPUT_DIR}/matcher_rules.yaml',
'-o', outfile])
out = result.stdout
err = result.stderr
Expand Down
7 changes: 6 additions & 1 deletion tests/test_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
from oaklib.implementations.ols.ols_implementation import OlsImplementation
from oaklib.implementations.ontobee.ontobee_implementation import OntobeeImplementation
from oaklib.implementations.pronto.pronto_implementation import ProntoImplementation
from oaklib.implementations.sparql.sparql_implementation import SparqlImplementation
from oaklib.implementations.sqldb.sql_implementation import SqlImplementation
from oaklib.implementations.ubergraph import UbergraphImplementation
from oaklib.selector import get_resource_from_shorthand



class TestResource(unittest.TestCase):


Expand All @@ -21,6 +21,11 @@ def test_from_descriptor(self):
self.assertEqual('foo.obo', resource.slug)
resource = get_resource_from_shorthand('foo.owl')
# this may change:
assert resource.implementation_class == SparqlImplementation
resource = get_resource_from_shorthand('foo.ttl')
# this may change:
assert resource.implementation_class == SparqlImplementation
resource = get_resource_from_shorthand('pronto:foo.owl')
assert resource.implementation_class == ProntoImplementation
resource = get_resource_from_shorthand('foo.db')
assert resource.implementation_class == SqlImplementation
Expand Down

0 comments on commit b9a9df3

Please sign in to comment.