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

SQLImpl() does not download ontology? #90

Closed
matentzn opened this issue Jun 2, 2022 · 7 comments · Fixed by #292
Closed

SQLImpl() does not download ontology? #90

matentzn opened this issue Jun 2, 2022 · 7 comments · Fixed by #292
Labels
bug Something isn't working

Comments

@matentzn
Copy link
Contributor

matentzn commented Jun 2, 2022

from oaklib.resource import OntologyResource
from oaklib.implementations.sqldb.sql_implementation import SqlImplementation
resource = OntologyResource(slug='mondo.obo', local=False)
oi = SqlImplementation(resource)

results in:

ArgumentError: Could not parse rfc1738 URL from string 'mondo.obo'

Same works with prontoimpl

@matentzn
Copy link
Contributor Author

matentzn commented Jun 2, 2022

I guess I was missing a piece.. It needs to be a SQL db, cant be an arbitrary obo/owl file.. Now looking for how to convert first.

This also wont work:

resource = OntologyResource(slug='sqlite:mondo.db', local=False)

How do I convert a local obo file into a db file? Assuming that is what the issue is I mean.

@cmungall
Copy link
Collaborator

cmungall commented Jun 2, 2022 via email

@matentzn
Copy link
Contributor Author

matentzn commented Jun 2, 2022

Cant get it to work, like this?

resource = OntologyResource(slug='mondo.owl', local=True)
oi = SqlImplementation(resource)

@cmungall
Copy link
Collaborator

cmungall commented Jun 2, 2022

I believe that should work

@matentzn
Copy link
Contributor Author

matentzn commented Jun 2, 2022

from oaklib.resource import OntologyResource
from oaklib.implementations.sqldb.sql_implementation import SqlImplementation
import os
print(os.path.exists('mondo.owl'))
resource = OntologyResource(slug='mondo.owl', local=True)
oi = SqlImplementation(resource)

Results in

True
---------------------------------------------------------------------------
ArgumentError                             Traceback (most recent call last)
<ipython-input-26-3f3e82a428e8> in <module>
      1 print(os.path.exists('mondo.owl'))
      2 resource = OntologyResource(slug='mondo.owl', local=True)
----> 3 oi = SqlImplementation(resource)

~/opt/anaconda3/lib/python3.8/site-packages/oaklib/implementations/sqldb/sql_implementation.py in __init__(self, resource, strict, engine, _session, _connection, **_kwargs)

~/opt/anaconda3/lib/python3.8/site-packages/oaklib/implementations/sqldb/sql_implementation.py in __post_init__(self)
     40     def __post_init__(self):
     41         if self.engine is None:
---> 42             self.engine = create_engine(self.resource.slug)  ## TODO
     43 
     44 

<string> in create_engine(url, **kwargs)

~/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/util/deprecations.py in warned(fn, *args, **kwargs)
    307                         stacklevel=3,
    308                     )
--> 309             return fn(*args, **kwargs)
    310 
    311         doc = fn.__doc__ is not None and fn.__doc__ or ""

~/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/engine/create.py in create_engine(url, **kwargs)
    528 
    529     # create url.URL object
--> 530     u = _url.make_url(url)
    531 
    532     u, plugins, kwargs = u._instantiate_plugins(kwargs)

~/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/engine/url.py in make_url(name_or_url)
    729 
    730     if isinstance(name_or_url, util.string_types):
--> 731         return _parse_rfc1738_args(name_or_url)
    732     else:
    733         return name_or_url

~/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/engine/url.py in _parse_rfc1738_args(name)
    790 
    791     else:
--> 792         raise exc.ArgumentError(
    793             "Could not parse rfc1738 URL from string '%s'" % name
    794         )

ArgumentError: Could not parse rfc1738 URL from string 'mondo.owl'

@cmungall
Copy link
Collaborator

cmungall commented Jun 2, 2022

try with the latest version from 2 days ago

from your stacktrace that seems to be a (quite) old version?

