pydompekeygen 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
@@ -0,0 +1,138 @@
1
+ # Pickles
2
+ *.pkl
3
+
4
+ # Byte-compiled / optimized / DLL files
5
+ __pycache__/
6
+ *.py[cod]
7
+ *$py.class
8
+
9
+ # C extensions
10
+ *.so
11
+
12
+ # Distribution / packaging
13
+ .Python
14
+ build/
15
+ develop-eggs/
16
+ dist/
17
+ downloads/
18
+ eggs/
19
+ .eggs/
20
+ lib/
21
+ lib64/
22
+ parts/
23
+ sdist/
24
+ var/
25
+ wheels/
26
+ pip-wheel-metadata/
27
+ share/python-wheels/
28
+ *.egg-info/
29
+ .installed.cfg
30
+ *.egg
31
+ MANIFEST
32
+
33
+ # PyInstaller
34
+ # Usually these files are written by a python script from a template
35
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
36
+ *.manifest
37
+ *.spec
38
+
39
+ # Installer logs
40
+ pip-log.txt
41
+ pip-delete-this-directory.txt
42
+
43
+ # Unit test / coverage reports
44
+ htmlcov/
45
+ .tox/
46
+ .nox/
47
+ .coverage
48
+ .coverage.*
49
+ .cache
50
+ nosetests.xml
51
+ coverage.xml
52
+ *.cover
53
+ *.py,cover
54
+ .hypothesis/
55
+ .pytest_cache/
56
+
57
+ # Translations
58
+ *.mo
59
+ *.pot
60
+
61
+ # Django stuff:
62
+ *.log
63
+ local_settings.py
64
+ db.sqlite3
65
+ db.sqlite3-journal
66
+
67
+ # Flask stuff:
68
+ instance/
69
+ .webassets-cache
70
+
71
+ # Scrapy stuff:
72
+ .scrapy
73
+
74
+ # Sphinx documentation
75
+ docs/_build/
76
+
77
+ # PyBuilder
78
+ target/
79
+
80
+ # Jupyter Notebook
81
+ .ipynb_checkpoints
82
+
83
+ # IPython
84
+ profile_default/
85
+ ipython_config.py
86
+
87
+ # PyCharm stuff:
88
+ .idea/
89
+
90
+ # VSCode stuff:
91
+ .vscode/
92
+
93
+ # pyenv
94
+ .python-version
95
+
96
+ # pipenv
97
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
98
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
99
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
100
+ # install all needed dependencies.
101
+ #Pipfile.lock
102
+
103
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
104
+ __pypackages__/
105
+
106
+ # Celery stuff
107
+ celerybeat-schedule
108
+ celerybeat.pid
109
+
110
+ # SageMath parsed files
111
+ *.sage.py
112
+
113
+ # Environments
114
+ .env
115
+ .venv
116
+ env/
117
+ venv/
118
+ ENV/
119
+ env.bak/
120
+ venv.bak/
121
+
122
+ # Spyder project settings
123
+ .spyderproject
124
+ .spyproject
125
+
126
+ # Rope project settings
127
+ .ropeproject
128
+
129
+ # mkdocs documentation
130
+ /site
131
+
132
+ # mypy
133
+ .mypy_cache/
134
+ .dmypy.json
135
+ dmypy.json
136
+
137
+ # Pyre type checker
138
+ .pyre/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 OlivierBeq
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,102 @@
1
+ Metadata-Version: 2.4
2
+ Name: pydompekeygen
3
+ Version: 1.0.0
4
+ Summary: A Python implementation of DompéKeys
5
+ Author-email: "Olivier J. M. Béquignon" <olivier.bequignon.maintainer@gmail.com>
6
+ Maintainer-email: "Olivier J. M. Béquignon" <olivier.bequignon.maintainer@gmail.com>
7
+ License-Expression: MIT
8
+ Project-URL: homepage, https://github.com/OlivierBeq/PyDompeKeyGen
9
+ Project-URL: repository, https://github.com/OlivierBeq/PyDompeKeyGen
10
+ Keywords: qsar,cheminformatics,fingerprint,dompé
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3 :: Only
19
+ Classifier: Topic :: Scientific/Engineering :: Chemistry
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: rdkit
24
+ Dynamic: license-file
25
+
26
+ # PyDompeKeyGen
27
+
28
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
29
+ [![Python](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue.svg)](pyproject.toml)
30
+ [![Status](https://img.shields.io/badge/status-beta-orange.svg)](pyproject.toml)
31
+ [![Paper](https://img.shields.io/badge/DOI-10.1186%2Fs13321--024--00813--4-blue.svg)](https://doi.org/10.1186/s13321-024-00813-4)
32
+
33
+ A lightweight Python / [RDKit](https://www.rdkit.org/) implementation of **DompéKeys** — a set of 1,064 SMARTS-based structural keys for mapping chemical space, built for use as an interpretable molecular fingerprint.
34
+
35
+ DompéKeys were originally developed by scientists at [Dompé farmaceutici](https://www.dompe.com/) as part of the [EXSCALATE](https://exscalate.eu/) drug-discovery platform and published in the *Journal of Cheminformatics* ([Manelfi, Tazzari, et al., 2024](https://doi.org/10.1186/s13321-024-00813-4)). This package provides a small, dependency-light way to generate the corresponding fingerprint for any RDKit molecule.
36
+
37
+ ## ✨ Features
38
+
39
+ - 🧬 **1,064 curated SMARTS keys** spanning amino acids, acids, metal binders, toxicophores, ring systems, and generic pharmacophoric features (H-bond donors/acceptors, etc.), organized across 5 complexity levels.
40
+ - 🎯 **Single-class API** — one object, one method, one RDKit `ExplicitBitVect` out.
41
+ - ⚡ **Fast startup** — the SMARTS catalog is compiled once and cached to disk (`smarts.pkl`), and automatically rebuilt if your installed RDKit version changes.
42
+ - 🔍 **Interpretable** — every set bit maps back to a named, human-readable substructure.
43
+
44
+ ## 📦 Installation
45
+
46
+ PyDompeKeyGen is not yet published to PyPI. Install it directly from GitHub:
47
+
48
+ ```bash
49
+ pip install git+https://github.com/OlivierBeq/PyDompeKeyGen.git
50
+ ```
51
+
52
+ Or clone and install locally for development:
53
+
54
+ ```bash
55
+ git clone https://github.com/OlivierBeq/PyDompeKeyGen.git
56
+ cd PyDompeKeyGen
57
+ pip install -e .
58
+ ```
59
+
60
+ Requires Python ≥ 3.10 and [RDKit](https://pypi.org/project/rdkit/) (installed automatically as a dependency).
61
+
62
+ ## 🚀 Quick start
63
+
64
+ ```python
65
+ from rdkit import Chem
66
+ from pydompekeygen import PyDompeKeys
67
+
68
+ # Load the DompéKeys catalog (built once, then cached on disk)
69
+ dompekeys = PyDompeKeys()
70
+
71
+ # Generate a fingerprint for a molecule
72
+ mol = Chem.MolFromSmiles("CC(=O)Oc1ccccc1C(=O)O") # aspirin
73
+ fingerprint = dompekeys.GetFingerprint(mol)
74
+
75
+ print(f"{fingerprint.GetNumOnBits()} / {dompekeys.num_bits} keys matched")
76
+ ```
77
+
78
+ See the [usage guide](docs/usage.md) for similarity calculations, converting fingerprints to NumPy arrays, batch processing, and inspecting which named keys matched.
79
+
80
+ ## 📚 Documentation
81
+
82
+ | Document | Description |
83
+ |---|---|
84
+ | [docs/usage.md](docs/usage.md) | Practical guide: similarity search, NumPy conversion, batch processing, introspecting matched keys |
85
+ | [docs/api.md](docs/api.md) | API reference for the `PyDompeKeys` class |
86
+ | [docs/background.md](docs/background.md) | What DompéKeys are, the 5 complexity levels, and how to cite the original paper |
87
+
88
+ ## 📖 Citation
89
+
90
+ If you use PyDompeKeyGen in published work, please cite the original DompéKeys paper:
91
+
92
+ > Manelfi, C., Tazzari, V., Lunghini, F. *et al.* "DompeKeys": a set of novel substructure-based descriptors for efficient chemical space mapping, development and structural interpretation of machine learning models, and indexing of large databases. *J Cheminform* **16**, 21 (2024). https://doi.org/10.1186/s13321-024-00813-4
93
+
94
+ See [docs/background.md](docs/background.md) for a BibTeX entry.
95
+
96
+ ## 🤝 Contributing
97
+
98
+ Issues and pull requests are welcome at [github.com/OlivierBeq/PyDompeKeyGen](https://github.com/OlivierBeq/PyDompeKeyGen).
99
+
100
+ ## ⚖️ License
101
+
102
+ Released under the [MIT License](LICENSE).
@@ -0,0 +1,77 @@
1
+ # PyDompeKeyGen
2
+
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
4
+ [![Python](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue.svg)](pyproject.toml)
5
+ [![Status](https://img.shields.io/badge/status-beta-orange.svg)](pyproject.toml)
6
+ [![Paper](https://img.shields.io/badge/DOI-10.1186%2Fs13321--024--00813--4-blue.svg)](https://doi.org/10.1186/s13321-024-00813-4)
7
+
8
+ A lightweight Python / [RDKit](https://www.rdkit.org/) implementation of **DompéKeys** — a set of 1,064 SMARTS-based structural keys for mapping chemical space, built for use as an interpretable molecular fingerprint.
9
+
10
+ DompéKeys were originally developed by scientists at [Dompé farmaceutici](https://www.dompe.com/) as part of the [EXSCALATE](https://exscalate.eu/) drug-discovery platform and published in the *Journal of Cheminformatics* ([Manelfi, Tazzari, et al., 2024](https://doi.org/10.1186/s13321-024-00813-4)). This package provides a small, dependency-light way to generate the corresponding fingerprint for any RDKit molecule.
11
+
12
+ ## ✨ Features
13
+
14
+ - 🧬 **1,064 curated SMARTS keys** spanning amino acids, acids, metal binders, toxicophores, ring systems, and generic pharmacophoric features (H-bond donors/acceptors, etc.), organized across 5 complexity levels.
15
+ - 🎯 **Single-class API** — one object, one method, one RDKit `ExplicitBitVect` out.
16
+ - ⚡ **Fast startup** — the SMARTS catalog is compiled once and cached to disk (`smarts.pkl`), and automatically rebuilt if your installed RDKit version changes.
17
+ - 🔍 **Interpretable** — every set bit maps back to a named, human-readable substructure.
18
+
19
+ ## 📦 Installation
20
+
21
+ PyDompeKeyGen is not yet published to PyPI. Install it directly from GitHub:
22
+
23
+ ```bash
24
+ pip install git+https://github.com/OlivierBeq/PyDompeKeyGen.git
25
+ ```
26
+
27
+ Or clone and install locally for development:
28
+
29
+ ```bash
30
+ git clone https://github.com/OlivierBeq/PyDompeKeyGen.git
31
+ cd PyDompeKeyGen
32
+ pip install -e .
33
+ ```
34
+
35
+ Requires Python ≥ 3.10 and [RDKit](https://pypi.org/project/rdkit/) (installed automatically as a dependency).
36
+
37
+ ## 🚀 Quick start
38
+
39
+ ```python
40
+ from rdkit import Chem
41
+ from pydompekeygen import PyDompeKeys
42
+
43
+ # Load the DompéKeys catalog (built once, then cached on disk)
44
+ dompekeys = PyDompeKeys()
45
+
46
+ # Generate a fingerprint for a molecule
47
+ mol = Chem.MolFromSmiles("CC(=O)Oc1ccccc1C(=O)O") # aspirin
48
+ fingerprint = dompekeys.GetFingerprint(mol)
49
+
50
+ print(f"{fingerprint.GetNumOnBits()} / {dompekeys.num_bits} keys matched")
51
+ ```
52
+
53
+ See the [usage guide](docs/usage.md) for similarity calculations, converting fingerprints to NumPy arrays, batch processing, and inspecting which named keys matched.
54
+
55
+ ## 📚 Documentation
56
+
57
+ | Document | Description |
58
+ |---|---|
59
+ | [docs/usage.md](docs/usage.md) | Practical guide: similarity search, NumPy conversion, batch processing, introspecting matched keys |
60
+ | [docs/api.md](docs/api.md) | API reference for the `PyDompeKeys` class |
61
+ | [docs/background.md](docs/background.md) | What DompéKeys are, the 5 complexity levels, and how to cite the original paper |
62
+
63
+ ## 📖 Citation
64
+
65
+ If you use PyDompeKeyGen in published work, please cite the original DompéKeys paper:
66
+
67
+ > Manelfi, C., Tazzari, V., Lunghini, F. *et al.* "DompeKeys": a set of novel substructure-based descriptors for efficient chemical space mapping, development and structural interpretation of machine learning models, and indexing of large databases. *J Cheminform* **16**, 21 (2024). https://doi.org/10.1186/s13321-024-00813-4
68
+
69
+ See [docs/background.md](docs/background.md) for a BibTeX entry.
70
+
71
+ ## 🤝 Contributing
72
+
73
+ Issues and pull requests are welcome at [github.com/OlivierBeq/PyDompeKeyGen](https://github.com/OlivierBeq/PyDompeKeyGen).
74
+
75
+ ## ⚖️ License
76
+
77
+ Released under the [MIT License](LICENSE).
@@ -0,0 +1,67 @@
1
+ # API reference
2
+
3
+ ## `pydompekeygen.PyDompeKeys`
4
+
5
+ ```python
6
+ class PyDompeKeys:
7
+ def __init__(self): ...
8
+ def GetFingerprint(self, mol: rdkit.Chem.Mol) -> rdkit.DataStructs.ExplicitBitVect: ...
9
+ ```
10
+
11
+ The single entry point of the package. Instantiate once and reuse across molecules.
12
+
13
+ ### `PyDompeKeys()`
14
+
15
+ Loads the DompéKeys SMARTS catalog into an [`rdkit.Chem.rdfiltercatalog.FilterCatalog`](https://www.rdkit.org/docs/source/rdkit.Chem.rdfiltercatalog.html).
16
+
17
+ - On first run (or if no cache exists), the catalog is compiled from the bundled `smarts.txt` and pickled to `smarts.pkl` next to the installed package, together with the RDKit version used to build it.
18
+ - On subsequent runs, the cache is loaded directly. If the installed RDKit version differs from the one recorded in the cache, the catalog is silently recompiled and re-cached — this keeps SMARTS matching behavior consistent with the RDKit version actually in use.
19
+
20
+ Takes no arguments.
21
+
22
+ #### Attributes
23
+
24
+ | Attribute | Type | Description |
25
+ |---|---|---|
26
+ | `library` | `rdkit.Chem.rdfiltercatalog.FilterCatalog` | The compiled catalog of DompéKey SMARTS filters. Each entry's description is a `"{index}\|{key_id}\|{name}\|{smarts}\|level{level}"` string, where `index` is the fingerprint bit position and `key_id` is the `DK#` identifier from `smarts.txt`. Query it directly (e.g. via `.GetMatches(mol)`) to introspect which named keys matched — see [docs/usage.md](usage.md#inspecting-which-keys-matched). |
27
+ | `num_bits` | `int` | Total number of DompéKeys / fingerprint length (1,064 with the bundled `smarts.txt`). |
28
+
29
+ ### `GetFingerprint(mol)`
30
+
31
+ ```python
32
+ GetFingerprint(mol: rdkit.Chem.Mol) -> rdkit.DataStructs.ExplicitBitVect
33
+ ```
34
+
35
+ Generates the DompéKey fingerprint for a molecule.
36
+
37
+ **Parameters**
38
+
39
+ - `mol` — an `rdkit.Chem.Mol` instance (e.g. from `Chem.MolFromSmiles`, `Chem.MolFromMolFile`, etc.). Must not be `None`.
40
+
41
+ **Returns**
42
+
43
+ An `rdkit.DataStructs.ExplicitBitVect` of length `num_bits`. Bit `i` is set if the molecule matches the SMARTS pattern of the DompéKey at index `i` in `library`. Compatible with all RDKit similarity metrics (`DataStructs.TanimotoSimilarity`, `DataStructs.BulkTanimotoSimilarity`, etc.) and `DataStructs.ConvertToNumpyArray`.
44
+
45
+ **Example**
46
+
47
+ ```python
48
+ from rdkit import Chem
49
+ from pydompekeygen import PyDompeKeys
50
+
51
+ dompekeys = PyDompeKeys()
52
+ mol = Chem.MolFromSmiles("c1ccccc1O") # phenol
53
+ fp = dompekeys.GetFingerprint(mol)
54
+ ```
55
+
56
+ ## Module data
57
+
58
+ The `smarts.txt` file bundled with the package is a tab-separated table with one DompéKey per row:
59
+
60
+ | Column | Description |
61
+ |---|---|
62
+ | `Index` | Human-readable key identifier (e.g. `DK1`) |
63
+ | `Chemical_Name` | Descriptive name of the substructure |
64
+ | `DompeKeys` | The SMARTS pattern |
65
+ | `Level` | Complexity level, `0`–`4` (see [docs/background.md](background.md)) |
66
+
67
+ This file is the single source of truth for the fingerprint definition — regenerating `smarts.pkl` (by deleting it, or on an RDKit version bump) always reflects the current contents of `smarts.txt`.
@@ -0,0 +1,57 @@
1
+ # Background
2
+
3
+ ## What are DompéKeys?
4
+
5
+ **DompéKeys** are a set of substructure-based descriptors developed by researchers at [Dompé farmaceutici](https://www.dompe.com/) as part of their [EXSCALATE](https://exscalate.eu/) drug-discovery platform, and published in the *Journal of Cheminformatics*:
6
+
7
+ > Manelfi, C., Tazzari, V., Lunghini, F., Cerchia, C., Fava, A., Pedretti, A., Stouten, P. F. W., Vistoli, G., & Beccari, A. R. (2024). "DompeKeys": a set of novel substructure-based descriptors for efficient chemical space mapping, development and structural interpretation of machine learning models, and indexing of large databases. *Journal of Cheminformatics*, 16, 21. https://doi.org/10.1186/s13321-024-00813-4
8
+
9
+ The original protocol and reference implementation are also available at [dompekeys.exscalate.eu](https://dompekeys.exscalate.eu).
10
+
11
+ DompéKeys encode 1,064 curated SMARTS patterns covering chemical features relevant to pharmaceutical compounds — from precisely defined structural moieties (natural amino acids, metal-chelating groups, known toxicophores/structural alerts) to more generic pharmacophoric features (hydrogen-bond donors/acceptors, ring systems, charged groups). Unlike fingerprints generated by exhaustive substructure enumeration (e.g. Morgan/ECFP), every bit in a DompéKeys fingerprint corresponds to a *named, medicinal-chemistry-relevant* fragment, which makes the fingerprint directly interpretable: a set bit can be read and explained by a chemist, not just used as an opaque ML feature.
12
+
13
+ This makes DompéKeys well suited to:
14
+
15
+ - **Chemical space mapping** and diversity analysis of large compound collections
16
+ - **Interpretable machine learning** — explaining *why* a model made a prediction in terms of concrete substructures
17
+ - **Indexing very large databases** for fast substructure-aware similarity search
18
+
19
+ ## The five complexity levels
20
+
21
+ Each DompéKey is tagged with a `Level` from 0 to 4, reflecting how specific vs. generic the encoded pattern is — from well-defined structural moieties toward broad pharmacophoric features. The bundled catalog (`smarts.txt`) breaks down as follows:
22
+
23
+ | Level | # Keys |
24
+ |---|---|
25
+ | 0 | 265 |
26
+ | 1 | 66 |
27
+ | 2 | 617 |
28
+ | 3 | 72 |
29
+ | 4 | 44 |
30
+ | **Total** | **1,064** |
31
+
32
+ The level for each key is included in its `FilterCatalogEntry` description (see [docs/api.md](api.md)), so fingerprints can be filtered or interpreted level-by-level if your application needs it.
33
+
34
+ ## PyDompeKeyGen vs. the original protocol
35
+
36
+ PyDompeKeyGen is an independent, minimal Python/RDKit implementation that reproduces the DompéKeys fingerprint from the published SMARTS definitions. It does not implement the full EXSCALATE pipeline (e.g. Molecular Anatomy integration) — only fingerprint generation via `PyDompeKeys.GetFingerprint`. For the canonical reference implementation and any downstream tooling built around DompéKeys, see [dompekeys.exscalate.eu](https://dompekeys.exscalate.eu).
37
+
38
+ ## Citing this work
39
+
40
+ If PyDompeKeyGen is useful in your research, please cite the original DompéKeys paper (not this package):
41
+
42
+ ```bibtex
43
+ @article{Manelfi2024DompeKeys,
44
+ author = {Manelfi, Candida and Tazzari, Valerio and Lunghini, Filippo and Cerchia, Carmen
45
+ and Fava, Anna and Pedretti, Alessandro and Stouten, Pieter F. W.
46
+ and Vistoli, Giulio and Beccari, Andrea Rosario},
47
+ title = {"{DompeKeys}": a set of novel substructure-based descriptors for efficient
48
+ chemical space mapping, development and structural interpretation of machine
49
+ learning models, and indexing of large databases},
50
+ journal = {Journal of Cheminformatics},
51
+ year = {2024},
52
+ volume = {16},
53
+ number = {1},
54
+ pages = {21},
55
+ doi = {10.1186/s13321-024-00813-4}
56
+ }
57
+ ```
@@ -0,0 +1,93 @@
1
+ # Usage guide
2
+
3
+ This guide covers the practical patterns you'll need day to day: generating fingerprints, comparing molecules, converting to NumPy, batch processing, and inspecting *which* keys matched.
4
+
5
+ ## Generating a fingerprint
6
+
7
+ ```python
8
+ from rdkit import Chem
9
+ from pydompekeygen import PyDompeKeys
10
+
11
+ dompekeys = PyDompeKeys()
12
+
13
+ mol = Chem.MolFromSmiles("CC(=O)Oc1ccccc1C(=O)O") # aspirin
14
+ fp = dompekeys.GetFingerprint(mol)
15
+ ```
16
+
17
+ `GetFingerprint` returns an RDKit [`ExplicitBitVect`](https://www.rdkit.org/docs/source/rdkit.DataStructs.cDataStructs.html) of length `dompekeys.num_bits` (1,064 by default), with one bit per DompéKey. This is the same object type returned by RDKit's own fingerprinting functions, so it works with every RDKit similarity metric and bit-vector utility out of the box.
18
+
19
+ Only create the `PyDompeKeys()` instance once and reuse it — building/loading the SMARTS catalog has a fixed one-time cost, but `GetFingerprint` itself is cheap per molecule.
20
+
21
+ ## Comparing molecules
22
+
23
+ ```python
24
+ from rdkit import DataStructs
25
+
26
+ mol_a = Chem.MolFromSmiles("CC(=O)Oc1ccccc1C(=O)O") # aspirin
27
+ mol_b = Chem.MolFromSmiles("CC(=O)Nc1ccc(O)cc1") # paracetamol
28
+
29
+ fp_a = dompekeys.GetFingerprint(mol_a)
30
+ fp_b = dompekeys.GetFingerprint(mol_b)
31
+
32
+ similarity = DataStructs.TanimotoSimilarity(fp_a, fp_b)
33
+ print(f"Tanimoto similarity: {similarity:.3f}")
34
+ ```
35
+
36
+ Any RDKit bit-vector metric works the same way, e.g. `DataStructs.DiceSimilarity`, `DataStructs.CosineSimilarity`, or bulk variants like `DataStructs.BulkTanimotoSimilarity` for comparing one fingerprint against many.
37
+
38
+ ## Converting to NumPy
39
+
40
+ ```python
41
+ import numpy as np
42
+ from rdkit import DataStructs
43
+
44
+ arr = np.zeros((dompekeys.num_bits,), dtype=int)
45
+ DataStructs.ConvertToNumpyArray(fp, arr)
46
+ ```
47
+
48
+ `arr` is now a plain 0/1 NumPy vector, ready to feed into scikit-learn, PyTorch, or any other ML stack.
49
+
50
+ ## Batch processing
51
+
52
+ ```python
53
+ import pandas as pd
54
+ from rdkit import Chem
55
+ from pydompekeygen import PyDompeKeys
56
+
57
+ dompekeys = PyDompeKeys()
58
+
59
+ df = pd.DataFrame({"smiles": ["CCO", "c1ccccc1", "CC(=O)Oc1ccccc1C(=O)O"]})
60
+ df["mol"] = df["smiles"].apply(Chem.MolFromSmiles)
61
+ df["fingerprint"] = df["mol"].apply(dompekeys.GetFingerprint)
62
+ ```
63
+
64
+ For large datasets, drop unparsable SMILES (`Chem.MolFromSmiles` returns `None` on failure) before calling `GetFingerprint`, since it expects a valid `rdkit.Chem.Mol`.
65
+
66
+ ## Inspecting which keys matched
67
+
68
+ Each bit corresponds to a named substructure. To see which DompéKeys fired for a given molecule (instead of just the bit vector), query the underlying RDKit `FilterCatalog` directly:
69
+
70
+ ```python
71
+ matches = dompekeys.library.GetMatches(mol)
72
+
73
+ for entry in matches:
74
+ index, key_id, name, smarts, level = entry.GetDescription().split("|")
75
+ print(f"[bit {index}, {level}] {key_id} — {name}")
76
+ ```
77
+
78
+ Example output for aspirin:
79
+
80
+ ```
81
+ [bit 410, level2] DK415 — carboxylic acids (aromatic)
82
+ [bit 429, level2] DK443 — esters (aliphatic) / (aromatic)
83
+ [bit 958, level3] DK978 — carboxylic acids derivatives
84
+ [bit 1061, level4] DK1081 — donor atoms for H-bonds (N and O)
85
+ [bit 1062, level4] DK1082 — acceptor atoms for H-bonds (N,O,F)
86
+ ...
87
+ ```
88
+
89
+ This is useful for explaining a model's prediction, debugging why two molecules are (dis)similar, or filtering the fingerprint down to a subset of complexity levels — see [docs/background.md](background.md) for what each level means.
90
+
91
+ ## Rebuilding the SMARTS catalog
92
+
93
+ On first use, PyDompeKeyGen compiles `smarts.txt` into an RDKit `FilterCatalog` and caches it alongside the installed RDKit version in `smarts.pkl`. On every subsequent import it loads straight from that cache — unless your installed RDKit version has changed since the cache was built, in which case it transparently rebuilds it. You never need to manage this yourself.
@@ -0,0 +1,44 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77.0.0", "setuptools_scm[toml]>=7.1"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "pydompekeygen"
7
+ dynamic = ["version"]
8
+ description = "A Python implementation of DompéKeys"
9
+ readme = { file = "README.md", content-type = "text/markdown" }
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ keywords = ["qsar", "cheminformatics", "fingerprint", "dompé"]
14
+ authors = [{ name = "Olivier J. M. Béquignon", email = "olivier.bequignon.maintainer@gmail.com" }]
15
+ maintainers = [{ name = "Olivier J. M. Béquignon", email = "olivier.bequignon.maintainer@gmail.com" }]
16
+ classifiers = [
17
+ "Development Status :: 5 - Production/Stable",
18
+ "Operating System :: OS Independent",
19
+ "Programming Language :: Python",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Programming Language :: Python :: 3.13",
24
+ "Programming Language :: Python :: 3 :: Only",
25
+ "Topic :: Scientific/Engineering :: Chemistry",
26
+ ]
27
+
28
+ dependencies = [
29
+ "rdkit",
30
+ ]
31
+
32
+ [tool.setuptools.packages.find]
33
+ where = ["src"]
34
+
35
+ [tool.setuptools.dynamic]
36
+ version = {attr = "pydompekeygen.__version__"}
37
+
38
+ [project.urls]
39
+ homepage = "https://github.com/OlivierBeq/PyDompeKeyGen"
40
+ repository = "https://github.com/OlivierBeq/PyDompeKeyGen"
41
+
42
+ [tool.setuptools]
43
+ include-package-data = true
44
+ package-dir = { "" = "src" }
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,6 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+
4
+ from .core import PyDompeKeys
5
+
6
+ __version__ = "1.0.0"