Skip to main content

xenosite.forest

Python implementation of Metabolic Forest: enumerate explicit metabolite structures from reaction rules, and search pathways that connect a reactant to a putative product.

Site-of-metabolism prediction models (epoxidation, quinonation, Phase I, reactivity, and others) are on the web at xenosite.org. This package is the structure-enumeration engine, not those neural-network models.

If you use this software, please cite the Metabolic Forest paper (DOI and BibTeX below).

Install

uv add xenosite-forest

or

pip install xenosite-forest

The default install is the Rust chematic door (no RDKit). For the RDKit reference engine and the frozen 0.6.x archive:

uv add "xenosite-forest[rdkit]"

Optional NetworkX helpers for building a metabolite graph:

uv add "xenosite-forest[network]"

Optional xenosite-predict (site-of-metabolism models; Python ≥3.11). Not installed in this repo’s CI:

uv add "xenosite-forest[predict]"

Requires Python 3.11–3.14. RDKit 2022.03+ only with the [rdkit] extra.

A WASM-clean Rust crate (chematic + canonaut) lives in crates/xenosite-forest. See docs/forest/RUST.md and docs/forest/MIGRATING_0.8.md.

Quick start

from xenosite.forest import find_path, PhaseOne, Epoxidation

hits, counters = find_path("CC", "CCO", max_paths=1)
print(hits[0]["steps"], counters["billed"])

RDKit reference engine (requires [rdkit]):

from rdkit import Chem
from xenosite.forest.native import bfs, rules, PhaseOneRS

smiles, steps, mols = next(bfs(["CCO", "CC=O"], ruleset="PhaseOneRS"))
print(smiles, steps)

for products, info in rules.Hydroxylation().metabolize(Chem.MolFromSmiles("CCC")):
    print(info["site"], [p.xf.csmi for p in products])

A longer walkthrough is in examples/tutorial.ipynb. API notes are in docs/usage.md. Rulesets and their papers are in docs/rulesets.md.

Command line

Requires the [rdkit] extra (temporary native bridge until a Rust CLI ships):

xenosite-forest CCO CC=O --ruleset PhaseOneRS --depth 1

Useful flags: --all-paths, --depth N, --phase1 (Phase I site strings), --max N, --ruleset NAME.

Rulesets and papers

Pass these names to bfs(..., ruleset=...) or load_ruleset(...). Full rule lists, Rainbow colors/hex codes, aliases, and BibTeX are in docs/rulesets.md.

Ruleset What it enumerates Matched paper
PhaseOneRS Phase I: SO, UO, DH, HD, RD Dang et al., Metabolic Rainbow, JCIM 2020. DOI 10.1021/acs.jcim.9b00836
SO / UO / DH / HD / RD One Rainbow color each (see hex table in docs) Same Rainbow paper; Forest rule lists differ slightly for HD/RD/DH
QuinoneFormationRS (QF) Quinone, quinone-imine, and quinone-methide structures Hughes & Swamidass, Chem. Res. Toxicol. 2017. DOI 10.1021/acs.chemrestox.6b00385
Bioactivation (BA) Quinone, epoxidation, nitroaromatic reduction, thiophene S-oxidation Hughes et al., Chem. Res. Toxicol. 2021. DOI 10.1021/acs.chemrestox.0c00417
Full Complete Metabolic Forest generator (Phase I, conjugations, quinone, tautomerization) Hughes et al., Metabolic Forest, JCIM 2020. DOI 10.1021/acs.jcim.0c00360

Rainbow colorblind-safe hex (Wong / Okabe–Ito, closest to the paper figures): SO Stable Oxygenation red #D55E00, UO Unstable Oxygenation orange #E69F00, DH Dehydrogenation green #009E73, HD Hydrolysis blue #56B4E9, RD Reduction purple #CC79A7.

