Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ jobs:
uses: ./.github/actions/setup-uv-env
with:
python-version: ${{ matrix.python-version }}
install-args: "--extra rna --extra report --extra tabpfn --extra tabicl --extra clustering --group test_duration"
install-args: >-
--extra rna --extra report --extra tabpfn --extra tabicl
--extra node --extra clustering --group test_duration

- name: Cache HuggingFace and Torch models 🗂️
uses: actions/cache@v4
Expand Down Expand Up @@ -116,7 +118,9 @@ jobs:
uses: ./.github/actions/setup-uv-env
with:
python-version: ${{ env.PYTHON_VERSION }}
install-args: "--extra rna --extra report --extra tabpfn --extra tabicl --extra clustering --group test_duration"
install-args: >-
--extra rna --extra report --extra tabpfn --extra tabicl
--extra node --extra clustering --group test_duration

- name: Cache HuggingFace and Torch models 🗂️
uses: actions/cache@v4
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "7ab185ba",
"metadata": {},
"source": [
"# CheMeleon GNN Fingerprints\n",
"\n",
"This notebook demonstrates how to generate CheMeleon molecular embeddings from SMILES using Mother."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "2457164a",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"from rdkit import Chem\n",
"\n",
"from mother.feature_generation.fp_gnn_gen import CheMeleonFingerprintFactory"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "17278c7c",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Embedding matrix shape: (3, 2048)\n",
"Dtype: float32\n",
"First row (first 8 values): [0. 0. 0. 0. 0. 0. 0. 0.]\n"
]
}
],
"source": [
"smiles = [\"CCO\", \"c1ccccc1\", \"CC(=O)O\"]\n",
"mols = [Chem.MolFromSmiles(s) for s in smiles]\n",
"mols_array = np.array(mols, dtype=object)\n",
"\n",
"checkpoint_path = \"path/to/chemeleon/checkpoint.pt\" # Replace with your local chemprop checkpoint path.\n",
"factory = CheMeleonFingerprintFactory(\n",
" output_dim=2048,\n",
" batch_size=128,\n",
" checkpoint_path=checkpoint_path,\n",
" device=\"cpu\",\n",
")\n",
"transformer = factory.get_fingerprint_generator()\n",
"embeddings = transformer.fit_transform(mols_array)\n",
"\n",
"print(\"Embedding matrix shape:\", embeddings.shape)\n",
"print(\"Dtype:\", embeddings.dtype)\n",
"print(\"First row (first 8 values):\", np.round(embeddings[0][:8], 4))"
]
},
{
"cell_type": "markdown",
"id": "20d687a9",
"metadata": {},
"source": [
"## Notes\n",
"\n",
"- Install dependencies before using CheMeleon embeddings (e.g. `pip install 'mother-ml[chemprop]'` or `pip install chemprop`).\n",
"- If `checkpoint_path=None`, the transformer calls `get_default_chemeleon_checkpoint()` which auto-downloads `chemeleon_mp.pt` from Zenodo on first use and caches it in `~/.cache/mother/`.\n",
"- Input to the transformer should be RDKit molecule objects, matching other fingerprint generators.\n",
"- Invalid molecules are returned as rows with `NaN` values.\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "mother-ml (3.13.14)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.14"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading
Loading