Skip to content

Commit

Permalink
Merge pull request #49 from pyscal/test_pioxigraph
Browse files Browse the repository at this point in the history
Test pioxigraph
  • Loading branch information
srmnitc authored Nov 7, 2023
2 parents 388dc53 + eb4b693 commit 72efb20
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
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

0 comments on commit 72efb20

Please sign in to comment.