Related single-rule papers: epoxidation (10.1021/acscentsci.5b00131), N-dealkylation (10.1021/acs.chemrestox.7b00191), UGT glucuronidation (10.1093/bioinformatics/btw350), glutathione reactivity (10.1021/acs.chemrestox.5b00017).

Documentation

Import the package as xenosite.forest (Rust public stub). The RDKit reference engine is xenosite.forest.native; the frozen 0.6.x archive is xenosite.forest.legacy (see docs/forest/LEGACY.md). xenosite is a PEP 420 namespace, so other xenosite.* packages can be installed alongside this one.

Citation

Please cite Metabolic Forest if you use this package:

Hughes, T. B.; Dang, N. L.; Kumar, A.; Flynn, N. R.; Swamidass, S. J. Metabolic Forest: Predicting the Diverse Structures of Drug Metabolites. J. Chem. Inf. Model. 2020, 60 (10), 4702–4716. DOI: 10.1021/acs.jcim.0c00360

BibTeX (copy and paste):

@article{Hughes2020MetabolicForest,
  title = {Metabolic Forest: Predicting the Diverse Structures of Drug Metabolites},
  author = {Hughes, Tyler B. and Dang, Na Le and Kumar, Ayush and Flynn, Noah R. and Swamidass, S. Joshua},
  journal = {Journal of Chemical Information and Modeling},
  volume = {60},
  number = {10},
  pages = {4702--4716},
  year = {2020},
  doi = {10.1021/acs.jcim.0c00360},
  url = {https://doi.org/10.1021/acs.jcim.0c00360},
  publisher = {American Chemical Society}
}

A machine-readable citation is also in CITATION.cff.

Development

git clone https://github.com/swamidasslab/xenosite-forest.git
cd xenosite-forest
uv sync --extra network --group dev
uv run pytest -n auto
uv run pytest --cov=xenosite.forest

Versioning comes from git tags via hatch-vcs (setuptools-scm). Tag a release as vX.Y.Z (for example v0.1.0). On that commit the version is X.Y.Z. On later untagged commits it becomes the next patch with a dev suffix and short commit, for example 0.1.1.dev3+gabc1234. Read it at runtime as xenosite.forest.__version__. User-facing notes go in changelog.d/; the tag workflow compiles them into CHANGELOG.md. See docs/release.md.

Pushing a v* tag runs .github/workflows/release.yml: tests must pass and the resolved version must be a clean X.Y.Z before a GitHub Release and PyPI upload. A red tag workflow means do not treat that tag as released. To block creating tags unless checks pass, add a GitHub Ruleset on refs/tags/v* that requires the release / test status checks.

License

MIT. See LICENSE.

Metadata

Release files for xenosite-forest 0.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xenosite-forest 0.8.0
File Size Uploaded
xenosite_forest-0.8.0.tar.gz 483.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xenosite-forest 0.8.0
File Interpreter ABI Platform
xenosite_forest-0.8.0-py3-none-any.whl Python 3 none any Details

Total release size: 693.5 kB

Release files / xenosite_forest-0.8.0.tar.gz

Download URL xenosite_forest-0.8.0.tar.gz
Size 483.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f72639fcc3c717155200ddc73687b6172049f273fe38bfac7d92711f531a9c07
BLAKE2b-256 checksum
How to use checksums
f5bf28855bfbed35adf30109a0aa7d103ccfd1382c3a026a66522ddfb3ab2e71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 29, 2026.

Transparency log

Release files / xenosite_forest-0.8.0-py3-none-any.whl

Download URL xenosite_forest-0.8.0-py3-none-any.whl
Size 210.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b7b28025679aafe6da938de6fd019a5015a3480f422f08ab007fee55f5434f09
BLAKE2b-256 checksum
How to use checksums
ab1bf37061524fd32b5e060ce876a1444794014ba44f8ec38eea2e56c27824c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 29, 2026.

Transparency log

Release history Release notifications | RSS feed

0.9.0

36 release files

0.8.1

36 release files

This release

0.8.0 This release

2 release files

0.7.4

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page