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

Test pioxigraph #49

Merged
merged 3 commits into from
Nov 7, 2023
Merged
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
4 changes: 2 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies:
- ase
- ipycytoscape
- networkx
- sqlalchemy <2.0.0
- rdflib-sqlalchemy
- pyoxigraph
- oxrdflib
- pandas
- owlready2
24 changes: 10 additions & 14 deletions pyscal_rdf/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,33 +54,29 @@ class RDFGraph:
def __init__(self, graph_file=None,
store="Memory",
store_file=None,
identifier="default_graph"):
identifier="http://default_graph"):

#owlfile = os.path.join(os.path.dirname(__file__), "data/cmso.owl")
#self.graph.parse(owlfile, format='xml')
if store == "Memory":
self.graph = Graph(store="Memory", identifier=identifier)

elif store=="SQLAlchemy":
if store_file is None:
raise ValueError("store file is needed if store is not memory")
self.graph = Graph(store="SQLAlchemy", identifier=identifier)
uri = Literal(f"sqlite:///{store_file}")
self.graph.open(uri, create=True)

elif store=="Oxigraph":
self.graph = Graph(store="Oxigraph", identifier=identifier)
if store_file is not None:
self.graph.open(store_file)

elif inspect.isclass(type(store)):
try:
prpath = store.path
dbfile = os.path.join(prpath, 'project.db')
#now start sqlalchemy instance
self.graph = Graph(store="SQLAlchemy", identifier=identifier)
uri = Literal(f"sqlite:///{dbfile}")
self.graph.open(uri, create=True)
self.graph = Graph(store="Oxigraph", identifier=identifier)
self.graph.open(prpath)
except:
raise ValueError("store should be pyiron_project, SQLAlchemy, or Memory")
raise ValueError("store should be pyiron_project, Oxigraph, or Memory")

else:
raise ValueError("store should be pyiron_project, SQLAlchemy, or Memory")
raise ValueError("store should be pyiron_project, Oxigraph, or Memory")

self.graph.bind("cmso", CMSO)
self.graph.bind("pldo", PLDO)
Expand Down
2 changes: 1 addition & 1 deletion pyscal_rdf/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class StructureGraph(RDFGraph):
def __init__(self, graph_file=None,
store="Memory",
store_file=None,
identifier="default_graph"):
identifier="http://default_graph"):

super().__init__(graph_file=graph_file, store=store, store_file=store_file, identifier=identifier)
self._element_dict = element_dict
Expand Down
Loading