shepherd-score 0.1.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.
Files changed (75) hide show
  1. shepherd_score-0.1.0/.gitattributes +2 -0
  2. shepherd_score-0.1.0/.gitignore +169 -0
  3. shepherd_score-0.1.0/LICENSE +21 -0
  4. shepherd_score-0.1.0/PKG-INFO +336 -0
  5. shepherd_score-0.1.0/README.md +294 -0
  6. shepherd_score-0.1.0/environment.yml +19 -0
  7. shepherd_score-0.1.0/examples/01_profiles.ipynb +383 -0
  8. shepherd_score-0.1.0/examples/02_scoring.ipynb +479 -0
  9. shepherd_score-0.1.0/examples/03_evaluation.ipynb +1087 -0
  10. shepherd_score-0.1.0/logo.svg +1 -0
  11. shepherd_score-0.1.0/pyproject.toml +101 -0
  12. shepherd_score-0.1.0/scripts/README.md +5 -0
  13. shepherd_score-0.1.0/scripts/conditional_evaluation.py +314 -0
  14. shepherd_score-0.1.0/scripts/conditional_evaluation.sh +13 -0
  15. shepherd_score-0.1.0/scripts/consistency_benchmark.py +271 -0
  16. shepherd_score-0.1.0/scripts/consistency_benchmark.sh +21 -0
  17. shepherd_score-0.1.0/scripts/consistency_evaluation.py +192 -0
  18. shepherd_score-0.1.0/scripts/consistency_evaluation.sh +12 -0
  19. shepherd_score-0.1.0/scripts/docking_evaluation.py +115 -0
  20. shepherd_score-0.1.0/scripts/docking_evaluation.sh +11 -0
  21. shepherd_score-0.1.0/scripts/docking_screen.py +54 -0
  22. shepherd_score-0.1.0/scripts/docking_screen.sh +12 -0
  23. shepherd_score-0.1.0/setup.cfg +4 -0
  24. shepherd_score-0.1.0/setup.py +25 -0
  25. shepherd_score-0.1.0/shepherd_score/__init__.py +8 -0
  26. shepherd_score-0.1.0/shepherd_score/alignment.py +1089 -0
  27. shepherd_score-0.1.0/shepherd_score/alignment_jax.py +1013 -0
  28. shepherd_score-0.1.0/shepherd_score/alignment_utils/__init__.py +0 -0
  29. shepherd_score-0.1.0/shepherd_score/alignment_utils/pca.py +227 -0
  30. shepherd_score-0.1.0/shepherd_score/alignment_utils/pca_jax.py +174 -0
  31. shepherd_score-0.1.0/shepherd_score/alignment_utils/pca_np.py +162 -0
  32. shepherd_score-0.1.0/shepherd_score/alignment_utils/se3.py +216 -0
  33. shepherd_score-0.1.0/shepherd_score/alignment_utils/se3_jax.py +104 -0
  34. shepherd_score-0.1.0/shepherd_score/alignment_utils/se3_np.py +156 -0
  35. shepherd_score-0.1.0/shepherd_score/conformer_generation.py +693 -0
  36. shepherd_score-0.1.0/shepherd_score/container.py +1121 -0
  37. shepherd_score-0.1.0/shepherd_score/evaluations/__init__.py +0 -0
  38. shepherd_score-0.1.0/shepherd_score/evaluations/docking.py +540 -0
  39. shepherd_score-0.1.0/shepherd_score/evaluations/evaluate.py +1758 -0
  40. shepherd_score-0.1.0/shepherd_score/evaluations/pdbs/1iep.pdbqt +2703 -0
  41. shepherd_score-0.1.0/shepherd_score/evaluations/pdbs/3eml.pdbqt +4306 -0
  42. shepherd_score-0.1.0/shepherd_score/evaluations/pdbs/3ny8.pdbqt +4300 -0
  43. shepherd_score-0.1.0/shepherd_score/evaluations/pdbs/4rlu.pdbqt +2770 -0
  44. shepherd_score-0.1.0/shepherd_score/evaluations/pdbs/4unn.pdbqt +1666 -0
  45. shepherd_score-0.1.0/shepherd_score/evaluations/pdbs/5mo4.pdbqt +4126 -0
  46. shepherd_score-0.1.0/shepherd_score/evaluations/pdbs/7l11.pdbqt +2890 -0
  47. shepherd_score-0.1.0/shepherd_score/evaluations/pdbs/README.md +6 -0
  48. shepherd_score-0.1.0/shepherd_score/evaluations/utils/__init__.py +0 -0
  49. shepherd_score-0.1.0/shepherd_score/evaluations/utils/convert_data.py +231 -0
  50. shepherd_score-0.1.0/shepherd_score/evaluations/utils/interactions.py +236 -0
  51. shepherd_score-0.1.0/shepherd_score/extract_profiles.py +35 -0
  52. shepherd_score-0.1.0/shepherd_score/generate_point_cloud.py +693 -0
  53. shepherd_score-0.1.0/shepherd_score/objective.py +675 -0
  54. shepherd_score-0.1.0/shepherd_score/pharm_utils/__init__.py +0 -0
  55. shepherd_score-0.1.0/shepherd_score/pharm_utils/pharmacophore.py +586 -0
  56. shepherd_score-0.1.0/shepherd_score/pharm_utils/pharmvec.py +841 -0
  57. shepherd_score-0.1.0/shepherd_score/pharm_utils/smarts_features.fdef +247 -0
  58. shepherd_score-0.1.0/shepherd_score/score/__init__.py +0 -0
  59. shepherd_score-0.1.0/shepherd_score/score/constants.py +33 -0
  60. shepherd_score-0.1.0/shepherd_score/score/electrostatic_scoring.py +290 -0
  61. shepherd_score-0.1.0/shepherd_score/score/electrostatic_scoring_jax.py +234 -0
  62. shepherd_score-0.1.0/shepherd_score/score/electrostatic_scoring_np.py +233 -0
  63. shepherd_score-0.1.0/shepherd_score/score/gaussian_overlap.py +417 -0
  64. shepherd_score-0.1.0/shepherd_score/score/gaussian_overlap_jax.py +119 -0
  65. shepherd_score-0.1.0/shepherd_score/score/gaussian_overlap_np.py +68 -0
  66. shepherd_score-0.1.0/shepherd_score/score/pharmacophore_scoring.py +737 -0
  67. shepherd_score-0.1.0/shepherd_score/score/pharmacophore_scoring_np.py +480 -0
  68. shepherd_score-0.1.0/shepherd_score/visualize.py +203 -0
  69. shepherd_score-0.1.0/shepherd_score.egg-info/PKG-INFO +336 -0
  70. shepherd_score-0.1.0/shepherd_score.egg-info/SOURCES.txt +73 -0
  71. shepherd_score-0.1.0/shepherd_score.egg-info/dependency_links.txt +1 -0
  72. shepherd_score-0.1.0/shepherd_score.egg-info/requires.txt +12 -0
  73. shepherd_score-0.1.0/shepherd_score.egg-info/top_level.txt +1 -0
  74. shepherd_score-0.1.0/tests/__init__.py +0 -0
  75. shepherd_score-0.1.0/tests/test_alignment.py +114 -0
