Python bindings for the Gen graph database
Project description
Gen
Gen brings version control to genetic sequences. With it, you can track variants and edits to genes or whole genomes, across multiple generations and lineages. You can clone genome repositories, create branches, make edits, and push changes to a shared remote using the same workflow developers know from Git. It works across FASTA files, VCFs, GenBank records, and other common bioinformatics formats. Under the hood, Gen stores data as a sequence graph, allowing a single repository to represent a reference genome, known variants, and engineered modifications without repeatedly storing the same sequence.
Install
Gen client: prebuilt binaries for macOS and Linux are on the releases page: macOS (.pkg), Linux x86_64 (.zip), Linux arm64 (.zip). Gen is built primarily for Unix-like systems; on Windows, you can install WSL to get a Linux environment, then use the Linux binary above from inside it.
Python package: install on macOS, Linux, or Windows using:
pip install gen
Install the jupyter extra to include an interactive graph widget for Jupyter and other anywidget-compatible notebooks:
pip install gen[jupyter]
R package: install on macOS (Apple silicon) using the remotes package:
install.packages("remotes")
remotes::install_url(
"https://github.com/genhub-bio/gen/releases/download/v0.2.0/genr_0.2.0-macos-arm64.tgz"
)
Windows builds are published as genr-windows-<version>.zip on the same releases page.
Quick start
Set up a repository
gen init
gen import fasta reference.fa --reference hg38
Branch, update, and inspect
# Branch before making changes
gen checkout --branch experiment/na12878
# Apply variants from a VCF
gen update vcf variants.vcf --reference hg38 --sample NA12878
# Review the operation log
gen operations
# Browse the graph in the terminal
gen view
Push to a remote
In order to upload data to a remote repository, you have to add a remote repository (call it origin here), log in to authenticate and optionally make it the default remote for this repository, and then run the push command:
gen remote add origin https://www.genhub.bio/api/repos/<user>/<repo>
gen remote login origin
gen remote set-default origin
gen push
Subsequent pushes from this repository only need gen push.
Python and R bindings
The Python package lets you import, edit, and export sequence graphs from Python. The R package covers the same workflows and interoperates with Bioconductor types such as DNAStringSet and GRanges. The jupyter extra adds an interactive widget for graph visualization and exploration. Remote operations (push and pull) require the client for now.
Example Python code to initialize or load a repository, import a sequence as reference, applying variants from a VCF file, and viewing the resulting sequence graph:
import gen
repo = gen.Repository(".")
repo.import_reference_fasta("reference.fa", "hg38")
sample = repo.update_with_vcf("variants.vcf", reference="hg38", sample="NA12878")[0]
sample.plot()
Equivalent R code:
library(genr)
repo <- Repository(".")
repo$import_reference_fasta("reference.fa", reference = "hg38")
sample <- repo$update_with_vcf(filename = "variants.vcf", sample = "NA12878", reference = "hg38")[[1]]
plot(sample)
Features
- Every import, update, and merge is a recorded operation. You can roll back to any prior state with
gen checkout, compare two branches withgen view-diff, or share a set of changes as a patch file. - Gen can import from FASTA, GenBank, GFA, VCF, GAF, and combinatorial part libraries, and export to FASTA, GenBank, or GFA for downstream tools like
vgor Bandage. - Sequence search works across all paths in a graph, including IUPAC ambiguity codes, via
gen searchorrepo.search()in Python and R. - GFF3 annotation tracks are visible in both the terminal viewer and the interactive widget.
- For combinatorial library design, you define a parts list and a slot table; Gen builds the graph of all combinations without enumerating the sequences explicitly.
gen clone,gen push, andgen pullwork against network-mounted filesystems or genhub.bio. Any public repository is clonable with a single URL.- The R package includes direct import from Bioconductor
DNAStringSetandGRangesobjects.
Designed for AI agents
Agents can interact with Gen through the command line or the Python API, which was designed with AI agents in mind. Nearly every user action has a programmatic equivalent, with methods returning samples and sequence graphs as Python objects that can be passed directly into subsequent operations. Graph visualizations in Python notebooks include embedded text representations that LLMs can interpret directly. Because every operation is recorded in the repository, agents can inspect history, compare revisions, and recover from failures.
Screenshots
|
Python: Claude reasons about a DNA graph and its protein translation, concluding that one of two SNPs is silent. |
R: finding a restriction site that stradles the junction between parts, from yeast_expression_library.Rmd.
|
Example workflows
- Model a yeast cross: cross two beer-yeast strains from the 1002 Yeast Genomes collection, building the combined graph from either VCF variant calls or whole-genome alignment.
- Explore a brewing-yeast variant graph in Python: analyse the FLO11 locus on a 9.1 kb S. cerevisiae chrIX fragment, searching and navigating the variant graph in the interactive widget.
- Screen a combinatorial library in R: build a combinatorial YTK expression-cassette library, easily detecting a restriction site that appears only at one part junction, not in any individual part.
Data model
Gen represents sequences as a sequence graph: nodes hold sequence fragments, edges connect them, and any linear sequence is reconstructed by walking a defined path. New variants extend the graph without splitting existing nodes, so node IDs remain stable across updates. This differs from the segment graph model used by tools like vg, where the reference sequence is split into pieces to accommodate each variant; Gen converts between the two formats on GFA export. See docs/coordinates.md for a full explanation with diagrams.
Documentation
Full command reference, Python and R API docs, and tutorials are at genhub.bio/docs.
Building from source
Requires a Rust toolchain (rustup).
git clone https://github.com/genhub-bio/gen.git
cd gen
cargo build --release
# binary at ./target/release/gen
For Python and R bindings, see gen-python/README.md and gen-r/README.md.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gen-0.2.1-cp314-cp314-win_amd64.whl.
File metadata
- Download URL: gen-0.2.1-cp314-cp314-win_amd64.whl
- Upload date:
- Size: 10.0 MB
- Tags: CPython 3.14, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ffeaebdbcb8f3afb2adba3dbcc119c47a73eade790c1547e34b15974b3f59f2
|
|
| MD5 |
81d22a59b9cf0c3978f3f4da6e2d9a71
|
|
| BLAKE2b-256 |
0885198112699c54ba3eb5a20cf2e36cf216dd250f22342ba93c6df7307166f1
|
File details
Details for the file gen-0.2.1-cp314-cp314-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: gen-0.2.1-cp314-cp314-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 11.4 MB
- Tags: CPython 3.14, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
051aeee8f872c375e1d04634cf3440cb609100483f3ade4ed6bb9b3801bd438f
|
|
| MD5 |
cb639613b5f08037835f691a27b157f8
|
|
| BLAKE2b-256 |
2f3dd5db76ee7fafcf06174efc8d9ddf3eb3091c5cd8cdd208ea84760a901744
|
File details
Details for the file gen-0.2.1-cp314-cp314-macosx_11_0_arm64.whl.
File metadata
- Download URL: gen-0.2.1-cp314-cp314-macosx_11_0_arm64.whl
- Upload date:
- Size: 10.3 MB
- Tags: CPython 3.14, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0c07434335bcbe6ad12a310bc1bf35ef8443555922eece9ea341c22fe8002a6
|
|
| MD5 |
0c4054f93fa334789174ed5d80a14f16
|
|
| BLAKE2b-256 |
a328e6af291f14f7ea400913b2565722a9fc9d9942ae54e0a11a36d62f33adbd
|
File details
Details for the file gen-0.2.1-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: gen-0.2.1-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 10.0 MB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec8fed9abd36109795bd03b75d9ffb4e397b4248c9fa16a6dddc350c7398dbad
|
|
| MD5 |
66a9455ed3d726d744b2b72c30492d5a
|
|
| BLAKE2b-256 |
4c65293bc37ca81658fb68538f0f65d8a1e2d8ce0dd5bf2ca5533c529bf75869
|
File details
Details for the file gen-0.2.1-cp313-cp313-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: gen-0.2.1-cp313-cp313-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 11.4 MB
- Tags: CPython 3.13, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
452a60ec53925663dcd79fd7094dc9ba02d3288caad7b9aa3f13fa81b04b963f
|
|
| MD5 |
6e28bc6ac4099baaec56e323e69ba80c
|
|
| BLAKE2b-256 |
6e9cdc871a819bb4b825fb3eac108423ff6ec89af9508ef51f5c68a8b1575a06
|
File details
Details for the file gen-0.2.1-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: gen-0.2.1-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 10.3 MB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
832bb5e4975ae57f7c37573877f425261a9c6b1a7dc45f15912abe06e55f4f9c
|
|
| MD5 |
064f0ce8caecdbe9be696bf491ffe85e
|
|
| BLAKE2b-256 |
4efe9caf450aa1503cdd5d24df4edc99487372ec2913f5a571ce5886fb22f47e
|
File details
Details for the file gen-0.2.1-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: gen-0.2.1-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 10.0 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21680376a0b220524a4e1d4132218a63cd3ee8b575b59b1b3caa17b9273faa7e
|
|
| MD5 |
4ab36889caa30d08805d63a0e94441c6
|
|
| BLAKE2b-256 |
286922bf858d00adf6d7fef84d956306a0e71f224020ac97cca1a708eb8fe0de
|
File details
Details for the file gen-0.2.1-cp312-cp312-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: gen-0.2.1-cp312-cp312-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 11.4 MB
- Tags: CPython 3.12, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f37a054cee33af3671795f6aac8678a97395e6d67083aa9726f050169447dab
|
|
| MD5 |
4ea713e69d12a14f48eb52ec7f8aec12
|
|
| BLAKE2b-256 |
c855e361c0c8466c7504706ba5e79b1867c817ed9d62f18b108298bf2c0e9518
|
File details
Details for the file gen-0.2.1-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: gen-0.2.1-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 10.3 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0deb5d3a711871441ba536e56a8bd2fae52213a2c4520fc674f0e6077a2e114e
|
|
| MD5 |
5c715d0bf036fb0692bad06c2b049c56
|
|
| BLAKE2b-256 |
382b8842a3e58003870380a3759ee62d0dfebb1ff3e8f8f76e0a41e4f1ecfce8
|
File details
Details for the file gen-0.2.1-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: gen-0.2.1-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 10.0 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8447fc5cdc4c218d425a0d5e57d59e654f41dc02bb70f1b18bc596da9c1dd60
|
|
| MD5 |
ee80403cc4e29cfe5a8805d61a5ada08
|
|
| BLAKE2b-256 |
ca73f68bdc17c90b72a399642fe312018f21fa4c718e6bdc7c892174092ea481
|
File details
Details for the file gen-0.2.1-cp311-cp311-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: gen-0.2.1-cp311-cp311-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 11.4 MB
- Tags: CPython 3.11, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c27bf29f71126faef70ac25eccdba5db309be898165a1a22ab52e2e4f8d6d881
|
|
| MD5 |
a2759b287a38ee000d65b8e99ed37603
|
|
| BLAKE2b-256 |
5891581fb442033730191a6c7ad6a1f36b592c87d313daa928dbc2c4d0907cb3
|
File details
Details for the file gen-0.2.1-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: gen-0.2.1-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 10.3 MB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e57e7e74366ae0af12fc127a35eacf16f6b86d4cad2efe19ff90eafe9874b8b3
|
|
| MD5 |
13f26babe6756694b7101d72f3eefd12
|
|
| BLAKE2b-256 |
e39e711fc5b76969f35e014390f0510e00ae8c61266939c559e667ab78fcfd67
|