datamol.conformers
¶
align_conformers(mols, ref_id=0, copy=True, conformer_id=-1, backend='crippenO3A')
¶
Align a list of molecules to a reference molecule.
Note that using the O3A
backend, hydrogens will be added at the beginning of the procedure
and removed at the end of the procedure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mols |
List[Mol]
|
List of molecules to align. All the molecules must have a conformer. |
required |
ref_id |
int
|
Index of the reference molecule. By default, the first molecule in the list will be used as reference. |
0
|
copy |
bool
|
Whether to copy the molecules before performing the alignement. |
True
|
conformer_id |
int
|
Conformer id to use. |
-1
|
backend |
str
|
Backend to use to compute the alignment from |
'crippenO3A'
|
Returns:
Name | Type | Description |
---|---|---|
mols |
list
|
The aligned molecules. |
scores |
list
|
The score of the alignement. |
Source code in datamol/conformers/_conformers.py
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 |
|
cluster(mol, rms_cutoff=1, already_aligned=False, centroids=True)
¶
Cluster the conformers of a molecule according to an RMS threshold in Angstrom.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mol |
Mol
|
a molecule |
required |
rms_cutoff |
float
|
The RMS cutoff in Angstrom. |
1
|
already_aligned |
bool
|
Whether or not the conformers are aligned. If False, they will be aligmned furing the RMS computation. |
False
|
centroids |
bool
|
If True, return one molecule with centroid conformers only. If False return a list of molecules per cluster with all the conformers of the cluster. Defaults to True. |
True
|
Source code in datamol/conformers/_conformers.py
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
|
generate(mol, n_confs=None, use_random_coords=True, enforce_chirality=True, num_threads=1, rms_cutoff=None, clear_existing=True, align_conformers=True, minimize_energy=False, sort_by_energy=True, method=None, forcefield='UFF', ewindow=np.inf, eratio=np.inf, energy_iterations=200, warning_not_converged=0, random_seed=19, add_hs=True, ignore_failure=False, embed_params=None, verbose=False)
¶
Compute conformers of a molecule.
Example:
import datamol as dm
smiles = "O=C(C)Oc1ccccc1C(=O)O"
mol = dm.to_mol(smiles)
mol = dm.conformers.generate(mol)
# Get all conformers as a list
conformers = mol.GetConformers()
# Get the 3D atom positions of the first conformer
positions = mol.GetConformer(0).GetPositions()
# If minimization has been enabled (default to True)
# you can access the computed energy.
conf = mol.GetConformer(1)
props = conf.GetPropsAsDict()
print(props)
# {'rdkit_UFF_energy': 35.64074017773132,'rdkit_UFF_delta_energy': 0.24682258222552633}
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mol |
Mol
|
a molecule |
required |
n_confs |
Optional[int]
|
Number of conformers to generate. Depends on the number of rotatable bonds by default: 50 for <8, 200 for <12 and 300 for >12. |
None
|
use_random_coords |
bool
|
Start the embedding from random coordinates instead of using eigenvalues of the distance matrix. |
True
|
enforce_chirality |
bool
|
Enforce correct chirilaty if chiral centers are present. |
True
|
num_threads |
int
|
Number of threads to use when embedding multiple conformations. |
1
|
rms_cutoff |
Optional[float]
|
The minimum RMS value in Angstrom at which two conformers are considered redundant and one is deleted. If None, all conformers are kept. This step is done after an eventual minimization step. |
None
|
clear_existing |
bool
|
Whether to overwrite existing conformers for the molecule. |
True
|
align_conformers |
bool
|
Whether to align the conformers. |
True
|
minimize_energy |
bool
|
Whether to minimize conformer's energies using MMFF94s. Disable to generate conformers much faster. |
False
|
sort_by_energy |
bool
|
Sort conformers by energy when minimizing is turned to False. |
True
|
method |
Optional[str]
|
RDKit method to use for embedding. Choose among ["ETDG", "ETKDG", "ETKDGv2", "ETKDGv3"]. If None, "ETKDGv3" is used. |
None
|
forcefield |
str
|
molecular forcefield to use, one of ['UFF','MMFF94s','MMFF94s_noEstat'] |
'UFF'
|
ewindow |
float
|
maximum energy above minimum energy conformer to output |
np.inf
|
eratio |
float
|
max delta-energy divided by rotatable bonds for conformers |
np.inf
|
energy_iterations |
int
|
Maximum number of iterations during the energy minimization procedure.
It corresponds to the |
200
|
warning_not_converged |
int
|
Wether to log a warning when the number of not converged conformers
during the minimization is higher than |
0
|
random_seed |
int
|
Set to None or -1 to disable. |
19
|
add_hs |
bool
|
Whether to add hydrogens to the mol before embedding. If set to True, the hydrogens are removed in the returned molecule. Warning: explicit hydrogens won't be conserved. It is strongly recommended to let the default value to True. The RDKit documentation says: "To get good 3D conformations, it's almost always a good idea to add hydrogens to the molecule first." |
True
|
ignore_failure |
bool
|
It set to True, this will avoid raising an error when the embedding fails and return None instead. |
False
|
embed_params |
Optional[dict]
|
Allows the user to specify arbitrary embedding parameters for the conformers. This will override any other default settings. See https://www.rdkit.org/docs/source/rdkit.Chem.rdDistGeom.html#rdkit.Chem.rdDistGeom.EmbedParameters for more details. |
None
|
verbose |
bool
|
Wether to enable logs during the process. |
False
|
Returns:
Name | Type | Description |
---|---|---|
mol |
Mol
|
the molecule with the conformers. |
Source code in datamol/conformers/_conformers.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
|
return_centroids(mol, conf_clusters, centroids=True)
¶
Given a list of cluster indices, return one single molecule with only the centroid of the clusters of a list of molecules per cluster.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mol |
Mol
|
a molecule. |
required |
conf_clusters |
Sequence[Sequence[int]]
|
list of cluster indices. |
required |
centroids |
bool
|
If True, return one molecule with centroid conformers only. If False return a list of molecules per cluster with all the conformers of the cluster. |
True
|
Source code in datamol/conformers/_conformers.py
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 |
|
rmsd(mol)
¶
Compute the RMSD between all the conformers of a molecule.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mol |
Mol
|
a molecule |
required |
Source code in datamol/conformers/_conformers.py
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 |
|
translate(mol, new_centroid, conf_id=-1)
¶
Move a given conformer of a molecule to a new position. The transformation is performed in place.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mol |
Mol
|
the molecule. |
required |
new_centroid |
Union[np.ndarray, List[int]]
|
the new position to move to of shape [x, y, z] |
required |
conf_id |
int
|
id of the conformer. |
-1
|
Source code in datamol/conformers/_conformers.py
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 |
|
center_of_mass(mol, use_atoms=True, digits=None, conf_id=-1)
¶
Compute the center of mass of a conformer of a molecule.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mol |
Mol
|
a molecule |
required |
use_atoms |
bool
|
Whether to compute the true center of mass or the geometrical center. |
True
|
digits |
Optional[int]
|
Number of digits to round to. |
None
|
conf_id |
int
|
the conformer id. |
-1
|
Returns cm: Center of mass or geometrical center
Source code in datamol/conformers/_features.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
get_coords(mol, conf_id=-1)
¶
Get the coordinate of a conformer of a molecule.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mol |
Mol
|
a molecule. |
required |
conf_id |
int
|
a conformer id. |
-1
|
Source code in datamol/conformers/_features.py
86 87 88 89 90 91 92 93 94 95 96 97 98 |
|
keep_conformers(mol, indices_to_keep=-1, assign_id=True, copy=True)
¶
Keep on the specified conformer(s) in indices_to_keep
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mol |
Mol
|
A molecule. |
required |
indices_to_keep |
Union[int, List[int]]
|
A indice or a least of indices of conformers to keep. |
-1
|
assign_id |
bool
|
Whether to assign the kept conformers an id or keep the original one. |
True
|
copy |
bool
|
Whether to copy the molecule or not. |
True
|
Source code in datamol/conformers/_features.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
|
sasa(mol, conf_id=None, n_jobs=1)
¶
Compute Solvent Accessible Surface Area of all the conformers
using FreeSASA (https://freesasa.github.io/). Values are returned
as an array and also stored within each conformer as a property
called rdkit_free_sasa
.
Example:
smiles = "O=C(C)Oc1ccccc1C(=O)O"
mol = dm.to_mol(smiles)
mol = dm.conformers.generate(mol)
# Compute SASA for all the conformers without parallelization
sasa_values = dm.conformers.sasa(mol, conf_id=None, n_jobs=1)
# If minimization has been enabled (default to True)
# you can access the computed energy.
conf = mol.GetConformer(0)
props = conf.GetPropsAsDict()
print(props)
# {'rdkit_uff_energy': 1.7649408317784008}
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mol |
Mol
|
a molecule |
required |
conf_id |
Optional[Union[int, List[int]]]
|
Id of the conformers to compute. If None, compute all. |
None
|
n_jobs |
int
|
Number of jobs for parallelization. Set to 1 to disable and -1 to use all cores. |
1
|
Returns:
Name | Type | Description |
---|---|---|
mol |
np.ndarray
|
the molecule with the conformers. |
Source code in datamol/conformers/_features.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
|