@@ -0,0 +1,2 @@
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
@@ -0,0 +1,169 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ .DS_Store
7
+
8
+ # C extensions
9
+ *.so
10
+
11
+ # Distribution / packaging
12
+ .Python
13
+ build/
14
+ develop-eggs/
15
+ dist/
16
+ downloads/
17
+ eggs/
18
+ .eggs/
19
+ lib/
20
+ lib64/
21
+ parts/
22
+ sdist/
23
+ var/
24
+ wheels/
25
+ share/python-wheels/
26
+ *.egg-info/
27
+ .installed.cfg
28
+ *.egg
29
+ MANIFEST
30
+
31
+ # PyPI authentication and config files
32
+ .pypirc
33
+ *.pypirc
34
+ .twinerc
35
+
36
+ # PyInstaller
37
+ # Usually these files are written by a python script from a template
38
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
39
+ *.manifest
40
+ *.spec
41
+
42
+ # Installer logs
43
+ pip-log.txt
44
+ pip-delete-this-directory.txt
45
+
46
+ # Unit test / coverage reports
47
+ htmlcov/
48
+ .tox/
49
+ .nox/
50
+ .coverage
51
+ .coverage.*
52
+ .cache
53
+ nosetests.xml
54
+ coverage.xml
55
+ *.cover
56
+ *.py,cover
57
+ .hypothesis/
58
+ .pytest_cache/
59
+ cover/
60
+
61
+ # Translations
62
+ *.mo
63
+ *.pot
64
+
65
+ # Django stuff:
66
+ *.log
67
+ local_settings.py
68
+ db.sqlite3
69
+ db.sqlite3-journal
70
+
71
+ # Flask stuff:
72
+ instance/
73
+ .webassets-cache
74
+
75
+ # Scrapy stuff:
76
+ .scrapy
77
+
78
+ # Sphinx documentation
79
+ docs/_build/
80
+
81
+ # PyBuilder
82
+ .pybuilder/
83
+ target/
84
+
85
+ # Jupyter Notebook
86
+ .ipynb_checkpoints
87
+
88
+ # IPython
89
+ profile_default/
90
+ ipython_config.py
91
+
92
+ # pyenv
93
+ # For a library or package, you might want to ignore these files since the code is
94
+ # intended to run in multiple environments; otherwise, check them in:
95
+ # .python-version
96
+
97
+ # pipenv
98
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
99
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
100
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
101
+ # install all needed dependencies.
102
+ #Pipfile.lock
103
+
104
+ # poetry
105
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
106
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
107
+ # commonly ignored for libraries.
108
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
109
+ #poetry.lock
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ #pdm.lock
114
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
115
+ # in version control.
116
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
117
+ .pdm.toml
118
+ .pdm-python
119
+ .pdm-build/
120
+
121
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
122
+ __pypackages__/
123
+
124
+ # Celery stuff
125
+ celerybeat-schedule
126
+ celerybeat.pid
127
+
128
+ # SageMath parsed files
129
+ *.sage.py
130
+
131
+ # Environments
132
+ .env
133
+ .venv
134
+ env/
135
+ venv/
136
+ ENV/
137
+ env.bak/
138
+ venv.bak/
139
+
140
+ # Spyder project settings
141
+ .spyderproject
142
+ .spyproject
143
+
144
+ # Rope project settings
145
+ .ropeproject
146
+
147
+ # mkdocs documentation
148
+ /site
149
+
150
+ # mypy
151
+ .mypy_cache/
152
+ .dmypy.json
153
+ dmypy.json
154
+
155
+ # Pyre type checker
156
+ .pyre/
157
+
158
+ # pytype static type analyzer
159
+ .pytype/
160
+
161
+ # Cython debug symbols
162
+ cython_debug/
163
+
164
+ # PyCharm
165
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
166
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
167
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
168
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
169
+ #.idea/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Kento Abeywardane
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,336 @@
1
+ Metadata-Version: 2.4
2
+ Name: shepherd-score
3
+ Version: 0.1.0
4
+ Summary: 3D scoring functions used for evaluation of ShEPhERD
5
+ Home-page: https://github.com/kentoabeywardane/shepherd-score
6
+ Author: Kento Abeywardane
7
+ Author-email: Kento Abeywardane <kento@mit.edu>
8
+ License: MIT
9
+ Project-URL: Homepage, https://github.com/kentoabeywardane/shepherd-score
10
+ Project-URL: Repository, https://github.com/kentoabeywardane/shepherd-score
11
+ Project-URL: Documentation, https://github.com/kentoabeywardane/shepherd-score
12
+ Project-URL: Bug Tracker, https://github.com/kentoabeywardane/shepherd-score/issues
13
+ Keywords: bioinformatics,molecular-modeling,3d-scoring,drug-discovery,chemistry,bioisosteres
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
17
+ Classifier: Topic :: Scientific/Engineering :: Chemistry
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.8
20
+ Classifier: Programming Language :: Python :: 3.9
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Operating System :: OS Independent
24
+ Classifier: License :: OSI Approved :: MIT License
25
+ Requires-Python: >=3.8,<3.12
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Requires-Dist: open3d>=0.18
29
+ Provides-Extra: dev
30
+ Requires-Dist: pytest>=6.0; extra == "dev"
31
+ Requires-Dist: pytest-cov; extra == "dev"
32
+ Requires-Dist: black; extra == "dev"
33
+ Requires-Dist: flake8; extra == "dev"
34
+ Requires-Dist: mypy; extra == "dev"
35
+ Provides-Extra: docs
36
+ Requires-Dist: sphinx; extra == "docs"
37
+ Requires-Dist: sphinx-rtd-theme; extra == "docs"
38
+ Dynamic: author
39
+ Dynamic: home-page
40
+ Dynamic: license-file
41
+ Dynamic: requires-python
42
+
43
+ # *ShEPhERD* Scoring Functions
44
+ This repository contains the code for **generating/optimizing conformers**, **extracting interaction profiles**, **aligning interaction profiles**, and **differentiably scoring 3D similarity**. It also contains modules to evaluate conformers generated with *ShEPhERD*<sup>1</sup> and other generative models.
45
+
46
+ The formulation of the interaction profile representation, scoring, alignment, and evaluations are found in our preprint [*ShEPhERD*: Diffusing shape, electrostatics, and pharmacophores for bioisosteric drug design](https://arxiv.org/abs/2411.04130). The diffusion model itself is found in a *separate* repository: [https://github.com/coleygroup/shepherd](https://github.com/coleygroup/shepherd).
47
+
48
+
49
+ <p align="center">
50
+ <img width="200" src="./logo.svg">
51
+ </p>
52
+
53
+ <sub><sup>1</sup> *ShEPhERD*: **S**hape, **E**lectrostatics, and **Ph**armacophores **E**xplicit **R**epresentation **D**iffusion</sub>
54
+
55
+ ## Table of Contents
56
+ 1. [File Structure](#file-structure)
57
+ 2. [Requirements](#requirements)
58
+ 3. [Installation](#installation)
59
+ 4. [Usage](#how-to-use)
60
+ 5. [Scoring and Alignment Examples](#scoring-and-alignment-examples)
61
+ 6. [Evaluation Examples and Scripts](#evaluation-examples-and-scripts)
62
+ 7. [Data](#data)
63
+
64
+
65
+ ## File Structure
66
+ ```
67
+ .
68
+ ├── shepherd_score/
69
+ │ ├── alignment_utils/ # Alignment and rigid transformations tools
70
+ │ │ ├── pca.py
71
+ │ │ └── se3.py
72
+ │ ├── evaluations/ # Evaluation suite
73
+ │ │ ├── pdbs/
74
+ │ │ ├── utils/
75
+ │ │ │ ├── convert_data.py
76
+ │ │ │ └── interactions.py
77
+ │ │ ├── docking.py # Docking evaluations
78
+ │ │ └── evaluate.py # Generated conformer evaluation pipelines
79
+ │ ├── pharm_utils/
80
+ │ │ ├── pharmacophore.py
81
+ │ │ ├── pharm_vec.py
82
+ │ │ └── smarts_featues.fdef # Pharmacophore definitions
83
+ │ ├── score/ # Scoring related functions and constants
84
+ │ │ ├── constants.py
85
+ │ │ ├── electrostatic_scoring.py
86
+ │ │ ├── gaussian_overlap.py
87
+ │ │ └── pharmacophore_scoring.py
88
+ │ ├── alignment.py
89
+ │ ├── conformer_generation.py # Conformer generation with rdkit and xtb
90
+ │ ├── container.py # Molecule and MoleculePair classes
91
+ │ ├── extract_profiles.py # Functions to extract interaction profiles
92
+ │ ├── generate_point_cloud.py
93
+ │ ├── objective.py # Objective function used for REINVENT
94
+ │ └── visualize.py # Visualization tools
95
+ ├── scripts/ # Scripts for running evaluations
96
+ ├── examples/ # Jupyter notebook tutorials/examples
97
+ ├── tests/
98
+ ├── environment.yml # Environment
99
+ └── README.md
100
+ ```
101
+
102
+
103
+ ## Requirements
104
+ An example environment can be found at `environment.yml`, however, this package should generally work where PyTorch, Open3D, RDKit, and xTB can be installed in an environment with Python >=3.8.
105
+
106
+ #### Minimum requirements for interaction profile extraction, scoring/alignment, and evaluations
107
+ ```
108
+ python>=3.8
109
+ numpy>1.2,<2.0
110
+ pytorch>=1.12
111
+ mkl==2024.0 (use conda)
112
+ open3d>=0.18
113
+ rdkit>=2023.03 (newest available is recommended)
114
+ xtb>=6.6 (use conda)
115
+ scipy>=1.10
116
+ pandas>=2.0
117
+ ```
118
+
119
+ <sup>Make sure that mkl is *not* 2024.1 since there is a known [issue](https://github.com/pytorch/pytorch/issues/123097) that prevents importing torch.</sup>
120
+
121
+ #### If you are coming from the *ShEPhERD* repository, you can use the same environment as described there and add the optional packages listed below, if needed.
122
+
123
+
124
+ #### Optional software necessary for docking evaluation
125
+ ```
126
+ meeko
127
+ vina==1.2.5
128
+ ```
129
+ You can pip install the python bindings for Autodock Vina for the python interface. However, this also requires an installation of the executable of Autodock Vina v1.2.5: [https://vina.scripps.edu/downloads/](https://vina.scripps.edu/downloads/) and the ADFR software suite: [https://ccsb.scripps.edu/adfr/implementation/](https://ccsb.scripps.edu/adfr/implementation/).
130
+
131
+ #### Other optional packages
132
+ ```
133
+ jax==0.4.26
134
+ jaxlib==0.4.26+cuda12.cudnn89
135
+ optax==0.2.2
136
+ py3dmol>=2.1.0
137
+ biopython>=1.84
138
+ prolif>=2.0.3
139
+ mdanalysis>=2.2.0
140
+ scikit-learn>=1.3
141
+ ```
142
+
143
+ ## Installation
144
+ 1. Clone this repo
145
+ 2. Navigate to this repo's top-level directory
146
+ 3. Set up the environment following the instructions above
147
+ 4. Run `pip install -e .` for developer install
148
+
149
+ ## Usage
150
+ The package has base functions and convenience wrappers. Scoring can be done with either NumPy or Torch, but alignment requires Torch. There are also Jax implementations for both scoring and alignment of gaussian overlap and ESP similarity, but currently *not* for pharmacophores.
151
+
152
+ ### Base functions
153
+ #### Conformer generation
154
+ Useful conformer generation functions are found in the `shepherd_score.conformer_generation` module.
155
+
156
+ #### Interaction profile extraction
157
+ | Interaction profile | Function |
158
+ | :------- | :------- |
159
+ | shape | `shepherd_score.extract_profiles.get_molecular_surface()` |
160
+ | electrostatics | `shepherd_score.extract_profiles.get_electrostatic_potential()` |
161
+ | pharmacophores | `shepherd_score.extract_profiles.get_pharmacophores()` |
162
+
163
+ #### Scoring
164
+ ```shepherd_score.score``` contains the base scoring functions with seperate modules for those dependent on PyTorch (`*.py`), NumPy (`*_np.py`), and Jax (`*_jax.py`).
165
+
166
+ | Similarity | Function |
167
+ | :------- | :------- |
168
+ | shape | `shepherd_score.score.gaussian_overlap.get_overlap()` |
169
+ | electrostatics | `shepherd_score.score.electrostatic_scoring.get_overlap_esp()` |
170
+ | pharmacophores | `shepherd_score.score.pharmacophore_scoring.get_overlap_pharm()` |
171
+
172
+ ### Convenience wrappers
173
+ - `Molecule` class
174
+ - `shepherd_score.container.Molecule` accepts an RDKit `Mol` object (with an associated conformer) and generates user-specified interaction profiles
175
+ - `MoleculePair` class
176
+ - `shepherd_score.container.MoleculePair` operates on `Molecule` objects and prepares them for scoring and alignment
177
+
178
+
179
+ ## Scoring and Alignment Examples
180
+
181
+ Full jupyter notebook tutorials/examples for extraction, scoring, and alignments are found in the [`examples`](./examples/) folder. Some minimal examples are below.
182
+
183
+ ### Extraction
184
+ Extraction of interaction profiles.
185
+
186
+ ```python
187
+ from shepherd_score.conformer_generation import embed_conformer_from_smiles
188
+ from shepherd_score.conformer_generation import charges_from_single_point_conformer_with_xtb
189
+ from shepherd_score.extract_profiles import get_atomic_vdw_radii, get_molecular_surface
190
+ from shepherd_score.extract_profiles import get_pharmacophores, get_electrostatic_potential
191
+ from shepherd_score.extract_profiles import get_electrostatic_potential
192
+
193
+ # Embed conformer with RDKit and partial charges from xTB
194
+ ref_mol = embed_conformer_from_smiles('Oc1ccc(CC=C)cc1', MMFF_optimize=True)
195
+ partial_charges = charges_from_single_point_conformer_with_xtb(ref_mol)
196
+
197
+ # Radii are needed for surface extraction
198
+ radii = get_atomic_vdw_radii(ref_mol)
199
+ # `surface` is an np.array with shape (200, 3)
200
+ surface = get_molecular_surface(ref_mol.GetConformer().GetPositions(), radii, num_points=200)
201
+
202
+ # Get electrostatic potential at each point on the surface
203
+ # `esp`: np.array (200,)
204
+ esp = get_electrostatic_potential(ref_mol, partial_charges, surface)
205
+
206
+ # Pharmacophores as arrays with averaged vectors
207
+ # pharm_types: np.array (P,)
208
+ # pharm_{pos/vecs}: np.array (P,3)
209
+ pharm_types, pharm_pos, pharm_vecs = get_pharmacophores(ref_mol, multi_vector=False)
210
+ ```
211
+
212
+ ### 3D similarity scoring
213
+ An example of scoring the similarity of two different molecules using 3D surface, ESP, and pharmacophore similarity metrics.
214
+
215
+ ```python
216
+ from shepherd_score.score.constants import ALPHA
217
+ from shepherd_score.conformer_generation import embed_conformer_from_smiles
218
+ from shepherd_score.conformer_generation import optimize_conformer_with_xtb
219
+ from shepherd_score.container import Molecule, MoleculePair
220
+
221
+ # Embed a random conformer with RDKit
222
+ ref_mol_rdkit = embed_conformer_from_smiles('Oc1ccc(CC=C)cc1', MMFF_optimize=True)
223
+ fit_mol_rdkit = embed_conformer_from_smiles('O=CCc1ccccc1', MMFF_optimize=True)
224
+ # Local relaxation with xTB
225
+ ref_mol, _, ref_charges = optimize_conformer_with_xtb(ref_mol_rdkit)
226
+ fit_mol, _, fit_charges = optimize_conformer_with_xtb(fit_mol_rdkit)
227
+
228
+ # Extract interaction profiles
229
+ ref_molec = Molecule(ref_mol,
230
+ num_surf_points=200,
231
+ partial_charges=ref_charges,
232
+ pharm_multi_vector=False)
233
+ fit_molec = Molecule(fit_mol,
234
+ num_surf_points=200,
235
+ partial_charges=fit_charges,
236
+ pharm_multi_vector=False)
237
+
238
+ # Centers the two molecules' COM's to the origin
239
+ mp = MoleculePair(ref_molec, fit_molec, num_surf_points=200, do_center=True)
240
+
241
+ # Compute the similarity score for each interaction profile
242
+ shape_score = mp.score_with_surf(ALPHA(mp.num_surf_points))
243
+ esp_score = mp.score_with_esp(ALPHA(mp.num_surf_points), lam=0.3)
244
+ pharm_score = mp.score_with_pharm()
245
+ ```
246
+
247
+ ### Alignment
248
+ Next we show alignment using the same MoleculePair class.
249
+
250
+ ```python
251
+ # Centers the two molecules' COM's to the origin
252
+ mp = MoleculePair(ref_molec, fit_molec, num_surf_points=200, do_center=True)
253
+
254
+ # Align fit_molec to ref_molec with your preferred objective function
255
+ # By default we use automatic differentiation via pytorch
256
+ surf_points_aligned = mp.align_with_surf(ALPHA(mp.num_surf_points),
257
+ num_repeats=50)
258
+ surf_points_esp_aligned = mp.align_with_esp(ALPHA(mp.num_surf_points),
259
+ lam=0.3,
260
+ num_repeats=50)
261
+ pharm_pos_aligned, pharm_vec_aligned = mp.align_with_pharm(num_repeats=50)
262
+
263
+ # Optimal scores and SE(3) transformation matrices are stored as attributes
264
+ mp.sim_aligned_{surf/esp/pharm}
265
+ mp.transform_{surf/esp/pharm}
266
+
267
+ # Get a copy of the optimally aligned fit Molecule object
268
+ transformed_fit_molec = mp.get_transformed_molecule(
269
+ se3_transform=mp.transform_{surf/esp/pharm}
270
+ )
271
+ ```
272
+
273
+ ## Evaluation Examples and Scripts
274
+
275
+ We implement three evaluations of generated 3D conformers. Evaluations can be done on an individual basis or in a pipeline. Here we show the most basic use case in the unconditional setting.
276
+
277
+
278
+ - `ConfEval`
279
+ - Checks validity, pre-/post-xTB relaxation
280
+ - Calculates 2D graph properties
281
+ - `ConsistencyEval`
282
+ - Inherits from `ConfEval` and evaluates the consistency of the molecule's jointly generated interaction profiles with the true interaction profiles using 3D similarity scoring functions
283
+ - `ConditionalEval`
284
+ - Inherits from `ConfEval` and evaluates the 3D similarity between generated molecules and the target molecule
285
+
286
+ **Note**: Evaluations can be run from any molecule's atomic numbers and positions with explicit hydrogens (i.e., straight from an xyz file).
287
+
288
+ ### Examples
289
+
290
+ Full jupyter notebook tutorials/examples for evaluations are found in the [`examples`](./examples/) folder. Some minimal examples are below.
291
+
292
+ ```python
293
+ from shepherd_score.evaluations.evalutate import ConfEval
294
+ from shepherd_score.evaluations.evalutate import UnconditionalEvalPipeline
295
+
296
+ # ConfEval evaluates the validity of a given molecule, optimizes it with xTB,
297
+ # and also computes various 2D graph properties
298
+ # `atom_array` np.ndarray (N,) atomic numbers of the molecule (with explicit H)
299
+ # `position_array` np.ndarray (N,3) atom coordinates for the molecule
300
+ conf_eval = ConfEval(atoms=atom_array, positions=position_array)
301
+
302
+ # Alternatively, if you have a list of molecules you want to test:
303
+ uncond_pipe = UnconditionalEvalPipeline(
304
+ generated_mols = [(a, p) for a, p in zip(atom_arrays, position_arrays)]
305
+ )
306
+ uncond_pipe.evaluate()
307
+
308
+ # Properties are stored as attributes and can be converted into pandas df's
309
+ sample_df, global_series = uncond_pipe.to_pandas()
310
+ ```
311
+
312
+ ### Scripts
313
+ Scripts to evaluate *ShEPhERD*-generated samples can be found in the `scripts` directory.
314
+
315
+ ## Data
316
+ We provide the data used for model training, benchmarking, and all *ShEPhERD*-generated samples reported in the paper at this [Dropbox link](https://www.dropbox.com/scl/fo/rgn33g9kwthnjt27bsc3m/ADGt-CplyEXSU7u5MKc0aTo?rlkey=fhi74vkktpoj1irl84ehnw95h&e=1&st=wn46d6o2&dl=0). There are comprehensive READMEs in the Dropbox describing the different folders.
317
+
318
+ ## License
319
+
320
+ This project is licensed under the MIT License -- see [LICENSE](./LICENSE) file for details.
321
+
322
+ ## Citation
323
+ If you use or adapt `shepherd_score` or [*ShEPhERD*](https://github.com/coleygroup/shepherd) in your work, please cite us:
324
+
325
+ ```bibtex
326
+ @misc{adamsShEPhERD2024,
327
+ title = {{{ShEPhERD}}: {{Diffusing}} Shape, Electrostatics, and Pharmacophores for Bioisosteric Drug Design},
328
+ author = {Adams, Keir and Abeywardane, Kento and Fromer, Jenna and Coley, Connor W.},
329
+ year = {2024},
330
+ number = {arXiv:2411.04130},
331
+ eprint = {2411.04130},
332
+ publisher = {arXiv},
333
+ doi = {10.48550/arXiv.2411.04130},
334
+ archiveprefix = {arXiv}
335
+ }
336
+ ```