ChemLogic
Chemlogic is a Neurosymbolic GNN framework designed for interpretable molecular property prediction. It integrates relational logic syntax with graph neural networks to encode functional groups and structural patterns as learnable rules.
Built on PyNeuraLogic.
Read the paper: TBD
Install
pip install ChemLogic
For experiment tracking with hyperparameter tuning (Optuna + MLflow):
pip install ChemLogic[experiments]
Dependencies
ChemLogic requires Python 3.11 and Java >=1.8. For visualization graphviz is required.
All dependencies are listed in pyproject.toml.
Usage
Usage examples can be found in notebooks and experiments folders.
from chemlogic.utils.Pipeline import Pipeline
# Built-in dataset
pipeline = Pipeline("mutagen", "gnn", param_size=4, layers=2)
train_loss, test_loss, auroc, _ = pipeline.train_test_cycle()
# Custom SMILES — task inferred from labels (floats → regression, {0,1} ints → classification)
pipeline = Pipeline(
"my_assay", "gnn", param_size=8, layers=2,
smiles_list=df["SMILES"],
labels=df["target"],
)
train_loss, test_loss, r2, _ = pipeline.train_test_cycle(epochs=200)
# Chemical knowledge base
pipeline = Pipeline(
"mutagen", "sgn", param_size=4, layers=2,
chem_rules=True, # hydroxyl, carbonyl, halogens, nitro, amines, ...
subgraphs=True, # cycles, paths, y-shapes, circular fingerprints, ...
)
# Atom, bond, and graph-level features
pipeline = Pipeline(
"my_assay", "gnn", param_size=8, layers=2,
smiles_list=df["SMILES"], labels=df["target"],
atom_features="all",
bond_features="all",
graph_features={"num_atoms": df["num_atoms"], "logP": df["logP"]},
)
# Multi-class — integers 0..N-1 are ambiguous, pass task= explicitly
pipeline = Pipeline(
"my_assay", "gnn", param_size=8, layers=2,
smiles_list=df["SMILES"], labels=df["activity_class"],
task="multi_class", num_outputs=3,
)
# Architecture modes
from chemlogic.utils.Pipeline import ArchitectureType
pipeline = Pipeline(
"mutagen", "rgcn", param_size=4, layers=2,
chem_rules=(False, True, False, False, False), # oxygen groups only
architecture=ArchitectureType.CCD,
)
pipeline.template.draw() # requires graphviz
# Checkpointing and inference
pipeline.save_checkpoint("checkpoints/run1")
pipeline = Pipeline.from_checkpoint("checkpoints/run1")
predictions = pipeline.inference(["CCO", "c1ccccc1", "CC(=O)O"])
How it works
A molecule is translated into logical atoms encoding atom and bond types. Background knowledge rules (functional groups, ring patterns, and substructures) are matched against these atoms to derive higher-level representations. The result is passed through message-passing GNN rules, all expressed in the same differentiable relational logic.
GNN message-passing is expressed directly as logic rules. Each node aggregates representations of connected nodes via variable substitutions over the graph.
The background knowledge can be integrated in three modes: BARE runs GNN and KB independently as a baseline; Chemical Concept Encoder (CCE) feeds KB-derived representations into the GNN input (enhances performance - something like featurization); Chemical Concept Decoder (CCD) passes GNN output through the KB (enhances explainability). After training in CCD mode, each functional group rule carries a scalar weight that directly quantifies its contribution to the prediction.
Models
| Key | Model | Paper |
|---|---|---|
gnn |
Standard GNN with edge features | Scarselli et al., 2009 |
rgcn |
Relational GCN (typed edges) | Schlichtkrull et al., 2017 |
kgnn / kgnn_local |
Higher-order GNN (k-GNN) | Morris et al., 2021 |
ego |
Ego-centric GNN | Sandfelder et al., 2021 |
sgn |
Subgraph Network | Xuan et al., 2021 |
diffusion |
Diffusion CNN | Atwood & Towsley, 2016 |
cw |
CW-Network | Bodnar et al., 2022 |
Datasets
| Name | Source | Size | Task |
|---|---|---|---|
mutagen |
TUD | 183 | Mutagenicity |
ptc / ptc_fr / ptc_mm / ptc_fm |
TUD | 336–351 | Toxicity |
dhfr |
TUD | 393 | DHFR inhibition |
er |
TUD | 446 | Estrogen receptor binding |
blood_brain_barrier |
TDC | 2030 | BBB penetration |
skin_reaction |
TDC | 404 | Skin sensitization |
oral_bioavailability |
TDC | 640 | Oral bioavailability |
carcinogenous |
TDC | 280 | Carcinogenicity |
pampa_permeability |
TDC | 2034 | Membrane permeability |
human_intestinal_absorption |
TDC | 578 | Intestinal absorption |
p_glycoprotein_inhibition |
TDC | 1218 | P-gp inhibition |
cyp2c9_substrate / cyp2d6_substrate / cyp3a4_substrate |
TDC | 667–670 | CYP substrates |
anti_sarscov2_activity |
TDC | 1484 | SARS-CoV-2 activity |
Any SMILES list or DataFrame works as a custom dataset.
Results
Performance across datasets and architecture modes (BARE / CCE / CCD):
Project structure
datasets— datasets encoded in relational format; includesTUDandTDCdatasets and a custom SMILES dataset convertermodels— GNN architecturesknowledge_base— functional groups and subgraph patterns
Documentation
- SPEC.md — API reference and configuration details
- DESIGN.md — architecture and design rationale
- REQUIREMENTS.md — functional and non-functional requirements
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines on how to get started.
License
This project is licensed under the MIT License.
Metadata
Release files for ChemLogic 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| chemlogic-0.1.3.tar.gz | 6.0 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| chemlogic-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.6 MB
Release files / chemlogic-0.1.3.tar.gz
| Download URL | chemlogic-0.1.3.tar.gz |
|---|---|
| Size | 6.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
33a9b0badfd4ae1d0cc2491d24e1f9d87765846eca35d22fe4af18e0535ca5ec
|
|
BLAKE2b-256 checksum How to use checksums |
cf4e29db8cc215202699e7f9384316454f70ec50af08c2088ac45576c57a3bf1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jul 9, 2026.
Transparency logRelease files / chemlogic-0.1.3-py3-none-any.whl
| Download URL | chemlogic-0.1.3-py3-none-any.whl |
|---|---|
| Size | 6.6 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a88bf2842f7aa6bb8d5db10f7c7e68058f326c6b36c22d46fbfde4557374c226
|
|
BLAKE2b-256 checksum How to use checksums |
7e0b892aaef1821c73a095cc562090a619c0d5f0bf26f6adb7371cced77d9ebb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jul 9, 2026.
Transparency log