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
Optional NetworkX helpers for building a metabolite graph:
uv add "xenosite-forest[network]"
Requires Python 3.10+ and RDKit.
Quick start
from rdkit import Chem
from xenosite.forest import bfs, rules, PhaseOneRS
# Pathway from ethanol to acetaldehyde
smiles, steps, mols = next(bfs(["CCO", "CC=O"], ruleset="PhaseOneRS"))
print(smiles)
print(steps)
# Enumerate hydroxylation products of propane
for site, products in rules.Hydroxylation().metabolites(Chem.MolFromSmiles("CCC")):
print(site, [Chem.MolToSmiles(p) for p in products])
# Named Phase I ruleset
print(sorted({rule.name for rule in PhaseOneRS}))
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
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
- Rulesets and papers — every built-in ruleset, Rainbow colors, and publication BibTeX
- Usage — public API and pathway search
- Tutorial notebook — interactive walkthrough
- xenosite.org — XenoSite models for sites of metabolism and reactivity
- Source repository — code, issues, and releases
Import the package as xenosite.forest. 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
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__.
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.
One-time PyPI Trusted Publishing setup
No API token is stored in the repo. CI authenticates with Trusted Publishing (OIDC).
-
Create the GitHub repo
swamidasslab/xenosite-forestand pushmain. -
GitHub → Settings → Environments → create an environment named exactly
pypi(optional: require reviewers before deploy). -
On PyPI: add a pending trusted publisher (project does not need to exist yet):
Field Value PyPI project name xenosite-forestOwner swamidasslabRepository name xenosite-forestWorkflow name release.ymlEnvironment name pypi -
Tag a release (
git tag -a v0.1.0 -m "0.1.0" && git push origin v0.1.0). Thepypi-publishjob uploads only after tests and build succeed.
For a dry run, register the same publisher on TestPyPI first and temporarily point the publish action at TestPyPI.
License
MIT. See LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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 xenosite_forest-0.1.0.tar.gz.
File metadata
- Download URL: xenosite_forest-0.1.0.tar.gz
- Upload date:
- Size: 52.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c097868d2b686dd767de85808035e0bc586243f3216f32e70bd044c110dc8cf9
|
|
| MD5 |
972b32071cf1ecaaef338338726f50ef
|
|
| BLAKE2b-256 |
3d850cd84af682102b34b30892ae08625a5b64a4d0b630c94a8829f4b5519dfa
|
Provenance
The following attestation bundles were made for xenosite_forest-0.1.0.tar.gz:
Publisher:
release.yml on swamidasslab/xenosite-forest
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xenosite_forest-0.1.0.tar.gz -
Subject digest:
c097868d2b686dd767de85808035e0bc586243f3216f32e70bd044c110dc8cf9 - Sigstore transparency entry: 2643575328
- Sigstore integration time:
-
Permalink:
swamidasslab/xenosite-forest@72a18e83dcd7d99afaa60283b8638bbc519f0078 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/swamidasslab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@72a18e83dcd7d99afaa60283b8638bbc519f0078 -
Trigger Event:
push
-
Statement type:
File details
Details for the file xenosite_forest-0.1.0-py3-none-any.whl.
File metadata
- Download URL: xenosite_forest-0.1.0-py3-none-any.whl
- Upload date:
- Size: 36.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a6ba211e6db53a303d04639ee5d1aef8b843843d3033bd0765a2acbadc7cb6d
|
|
| MD5 |
06520b920eb29ead38abc4ede47d8998
|
|
| BLAKE2b-256 |
8b06b1b4602ead2e70bf84c6cebb462f5dcafae85ba651e578c34afc88935dbc
|
Provenance
The following attestation bundles were made for xenosite_forest-0.1.0-py3-none-any.whl:
Publisher:
release.yml on swamidasslab/xenosite-forest
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xenosite_forest-0.1.0-py3-none-any.whl -
Subject digest:
8a6ba211e6db53a303d04639ee5d1aef8b843843d3033bd0765a2acbadc7cb6d - Sigstore transparency entry: 2643576218
- Sigstore integration time:
-
Permalink:
swamidasslab/xenosite-forest@72a18e83dcd7d99afaa60283b8638bbc519f0078 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/swamidasslab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@72a18e83dcd7d99afaa60283b8638bbc519f0078 -
Trigger Event:
push
-
Statement type: