Skip to main content

A Python package to import ChEBI data in MySQL and Neo4J

Project description

-ChEBI

  • allows to import ChEBI into relational database (like MySQL, sqlite, POSTGres), create RDF triples (turtles) and import the triples into graph database (Neo4J).
  • Provides REST API and CLI to run the steps.
  • is part of the biokb python package family which allow to combine knowledge graphs from different domain in the context of biology and medicine.

Installation

If uv is installed:

uv venv
source .venv/bin/activate
uv pip install biokb_chebi

Otherwise:

python3 -m venv .venv
source .venv/bin/activate
pip install biokb_chebi

Quick Start

biokb_chebi run-api

http://localhost:8000/docs#/

  1. Import data
  2. Export ttls
  3. Import Neo4J

Create turtles and import into Neo4J

For docker just replace podman with docker in the commands below.

biokb_chebi create-ttls
podman run -d --rm --name biokb-neo4j -p7474:7474 -p7687:7687 -e NEO4J_AUTH=neo4j/neo4j_password neo4j:latest
# Remove `--rm` if you want to keep the container after stopping it.
# wait a bit until Neo4J is started
biokb_chebi import-neo4j -p neo4j_password

http://localhost:7474 (user/password: neo4j/neo4j_password)

podman stop biokb-neo4j

Run as Podman/ Docker container

For docker just replace podman with docker in the commands below.

Build & run with Podman:

git clone https://github.com/biokb/biokb_chebi.git
cd biokb_chebi
podman build -t biokb_chebi .
podman run -d --rm --name biokb_chebi -p 8000:8000 biokb_chebi
  • Login: admin
  • Password: admin

With environment variable for user and password for more security:

podman run -d --rm --name biokb_chebi -p 8000:8000 -e API_PASSWORD=your_secure_password -e API_USER=your_secure_user biokb_chebi

http://localhost:8000/docs

On the website:

  1. Import data
  2. http://localhost:8000/docs#/Database%20Management/get_report_export_ttls__get

Neo4j import in this context is not possible because Neo4J is not running as service.

Run as Podman/Docker networked containers with Neo4J and MySQL

Build & run with Docker:

git clone https://github.com/biokb/biokb_chebi.git
cd biokb_chebi
podman-compose -f docker-compose.db_neo.yml --env-file .env_template up -d

http://localhost:8000/docs

stop with:

docker stop biokb_chebi

rerun with:

docker start biokb_chebi

Run with MySQL and Neo4J as podman-compose services

git clone https://github.com/biokb/biokb_chebi.git
cd biokb_chebi 
podman-compose -f docker-compose.db_neo.yml --env-file .env_template up -d
podman-compose --env-file .env_template up -d

In production copy .env_template to .env and use secure passwords (and skip --env-file .env_template in the last command)!

podman-compose -f docker-compose.db_neo.yml --env-file .env_template up -d
podman-compose --env-file .env_template up -d

http://localhost:8001/docs

On the website:

  1. Import data
  2. Export ttls
  3. Import Neo4J

CLI

Install with

pip install biokb_chebi

Import data into relational database

Usage: biokb_chebi import-data [OPTIONS]

biokb_chebi import-data

-> SQLite database in ~/.biokb/biokb.db. Open with e.g. DB Browser for SQLite

Option long Description default
-f --force-download Force re-download of the source file False
-k --keep-files Keep downloaded source files after import False
-c --connection-string TEXT SQLAlchemy engine URL sqlite:///chebi.db

If you want to use different relational database (MySQL, PostgreSQL, etc.), provide the connection string with -c option. Examples:

  • MySQL: mysql+pymysql://user:password@localhost/biokb
  • PostgreSQL: postgresql+psycopg2://user:password@localhost/biokb

For more examples please check how to create database URLs

Create RDF turtles

Usage: biokb_chebi create-ttls [OPTIONS]

biokb_chebi create-ttls

-> RDF turtles will be created in ~/.biokb/chebi/data/ttls.zip

Option long Description default
-c --connection-string TEXT SQLAlchemy engine URL sqlite:///chebi.db

Import into Neo4J

Start Neo4J ...

podman run --rm --name biokb-neo4j-test -p7474:7474 -p7687:7687 -e NEO4J_AUTH=neo4j/neo4j_password neo4j:latest

Note: Remove --rm if you want to keep the container after stopping it. Replace podman with docker if you use Docker.

... and import into Neo4J:

biokb_chebi import-neo4j -p neo4j_password
Option long Description default
-i --uri Neo4j database URI bolt://localhost:7687
-u --user Neo4j username neo4j
-p --password Neo4j password

http://localhost:7474 (user/password: neo4j/neo4j_password)

For testing you can install from TestPyPI:

uv venv
source venv/bin/activate
uv pip install --no-cache-dir -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ biokb-chebi==0.1.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

biokb_chebi-0.1.0.tar.gz (471.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

biokb_chebi-0.1.0-py3-none-any.whl (24.9 kB view details)

Uploaded Python 3

File details

Details for the file biokb_chebi-0.1.0.tar.gz.

File metadata

  • Download URL: biokb_chebi-0.1.0.tar.gz
  • Upload date:
  • Size: 471.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for biokb_chebi-0.1.0.tar.gz
Algorithm Hash digest
SHA256 80efd561b0021b739e296a5bb75c863503c861a83e7683d7dcb158e262b6bd9c
MD5 3d8b2bd9f9c5f09eabc44b5c32d9f60f
BLAKE2b-256 c8eb860d4ff661da9a16f469cbdbc96363b818826c5da9dcbba5d5637225212f

See more details on using hashes here.

Provenance

The following attestation bundles were made for biokb_chebi-0.1.0.tar.gz:

Publisher: pypi-publish.yml on biokb/biokb_chebi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file biokb_chebi-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: biokb_chebi-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 24.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for biokb_chebi-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c1e7eb0b74cfd0fae32d9b413b8f72deeb991f0b60cd3c0ce9a710765c2ea949
MD5 30091f598a42de07d7047778e9600665
BLAKE2b-256 9569e1aaf2e4de2a78165457960f48de074333f09f1f2ae69d8f356fd018a2ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for biokb_chebi-0.1.0-py3-none-any.whl:

Publisher: pypi-publish.yml on biokb/biokb_chebi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page