this is what post_init looks like now:

https://github.com/INCATools/ontology-access-kit/blob/v0.1.19/src/oaklib/implementations/sqldb/sql_implementation.py#L103-L116

this is my output:

➜  mondo-build git:(minor-edits) ✗ /Users/cjm/Library/Caches/pypoetry/virtualenvs/oaklib-OeQZizwE-py3.9/bin/python t.py
True
cat /Users/cjm/Library/Caches/pypoetry/virtualenvs/oaklib-OeQZizwE-py3.9/lib/python3.9/site-packages/semsql/builder//sql_schema/semsql.sql | sqlite3 .template.db.tmp && \
        echo .exit | sqlite3 -echo .template.db.tmp -cmd ".mode csv" -cmd ".import /Users/cjm/Library/Caches/pypoetry/virtualenvs/oaklib-OeQZizwE-py3.9/lib/python3.9/site-packages/semsql/builder//prefixes/prefixes.csv prefix" && \
        mv .template.db.tmp .template.db
.exit
robot remove -i mondo.owl --axioms "equivalent disjoint annotation" -o mondo-min.owl
relation-graph --disable-owl-nothing true \
                       --ontology-file mondo-min.owl\
                       --output-file mondo-relation-graph.tsv.ttl.tmp \
                       --equivalence-as-subclass true \
                       --output-subclasses true \
                       --reflexive-subclasses true && \
        riot --out RDFXML mondo-relation-graph.tsv.ttl.tmp > mondo-relation-graph.tsv.owl.tmp && \
        sqlite3 mondo-relation-graph.tsv.db.tmp -cmd ".mode csv" ".import /Users/cjm/Library/Caches/pypoetry/virtualenvs/oaklib-OeQZizwE-py3.9/lib/python3.9/site-packages/semsql/builder//prefixes/prefixes.csv prefix" && \
        rdftab mondo-relation-graph.tsv.db.tmp < mondo-relation-graph.tsv.owl.tmp && \
        sqlite3 mondo-relation-graph.tsv.db.tmp -cmd '.separator "\t"' -cmd '.header on' "SELECT subject,predicate,object FROM statements " > mondo-relation-graph.tsv.tmp && \
        mv mondo-relation-graph.tsv.tmp mondo-relation-graph.tsv && \
        rm mondo-relation-graph.tsv.*.tmp
2022.06.02 14:22:35:933 zio-default-async-1 INFO org.renci.relationgraph.Main.program:57
    Running reasoner
2022.06.02 14:22:48:433 zio-default-async-1 INFO org.renci.relationgraph.Main.program:60
    Done running reasoner
2022.06.02 14:23:42:579 zio-default-async-16 INFO org.renci.relationgraph.Main.program:70
    Computed relations in 54.116s
cp .template.db mondo.db.tmp && \
        rdftab mondo.db.tmp < mondo.owl && \
        sqlite3 mondo.db.tmp -cmd '.separator "\t"' ".import mondo-relation-graph.tsv entailed_edge" && \
        gzip -f mondo-relation-graph.tsv && \
        cat /Users/cjm/Library/Caches/pypoetry/virtualenvs/oaklib-OeQZizwE-py3.9/lib/python3.9/site-packages/semsql/builder//indexes/*.sql | sqlite3 mondo.db.tmp && \
        mv mondo.db.tmp mondo.db
rm mondo-min.owl

@cmungall cmungall added the bug Something isn't working label Jun 30, 2022
@joeflack4
Copy link
Contributor

joeflack4 commented Aug 5, 2022

I had some other issues here, but I moved them to #294 , as I think they are unrelated to this issue.

cmungall added a commit that referenced this issue Sep 24, 2022
* Add option to filter owl tautologies

* Raise exception if path to sqlite db does not exist, fixes #90

* moving towards general compliance suite, #291

* Renaming check-definitions to validate-definitions. #30

* ability to filter owl tautologies.

Adding missing predicate filter for
abstract_sparql_implementation.py

* lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants