Metadata-Version: 2.4
Name: rdfsolve
Version: 0.0.2
Summary: Wraps several RDF schema solver tools
Author-email: Javier Millán Acosta <javier.millanacosta@maastrichtuniversity.nl>
Maintainer-email: Javier Millán Acosta <javier.millanacosta@maastrichtuniversity.nl>
License: MIT License
        
        Copyright (c) 2024 Javier Millán Acosta
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Bug Tracker, https://github.com/jmillanacosta/rdfsolve/issues
Project-URL: Homepage, https://github.com/jmillanacosta/rdfsolve
Project-URL: Repository, https://github.com/jmillanacosta/rdfsolve.git
Project-URL: Documentation, https://rdfsolve.readthedocs.io
Keywords: snekpack,cookiecutter
Classifier: Development Status :: 1 - Planning
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Framework :: Pytest
Classifier: Framework :: tox
Classifier: Framework :: Sphinx
Classifier: Natural Language :: English
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: rdflib>=6.0.0
Requires-Dist: sparqlwrapper>=2.0.0
Requires-Dist: pandas>=2.0.0
Requires-Dist: numpy
Requires-Dist: bioregistry>=0.13.25
Requires-Dist: bioversions>=0.8.295
Requires-Dist: linkml>=1.10.0
Requires-Dist: linkml-runtime>=1.10.0
Requires-Dist: deprecated>=1.2.13
Requires-Dist: pyld
Requires-Dist: more_itertools
Requires-Dist: tqdm
Requires-Dist: pyyaml>=6.0
Requires-Dist: pyarrow==22.0.0
Requires-Dist: click
Requires-Dist: more_click
Requires-Dist: flask
Requires-Dist: pyobo>=0.12.16
Requires-Dist: semra>=0.1.4
Provides-Extra: tests
Requires-Dist: pytest; extra == "tests"
Requires-Dist: coverage; extra == "tests"
Provides-Extra: docs
Requires-Dist: sphinx>=8; extra == "docs"
Requires-Dist: sphinx-rtd-theme>=3.0; extra == "docs"
Requires-Dist: sphinx-click; extra == "docs"
Requires-Dist: sphinx-automodapi; extra == "docs"
Provides-Extra: dev
Requires-Dist: ruff; extra == "dev"
Provides-Extra: web
Requires-Dist: flask>=3.0; extra == "web"
Requires-Dist: flask-cors>=4.0; extra == "web"
Requires-Dist: gunicorn>=22.0; extra == "web"
Provides-Extra: notebooks
Requires-Dist: matplotlib>=3.10.7; extra == "notebooks"
Requires-Dist: seaborn>=0.11.0; extra == "notebooks"
Requires-Dist: plotly>=5.0.0; extra == "notebooks"
Requires-Dist: networkx>=2.8; extra == "notebooks"
Requires-Dist: jupyterlab>=4.0.0; extra == "notebooks"
Requires-Dist: ipywidgets>=8.0.0; extra == "notebooks"
Requires-Dist: narwhals==2.11.0; extra == "notebooks"
Requires-Dist: plotly==6.4.0; extra == "notebooks"
Dynamic: license-file

# RDFSolve

<p align="center">
    <a href="https://github.com/jmillanacosta/rdfsolve/actions/workflows/tests.yml">
        <img alt="Tests" src="https://github.com/jmillanacosta/rdfsolve/actions/workflows/tests.yml/badge.svg" /></a>
    <a href="https://pypi.org/project/rdfsolve">
        <img alt="PyPI" src="https://img.shields.io/pypi/v/rdfsolve" /></a>
    <a href="https://pypi.org/project/rdfsolve">
        <img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/rdfsolve" /></a>
    <a href="https://github.com/jmillanacosta/rdfsolve/blob/main/LICENSE">
        <img alt="PyPI - License" src="https://img.shields.io/pypi/l/rdfsolve" /></a>
    <a href='https://rdfsolve.readthedocs.io/en/latest/?badge=latest'>
        <img src='https://readthedocs.org/projects/rdfsolve/badge/?version=latest' alt='Documentation Status' /></a>
</p>

Extract RDF schemas from SPARQL endpoints, convert between formats
(JSON-LD, LinkML, SHACL, VoID, RDF-config), and derive cross-dataset mappings.

Dashboard (static demo): [jmillanacosta.github.io/rdfsolve-frontend](https://jmillanacosta.github.io/rdfsolve-frontend)

## Installation

```bash
uv pip install rdfsolve
```

## CLI

```text
rdfsolve [--verbose] <group> <command> [OPTIONS]
```

### Schema mining (`pipeline`)

```bash
# Mine schemas from remote SPARQL endpoints listed in sources.yaml
rdfsolve pipeline mine --sources data/sources.yaml

# Mine a single source from a local QLever endpoint
rdfsolve pipeline local-mine --name drugbank --endpoint http://localhost:7026

# Generate Qleverfiles for local QLever instances
rdfsolve pipeline qleverfile --data-dir /data/rdf
```

### Format conversion (`export`)

Convert any VoID `.ttl` or rdfsolve `.jsonld` schema to another format
(auto-detected from extension):

```bash
rdfsolve export csv       schema.jsonld
rdfsolve export jsonld    void.ttl
rdfsolve export void      schema.jsonld
rdfsolve export linkml    schema.jsonld -o ./out
rdfsolve export shacl     schema.jsonld --closed
rdfsolve export rdfconfig void.ttl --endpoint-url https://sparql.example.org
```

### Web backend

A Flask REST API exposes schemas, SPARQL query generation, IRI resolution, export,
mappings, and SHACL/LinkML conversion over HTTP. It can also serve the
[rdfsolve-frontend](https://github.com/jmillanacosta/rdfsolve-frontend) app.

```bash
# Quick start with Docker
docker compose up --build        # http://localhost:8000

# Or run directly
python -m rdfsolve.backend.app   # uses env vars for config
```

Key endpoints: `/api/schemas`, `/api/sparql`, `/api/export`, `/api/shapes`,
`/api/mappings`, `/api/linkml`, `/api/compose`.

## Python API

```python
from rdfsolve.api import mine_schema, load_parser_from_file

# Mine a schema from a SPARQL endpoint
result = mine_schema(
    name="rhea",
    endpoint_url="https://sparql.rhea-db.org/sparql",
)

# Load a previously mined schema and convert
parser = load_parser_from_file("rhea_schema.jsonld")
parser.to_schema()       # pandas DataFrame
parser.to_jsonld()       # JSON-LD dict
parser.to_linkml_yaml()  # LinkML YAML string
parser.to_shacl()        # SHACL Turtle string
```

## Documentation

Full docs: [rdfsolve.readthedocs.io](https://rdfsolve.readthedocs.io)

## License

MIT — see [LICENSE](LICENSE).
