Metadata-Version: 2.4
Name: momapy_kb
Version: 0.4.0
Summary: Momapy maps to KB
Author-email: Adrien Rougny <adrienrougny@gmail.com>
License: GPL-3.0-or-later
License-File: COPYING
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
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.14
Requires-Python: >=3.10
Requires-Dist: colorama>=0.4.6
Requires-Dist: fieldz-kb>=0.3.1
Requires-Dist: frozendict>=2.4.6
Requires-Dist: jinja2>=3.1.3
Requires-Dist: momapy>=0.13.0
Provides-Extra: all
Requires-Dist: fieldz-kb[clingo]; extra == 'all'
Requires-Dist: fieldz-kb[falkordb]; extra == 'all'
Requires-Dist: fieldz-kb[falkordblite]; extra == 'all'
Requires-Dist: fieldz-kb[neo4j]; extra == 'all'
Provides-Extra: clingo
Requires-Dist: fieldz-kb[clingo]; extra == 'clingo'
Provides-Extra: falkordb
Requires-Dist: fieldz-kb[falkordb]; extra == 'falkordb'
Provides-Extra: falkordblite
Requires-Dist: fieldz-kb[falkordblite]; extra == 'falkordblite'
Provides-Extra: neo4j
Requires-Dist: fieldz-kb[neo4j]; extra == 'neo4j'
Description-Content-Type: text/markdown

# momapy_kb

[![License](https://img.shields.io/github/license/adrienrougny/momapy_kb)](<https://github.com/adrienrougny/momapy_kb/blob/main/COPYING>)

A library to integrate [momapy](https://github.com/adrienrougny/momapy) maps into graph databases and logic programming backends.

## Features

- **Multiple LPG backends** -- Neo4j, FalkorDB, FalkorDBLite (embedded), via [fieldz_kb](https://github.com/adrienrougny/fieldz_kb)
- **Clingo/ASP backend** -- convert maps to logic programming facts
- **File-based loading** -- save maps directly from CellDesigner, SBGN, and SBML files
- **Collection management** -- organize maps into named collections
- **Custom type plugins** -- handles momapy-specific types (LayoutModelMapping, NoneValue, FrozenSurjectionDict)
- **Layout element queries** -- query model elements and retrieve corresponding layout elements for rendering

## Installation

```bash
pip install momapy-kb[neo4j]        # Neo4j support
pip install momapy-kb[falkordb]     # FalkorDB support
pip install momapy-kb[falkordblite] # FalkorDBLite (embedded) support
pip install momapy-kb[clingo]       # Clingo/ASP support
pip install momapy-kb[all]          # Everything
```

## Quick example

```python
import momapy_kb.lpg.session
import momapy_kb.lpg.backends.neo4j

backend = momapy_kb.lpg.backends.neo4j.Neo4jBackend(
    hostname="localhost",
    username="neo4j",
    password="password",
)

with momapy_kb.lpg.session.Session(backend) as session:
    # Save a map from a CellDesigner file
    session.save_from_file("model.xml", integration_mode="hash")

    # Query model elements
    results = session.execute_query_as_objects(
        "MATCH (n:Macromolecule) RETURN n"
    )

    # Get layout elements for rendering
    layout_results = session.execute_query_as_layout_elements(
        "MATCH (n:GenericProcess) RETURN n"
    )
```

## Demo

A Jupyter notebook walking through storing, querying, and rendering maps with Neo4j is available at `demos/neo4j/main.ipynb`. It requires a running Neo4j server:

```bash
docker run -p 7474:7474 -p 7687:7687 -e NEO4J_AUTH=neo4j/password neo4j:5
```

To run the demo locally:

```bash
git clone https://github.com/adrienrougny/momapy_kb.git
cd momapy_kb
pip install .[neo4j] momapy[notebook] jupyter
jupyter notebook demos/neo4j/main.ipynb
```

The demo includes example data (`demos/neo4j/data/`) that is only available in the repository.

## Documentation

Full documentation is available at [https://adrienrougny.github.io/momapy_kb/](https://adrienrougny.github.io/momapy_kb/).
