Calculators
¶
get_calculator(name, **params)
¶
Get molecular calculator based on name
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Name of the featurizer |
required |
params |
dict
|
Parameters of the featurizer |
{}
|
Raises:
Type | Description |
---|---|
ValueError
|
When featurizer is not supported |
Returns:
Name | Type | Description |
---|---|---|
featurizer |
Callable |
Source code in molfeat/calc/__init__.py
10 11 12 13 14 15 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 |
|
Serializable Calculator are the base abstract class for implementing your calculators.¶
SerializableCalculator
¶
Bases: ABC
Interface to define a serializable calculator
Subclassing SerializableCalculator
When subclassing a calculator, you must implement the call method.
If your calculator also implements a batch_compute
method, it will be used
by MoleculeTransformer
to accelerate featurization.
from molfeat.calc import SerializableCalculator
class MyCalculator(SerializableCalculator):
def __call__(self, mol, **kwargs):
# you have to implement this
...
def __len__(self):
# you don't have to implement this but are encouraged to do so
# this is used to determine the length of the output
...
@property
def columns(self):
# you don't have to implement this
# use this to return the name of each entry returned by your featurizer
...
def batch_compute(self, mols:list, **dm_parallelized_kwargs):
# you don't need to implement this
# but you should if there is an efficient batching process
# By default dm.parallelized arguments will also be passed as input
...
Source code in molfeat/calc/base.py
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 |
|
from_state_dict(state, override_args=None)
classmethod
¶
Load from state dictionary
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state |
dict
|
dictionary to use to create the the calculator |
required |
overrride_args |
optional dictionary of arguments to override the ones in the state dict at construction of the new object |
required |
Source code in molfeat/calc/base.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
to_state_dict()
¶
Get the state dictionary
Source code in molfeat/calc/base.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
|
to_state_json()
¶
Output this instance as a JSON representation
Source code in molfeat/calc/base.py
103 104 105 |
|
to_state_json_file(filepath)
¶
Save the state of this instance as a JSON file
Source code in molfeat/calc/base.py
111 112 113 114 |
|
to_state_yaml()
¶
Output this instance as a YAML representation
Source code in molfeat/calc/base.py
107 108 109 |
|
to_state_yaml_file(filepath)
¶
Save the state of this instance as a YAML file
Source code in molfeat/calc/base.py
116 117 118 119 |
|
Fingerprints
¶
FPCalculator
¶
Bases: SerializableCalculator
Fingerprint bit calculator for a molecule
Source code in molfeat/calc/fingerprints.py
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 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 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 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 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 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
|
columns
property
¶
Get the name of all the descriptors of this calculator
__call__(mol, raw=False)
¶
Compute the Fingerprint of a molecule
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mol |
Union[Mol, str]
|
the molecule of interest |
required |
raw |
bool
|
whether to keep original datatype or convert to numpy. Useful for rdkit's similarity functions |
False
|
Returns:
Name | Type | Description |
---|---|---|
props |
ndarray
|
list of computed rdkit molecular descriptors |
Source code in molfeat/calc/fingerprints.py
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 |
|
__init__(method, length=None, counting=False, **method_params)
¶
Compute the given fingeprint for a molecule
Note
For efficiency reason, count fingerprints are hashed and potentially re-folded and the count corresponds to the number of bits set to true
Parameters:
Name | Type | Description | Default |
---|---|---|---|
method |
str
|
Name of the fingerprint method to use. See FPCalculator.available_fingerprints() for a list |
required |
length |
int
|
Length of the fingerprint. Defaults to None. The default corresponds to the fingerpint default. |
None
|
counting |
bool
|
Whether to use the count version of the fingerprint |
False
|
method_params |
dict
|
any parameters to the fingerprint algorithm. See FPCalculator.default_parameters(method) for all the parameters required by a given method. |
{}
|
Source code in molfeat/calc/fingerprints.py
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 235 236 237 238 239 |
|
__len__()
¶
Return the length of the calculator
Source code in molfeat/calc/fingerprints.py
262 263 264 |
|
__setstate__(state)
¶
Set the state of the featurizer
Source code in molfeat/calc/fingerprints.py
341 342 343 344 345 346 347 348 |
|
available_fingerprints()
staticmethod
¶
Get the list of available fingerprints
Source code in molfeat/calc/fingerprints.py
241 242 243 244 |
|
default_parameters(method)
staticmethod
¶
Get the default parameters for a given fingerprint method
Parameters:
Name | Type | Description | Default |
---|---|---|---|
method |
str
|
name of the fingerprint method |
required |
Source code in molfeat/calc/fingerprints.py
246 247 248 249 250 251 252 253 |
|
to_state_dict()
¶
Get the state dictionary
Source code in molfeat/calc/fingerprints.py
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
|
CATS
¶
CATS 2D and 3D implementation based on original work by Rajarshi Guha rguha@indiana.edu 08/26/07 and Chris Arthur 1/11/2015 Rdkit port This version modernizes the code, improve performance, add supports for 3D as well as allowing distance binning. see: https://masterchemoinfo.u-strasbg.fr/Documents/Conferences/Lecture1_Pharmacophores_Schneider.pdf
CATS
¶
Bases: SerializableCalculator
Cats descriptors calculator based on PPPs (potential pharmacophore points). Can be either 2D or 3D.
!!! note:
We need to consider all pairwise combination of the 6 PPPs described in CATS2D.SMARTS
which would be $P(6,2) + 6$. However, as we only consider lexicographic order, the total size
is then $rac{P(6,2)}{2} + 6 = 21$, explaining the size of CATS2D.DESCRIPTORS
Tip
The CATS descriptor are sensitive to the number of atoms in a molecule, meaning, you would get different results if you add or remove hydrogen atoms
Source code in molfeat/calc/cats.py
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 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 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 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 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
|
columns
property
¶
Get the descriptors columns
__call__(mol, conformer_id=-1)
¶
Get CATS 2D descriptors for a molecule
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mol |
Union[Mol, str]
|
the molecule of interest. |
required |
conformer_id |
int
|
Optional conformer id. Only relevant when |
-1
|
Returns:
Name | Type | Description |
---|---|---|
props |
ndarray
|
list of computed rdkit molecular descriptors |
Source code in molfeat/calc/cats.py
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
|
__getstate__()
¶
Serialize the class for pickling.
Source code in molfeat/calc/cats.py
320 321 322 323 324 325 326 327 |
|
__init__(max_dist=None, bins=None, scale='raw', use_3d_distances=False, **kwargs)
¶
Calculator for the CATS descriptors.
max_dist
and bins
will both determine the length of the fingerprint vector,
which you can get by calling len(calc)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_dist |
Union[float, int]
|
Maximum distance between pairs. When set to None, the default for 2D is
set to |
None
|
bins |
List[int]
|
Bins to use. Defaults to equal spacing |
None
|
scale |
str
|
How to scale the values. Supported values are: - 'raw' for the raw values. - 'num' for values normalized by the number of atoms. - 'count' for scaling based on occurence of the PPP. |
'raw'
|
use_3d_distances |
bool
|
Whether to use the 3D distances instead of the topological distances. If set to True, the input molecules must contain a conformer. |
False
|
kwargs |
silently ignored extra parameters for compatibility with other calculators. |
{}
|
Source code in molfeat/calc/cats.py
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 |
|
__len__()
¶
Return the length of the calculator
Source code in molfeat/calc/cats.py
285 286 287 |
|
__setstate__(state)
¶
Reload the class from pickling.
Source code in molfeat/calc/cats.py
329 330 331 332 |
|
Pharmacophore
¶
Pharmacophore2D
¶
Bases: SerializableCalculator
2D Pharmacophore.
The fingerprint is computed using Generate.Gen2DFingerprint
from RDKit.
An explanation of pharmacophore fingerprints and how the bits are set is available in the RDKit book. In particular the following figure describes the process. { align=left }
Source code in molfeat/calc/pharmacophore.py
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 |
|
columns
property
¶
Get the name of all the descriptors of this calculator.
__call__(mol, raw=False)
¶
Compute the Pharmacophore fingeprint for the input molecule.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mol |
Union[Mol, str]
|
the molecule of interest |
required |
raw |
bool
|
Whether to return the raw fingerprint or a Numpy array. |
False
|
Returns:
Name | Type | Description |
---|---|---|
fp |
the computed fingerprint as a Numpy array or as a raw object. |
Source code in molfeat/calc/pharmacophore.py
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 |
|
__getstate__()
¶
Serialize the class for pickling.
Source code in molfeat/calc/pharmacophore.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
|
__init__(factory='pmapper', length=2048, useCounts=None, minPointCount=None, maxPointCount=None, shortestPathsOnly=None, includeBondOrder=None, skipFeats=None, trianglePruneBins=None, bins=None, **kwargs)
¶
Pharmacophore computation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
factory |
Union[str, MolChemicalFeatureFactory]
|
Which features factory to use. One of "default", "cats", "gobbi" , "pmapper" or path to a feature definition or a feature factory object |
'pmapper'
|
length |
Optional[int]
|
Optional desired length. If provided, the fp will be refold or padded to that length. If set to None, fallback to the default for the provided sig factory. |
2048
|
minPointCount |
int
|
Minimum number of points. |
None
|
maxPointCount |
int
|
Maximum number of points. |
None
|
trianglePruneBins |
bool
|
Whether to prune the triangle inequality. |
None
|
includeBondOrder |
bool
|
Whether to consider bond order. |
None
|
shortestPathsOnly |
bool
|
Whether to only use the shortest path between pharmacophores. |
None
|
useCounts |
bool
|
Whether take into account the count information. This will also impact how the folding works. |
None
|
bins |
List[Tuple[int, int]]
|
Bins to use. |
None
|
Source code in molfeat/calc/pharmacophore.py
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 |
|
__len__()
¶
Returns the length of the pharmacophore
Source code in molfeat/calc/pharmacophore.py
166 167 168 |
|
__setstate__(state)
¶
Reload the class from pickling.
Source code in molfeat/calc/pharmacophore.py
194 195 196 197 |
|
Pharmacophore3D
¶
Bases: SerializableCalculator
3D Pharmacophore.
The fingerprint is computed using pmapper
.
This featurizer supports building a consensus pharmacophore from a set of molecules.
Source code in molfeat/calc/pharmacophore.py
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 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 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 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 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 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 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 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 |
|
__call__(mol, conformer_id=-1, raw=False)
¶
Compute the Pharmacophore fingeprint for the input molecule.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mol |
Union[Mol, str]
|
the molecule of interest |
required |
conformer_id |
int
|
the conformer id to use. |
-1
|
raw |
bool
|
Whether to return the raw fingerprint or a Numpy array. |
False
|
Returns:
Name | Type | Description |
---|---|---|
fp |
the computed fingerprint as a Numpy array. |
Source code in molfeat/calc/pharmacophore.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
|
__getstate__()
¶
Serialize the class for pickling.
Source code in molfeat/calc/pharmacophore.py
609 610 611 612 613 614 615 616 617 618 619 |
|
__init__(factory='pmapper', length=2048, bin_step=1, min_features=2, max_features=3, use_modulo=True, tolerance=0)
¶
Pharmacophore computation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
factory |
Union[str, MolChemicalFeatureFactory]
|
Which features factory to use. One of "default", "cats", "gobbi" , "pmapper" or path to a feature definition or a feature factory object |
'pmapper'
|
length |
int
|
Optional desired length. If provided, the fp will be refold or padded to that length. If set to None, fallback to the default for the provided sig factory. |
2048
|
bin_step |
float
|
Bin step to use. |
1
|
min_features |
int
|
Minimum number of features to use. |
2
|
max_features |
int
|
Maximum number of features to use. |
3
|
use_modulo |
bool
|
whether to use modulo to compute the pharmacophore fingerprint |
True
|
tolerance |
float
|
tolerance value to use when computing the pharmacophore fingerprint |
0
|
Source code in molfeat/calc/pharmacophore.py
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 235 236 237 238 239 240 |
|
__setstate__(state)
¶
Reload the class from pickling.
Source code in molfeat/calc/pharmacophore.py
621 622 623 624 |
|
cluster_features(features, min_samples_ratio=0.5, n_mols=None, eps=np.inf, **kwargs)
¶
Cluster a set of pharmacophoric features using OPTICS. The only reason why we are not using SpectralClustering is because of the need to provide the number of clusters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
features |
DataFrame
|
A dataframe of features. |
required |
min_samples_ratio |
float
|
Percentages of mols that must contain a pharmacophoric point to be considered as a core point. |
0.5
|
n_mols |
int
|
Optional number of compounds to compute |
None
|
eps |
float
|
The maximum distance between two samples for one to be considered as in the neighborhood of the other. This is max_eps in OPTICS |
inf
|
kwargs |
Any additional parameters to pass to |
{}
|
Source code in molfeat/calc/pharmacophore.py
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 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 |
|
compute_fp_from_coords(features_coords, raw=False)
¶
Compute a fingerprint from a list of features.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
features_coords |
List[Tuple[str, Tuple[float]]]
|
Features coords: |
required |
raw |
bool
|
Whether to return the raw fingerprint or a Numpy array. |
False
|
Source code in molfeat/calc/pharmacophore.py
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 |
|
consensus_fp(mols, align=True, conformer_id=-1, copy=True, min_samples_ratio=0.5, eps=2, raw=False, **cluster_kwargs)
¶
Compute a consensus fingerprint from a list of molecules.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mols |
List[Mol]
|
a list of molecules. |
required |
align |
bool
|
Whether to align the conformers of the molecules. |
True
|
conformer_id |
int
|
Optional conformer id. |
-1
|
copy |
bool
|
Whether to copy the molecules before clustering. |
True
|
min_samples_ratio |
float
|
Percentages of mols that must contain a pharmacophoric point to be considered as a core point. |
0.5
|
eps |
float
|
The maximum distance between two samples for one to be considered as in the neighborhood of the other. |
2
|
raw |
bool
|
Whether to return the raw fingerprint or a Numpy array. |
False
|
cluster_kwargs |
additional keyword arguments for the clustering algorithm. |
{}
|
Source code in molfeat/calc/pharmacophore.py
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
|
get_features(mol, conformer_id=-1)
¶
Retrieve the features for a given molecule.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mol |
Mol
|
the molecule of interest |
required |
Returns:
Name | Type | Description |
---|---|---|
features |
DataFrame
|
the features as a Numpy array |
Source code in molfeat/calc/pharmacophore.py
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 |
|
get_features_from_many(mols, align=True, conformer_id=-1, copy=True, keep_mols=False)
¶
Extract all the features from a list of molecules after an optional alignement step.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mols |
List[Mol]
|
List of molecules with conformers. |
required |
align |
bool
|
Whether to align the conformers of the molecules. |
True
|
conformer_id |
int
|
Optional conformer id. |
-1
|
copy |
bool
|
Whether to copy the molecules before clustering. |
True
|
keep_mols |
bool
|
Whether to keep the molecules in the returned dataframe. |
False
|
Source code in molfeat/calc/pharmacophore.py
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 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 |
|
show(mol, features=None, alpha=1.0, sphere_radius=0.4, show_legend=True)
¶
Show a 3D view of a given molecule with the pharmacophoric features.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mol |
Mol
|
the molecule of interest |
required |
alpha |
float
|
Alpha value for the colors (currently not working). |
1.0
|
sphere_radius |
float
|
Radius of the spheres for the features. |
0.4
|
show_legend |
bool
|
Display the legend (the layout is bad but at least it shows the legend). |
True
|
Source code in molfeat/calc/pharmacophore.py
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 |
|
show_many(mols, align=True, conformer_id=-1, copy=True, min_samples_ratio=0.5, eps=2, alpha=1.0, sphere_radius=0.4, show_legend=True)
¶
Show a 3D view of a given molecule with the pharmacophoric features.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mols |
List[Mol]
|
a list of molecules. |
required |
align |
bool
|
Whether to align the conformers of the molecules. |
True
|
conformer_id |
int
|
Optional conformer id. |
-1
|
copy |
bool
|
Whether to copy the molecules before clustering. |
True
|
min_samples_ratio |
float
|
Percentages of mols that must contain a pharmacophoric point to be considered as a core point. |
0.5
|
eps |
float
|
The maximum distance between two samples for one to be considered as in the neighborhood of the other. |
2
|
alpha |
float
|
Alpha value for the colors (currently not working). |
1.0
|
sphere_radius |
float
|
Radius of the spheres for the features. |
0.4
|
show_legend |
bool
|
Display the legend (the layout is bad but at least it shows the legend). |
True
|
Source code in molfeat/calc/pharmacophore.py
552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 |
|
get_feature_factory(factory)
¶
Build a feature factory.
Source code in molfeat/calc/pharmacophore.py
630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 |
|
get_sig_factory(factory, useCounts=None, minPointCount=None, maxPointCount=None, shortestPathsOnly=None, includeBondOrder=None, skipFeats=None, trianglePruneBins=None, bins=None, init_factory=True)
¶
Build a signature factory.
Source code in molfeat/calc/pharmacophore.py
665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 |
|
get_sig_factory_params(factory_name, useCounts=None, minPointCount=None, maxPointCount=None, shortestPathsOnly=None, includeBondOrder=None, skipFeats=None, trianglePruneBins=None, bins=None)
¶
Get the default parameter for a given sig factory allowing some of them to be overriden.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
factory_name |
str
|
The name of the factory. |
required |
Source code in molfeat/calc/pharmacophore.py
708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 |
|
Scaffold Keys
¶
ScaffoldKeyCalculator
¶
Bases: SerializableCalculator
Implementation of the Scaffold Keys described in
Identification of Bioisosteric Scaffolds using Scaffold Keys
by Peter Ertl
Source code in molfeat/calc/skeys.py
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 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 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 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 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 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 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 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 |
|
columns
property
¶
Get the name of all the descriptors of this calculator
__call__(mol)
¶
Compute the Fingerprint of a molecule
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mol |
Union[Mol, str]
|
the molecule of interest |
required |
Returns:
Name | Type | Description |
---|---|---|
props |
ndarray
|
list of computed rdkit molecular descriptors |
Source code in molfeat/calc/skeys.py
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 |
|
__getstate__()
¶
Get state of the scaffold key function
Source code in molfeat/calc/skeys.py
175 176 177 178 179 180 181 |
|
__init__(normalize=False, verbose=False, use_scaffold=False, **kwargs)
¶
Init of the scaffold key function
Parameters:
Name | Type | Description | Default |
---|---|---|---|
normalize |
bool
|
whether to normalize the value of the feature |
False
|
verbose |
bool
|
whether to log errors |
False
|
use_scaffold |
bool
|
whether to convert the molecule into scaffold first |
False
|
Source code in molfeat/calc/skeys.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
|
abs_scaffold_format_charge(mol)
¶
- absolute value of the scaffold formal charge
Source code in molfeat/calc/skeys.py
291 292 293 294 |
|
compute_normalization(features)
classmethod
¶
Normalize input features. The normalization parameters are computed by the scaffolds of 2.1M molecules from CHEMBL 29.
Source code in molfeat/calc/skeys.py
186 187 188 189 190 191 |
|
n_atom_at_least_2_nei_more_than_2_conn(mol)
¶
- Number of atoms where at least 2 connected atoms have more than 2 connections
Source code in molfeat/calc/skeys.py
283 284 285 286 287 288 289 |
|
n_atom_exocyclic(mol)
¶
- number of exocyclic atoms (connected by multiple bonds to a ring)
Source code in molfeat/calc/skeys.py
225 226 227 228 |
|
n_atom_in_chain(mol)
¶
- number atoms in chains (not counting double-connected exo-chain atoms)
Source code in molfeat/calc/skeys.py
220 221 222 223 |
|
n_atom_in_conjugated_ring(mol)
¶
- number of atoms in conjugated rings
Source code in molfeat/calc/skeys.py
198 199 200 201 202 203 204 205 |
|
n_atom_in_rings(mol)
¶
- number of ring atoms
Source code in molfeat/calc/skeys.py
193 194 195 196 |
|
n_atom_spiro_atoms(mol)
¶
- number of spiro atoms
Source code in molfeat/calc/skeys.py
266 267 268 |
|
n_atoms_not_in_conjugated_ring(mol)
¶
- number of atoms not in conjugated rings (i.e. atoms in aliphatic rings and non-ring atoms)
Source code in molfeat/calc/skeys.py
207 208 209 210 211 212 213 214 215 216 217 218 |
|
n_bonds(mol)
¶
- number of bonds
Source code in molfeat/calc/skeys.py
296 297 298 |
|
n_bonds_2_heteroatoms(mol)
¶
- number of bonds connecting 2 heteroatoms
Source code in molfeat/calc/skeys.py
312 313 314 315 |
|
n_bonds_at_least_3_conn(mol)
¶
- number of bonds with at least 3 connections on both its atoms
Source code in molfeat/calc/skeys.py
322 323 324 325 |
|
n_bonds_atoms_with_at_least_one_nei_with_2_conn(mol)
¶
- number of bonds where both atoms have at least one neighbor (not considering the bond atoms) with more than 2 connections
Source code in molfeat/calc/skeys.py
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 |
|
n_carbon_atleast_2_heteroatoms(mol)
¶
- number of carbon atoms connected to at least 2 heteroatoms
Source code in molfeat/calc/skeys.py
275 276 277 278 279 280 281 |
|
n_carbon_het_carbon_het_bonds(mol)
¶
- number of bonds connecting 2 heteroatoms through 2 carbons
Source code in molfeat/calc/skeys.py
317 318 319 320 |
|
n_exocyclic_single_bonds_carbon(mol)
¶
- number of exocyclic single bonds where a ring atom is carbon
Source code in molfeat/calc/skeys.py
327 328 329 330 |
|
n_exocyclic_single_bonds_nitrogen(mol)
¶
- number of exocyclic single bonds where a ring atom is nitrogen
Source code in molfeat/calc/skeys.py
332 333 334 335 |
|
n_heteroatom_more_than_2_conn(mol)
¶
- number of heteroatoms with more than 2 connections
Source code in molfeat/calc/skeys.py
270 271 272 273 |
|
n_heteroatoms(mol)
¶
- number of heteroatoms
Source code in molfeat/calc/skeys.py
255 256 257 258 259 |
|
n_heteroatoms_in_ring(mol)
¶
- number of heteroatoms in rings
Source code in molfeat/calc/skeys.py
261 262 263 264 |
|
n_multiple_non_conj_ring_bonds(mol)
¶
- number of multiple, nonconjugated ring bonds
Source code in molfeat/calc/skeys.py
300 301 302 303 304 305 306 307 308 309 310 |
|
n_nitrogen(mol)
¶
- number of nitrogen
Source code in molfeat/calc/skeys.py
230 231 232 233 |
|
n_nitrogen_in_ring(mol)
¶
- number of nitrogen in rings
Source code in molfeat/calc/skeys.py
235 236 237 238 |
|
n_non_ring_bonds_2_conj_rings(mol)
¶
- number of non-ring bonds connecting 2 nonconjugated rings
Source code in molfeat/calc/skeys.py
337 338 339 340 341 342 343 344 345 346 347 348 349 |
|
n_non_ring_bonds_conj_nonconj_rings(mol)
¶
- number of non-ring bonds connecting 2 rings, one of them conjugated and one non-conjugated
Source code in molfeat/calc/skeys.py
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 |
|
n_oxygen(mol)
¶
- number of oxygen
Source code in molfeat/calc/skeys.py
240 241 242 243 |
|
n_oxygen_in_ring(mol)
¶
- number of oxygen in rings
Source code in molfeat/calc/skeys.py
245 246 247 248 |
|
n_ring_system(mol)
¶
- number of ring systems
Source code in molfeat/calc/skeys.py
443 444 445 446 |
|
n_ring_system_with_2_conj_simple_ring(mol)
¶
- number of rings systems with 2 conjugated simple rings
Source code in molfeat/calc/skeys.py
460 461 462 463 464 465 466 467 468 469 470 |
|
n_ring_system_with_2_non_conj_simple_ring(mol)
¶
- number of rings systems with 2 non-conjugated simple rings
Source code in molfeat/calc/skeys.py
448 449 450 451 452 453 454 455 456 457 458 |
|
n_ring_system_with_3_conj_simple_ring(mol)
¶
- number of rings systems with 3 conjugated simple rings
Source code in molfeat/calc/skeys.py
485 486 487 488 489 490 491 492 493 494 495 |
|
n_ring_system_with_3_non_conj_simple_ring(mol)
¶
- number of rings systems with 3 non-conjugated simple rings
Source code in molfeat/calc/skeys.py
497 498 499 500 501 502 503 504 505 506 507 |
|
n_ring_system_with_conj_non_conj_simple_ring(mol)
¶
39 number of ring system containing 2 simple rings, one conjugated and one nonconjugated
Source code in molfeat/calc/skeys.py
472 473 474 475 476 477 478 479 480 481 482 483 |
|
n_ring_system_with_greater_one_conj_nonconj_simple_ring(mol)
¶
- number of ring system containing 3 simple rings, at least one conjugated and one nonconjugated
Source code in molfeat/calc/skeys.py
509 510 511 512 513 514 515 516 517 518 519 520 |
|
n_simple_non_conj_5_atoms_rings(mol)
¶
- number of simple non-conjugated rings with 5 atoms
Source code in molfeat/calc/skeys.py
425 426 427 428 429 430 431 432 |
|
n_simple_non_conj_6_atoms_rings(mol)
¶
- number of simple non-conjugated rings with 6 atoms
Source code in molfeat/calc/skeys.py
434 435 436 437 438 439 440 441 |
|
n_simple_rings(mol)
¶
- number of simple rings
Source code in molfeat/calc/skeys.py
390 391 392 393 |
|
n_simple_rings_1_heteroatoms(mol)
¶
- number of simple rings with 1 heteroatom
Source code in molfeat/calc/skeys.py
407 408 409 410 411 |
|
n_simple_rings_2_heteroatoms(mol)
¶
- number of simple rings with 2 heteroatom
Source code in molfeat/calc/skeys.py
413 414 415 416 417 |
|
n_simple_rings_at_least_3_heteroatoms(mol)
¶
- number of simple rings with 3 or more heteroatoms
Source code in molfeat/calc/skeys.py
419 420 421 422 423 |
|
n_simple_rings_no_heteroatoms(mol)
¶
- number of simple rings with no heteroatoms
Source code in molfeat/calc/skeys.py
401 402 403 404 405 |
|
n_sulfur(mol)
¶
- number of sulfur atoms
Source code in molfeat/calc/skeys.py
250 251 252 253 |
|
size_largest_ring(mol)
¶
- Size of the largest ring
Source code in molfeat/calc/skeys.py
395 396 397 398 399 |
|
skdistance(sk1, sk2, weights=None, cdist=False)
¶
Compute the scaffold distance between two scaffold keys as described in https://pubs.acs.org/doi/abs/10.1021/ci5001983. The input features are expected to be normalized beforehand (see paper)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sk1 |
ndarray
|
scaffold key 1 |
required |
sk2 |
ndarray
|
scaffold key 2 |
required |
weights |
Optional[ndarray]
|
how to weight each of the features. By default rank ordering is used. |
None
|
cdist |
bool
|
whether to compute the features on a batched of inputs (expected 2D) |
False
|
Returns:
Name | Type | Description |
---|---|---|
dist |
float
|
distance between two scaffold keys |
Source code in molfeat/calc/skeys.py
556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 |
|
Shape
¶
ElectroShapeDescriptors
¶
Bases: SerializableCalculator
Compute Electroshape descriptors as described by
Armstrong et al. ElectroShape: fast molecular similarity calculations incorporating shape, chirality and electrostatics. J Comput Aided Mol Des 24, 789-801 (2010). http://dx.doi.org/doi:10.1007/s10822-010-9374-0
Source code in molfeat/calc/shape.py
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 235 236 |
|
columns
property
¶
Get the name of all the descriptors of this calculator
__call__(mol, conformer_id=-1)
¶
Get rdkit 3D descriptors for a molecule
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mol |
Union[Mol, str]
|
the molecule of interest |
required |
conformer_id |
int
|
Optional conformer id. Defaults to -1. |
-1
|
Returns:
Name | Type | Description |
---|---|---|
shape_descriptor |
ndarray
|
computed shape descriptor |
Source code in molfeat/calc/shape.py
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 235 236 |
|
__init__(charge_model='gasteiger', replace_nan=False, electron_scaling=25.0, **kwargs)
¶
Constructor for ElectroShape descriptor
Parameters:
Name | Type | Description | Default |
---|---|---|---|
charge_model |
str
|
charge model to use. One of ('gasteiger', 'tripos', 'mmff94', 'formal'). Defaults to "gasteiger".
Note that formal charges will be computed on the fly if not provided in the input molecules.
The |
'gasteiger'
|
replace_nan |
bool
|
whether to replace NaN values. Defaults False |
False
|
electron_scaling |
float
|
scaling factor to convert electron charges to Angstroms. Defaults to 25.0. |
25.0
|
Source code in molfeat/calc/shape.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
|
__len__()
¶
Return the length of the calculator
Source code in molfeat/calc/shape.py
130 131 132 |
|
compute_charge(mol, charge_model=None)
staticmethod
¶
Get the molecular charge of the molecule.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
charge_model |
str
|
charge model to use. One of ('gasteiger', 'tripos', 'mmff94', 'formal'). Defaults to "gasteiger". |
None
|
Source code in molfeat/calc/shape.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 |
|
USRDescriptors
¶
Bases: SerializableCalculator
Descriptors for the shape of a molecule.
!!! note: The following shape descriptors are offered: * USR: UltraFast Shape Recognition * USRCAT: Ultrafast Shape Recognition with CREDO Atom Types
Source code in molfeat/calc/shape.py
13 14 15 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 |
|
columns
property
¶
Get the name of all the descriptors of this calculator
__call__(mol, conformer_id=-1)
¶
Get rdkit 3D descriptors for a molecule
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mol |
Union[Mol, str]
|
the molecule of interest |
required |
conformer_id |
Optional[int]
|
Optional conformer id. Defaults to -1. |
-1
|
Returns:
Name | Type | Description |
---|---|---|
shape_descriptors |
ndarray
|
list of computed molecular descriptors |
Source code in molfeat/calc/shape.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
|
__init__(method='USR', replace_nan=False, **kwargs)
¶
Constructor for ShapeDescriptors
Parameters:
Name | Type | Description | Default |
---|---|---|---|
method |
str
|
Shape descriptor method to use. One of 'USR', 'USRCAT'. Default to 'USR' |
'USR'
|
replace_nan |
bool
|
Whether to replace nan or infinite values. Defaults to False. |
False
|
Source code in molfeat/calc/shape.py
22 23 24 25 26 27 28 29 30 31 32 33 |
|
__len__()
¶
Compute descriptors length
Source code in molfeat/calc/shape.py
54 55 56 |
|
usrdistance(shape_1, shape_2, weights=None)
¶
Computes similarity between molecules
Parameters:
Name | Type | Description | Default |
---|---|---|---|
shape_1 |
USR shape descriptor of first molecule |
required | |
shape_2 |
USR shape descriptor |
required | |
weights |
Optional[List[float]]
|
List of scaling factor to use for |
None
|
Returns:
Name | Type | Description |
---|---|---|
dist |
Distance [0-1] between shapes of molecules, 0 indicates identical molecules |
Source code in molfeat/calc/shape.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
|
Atoms Featurizer
¶
AtomCalculator
¶
Bases: SerializableCalculator
Base class for computing atom properties compatible with DGLLife
Source code in molfeat/calc/atom.py
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 |
|
__call__(mol, dtype=None)
¶
Get rdkit basic descriptors for a molecule
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mol |
Union[Mol, str]
|
the molecule of interest |
required |
dtype |
Callable
|
requested data type |
None
|
Returns:
Name | Type | Description |
---|---|---|
dict |
For each function in self.featurizer_funcs with the key |
Source code in molfeat/calc/atom.py
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 |
|
__init__(featurizer_funcs=None, concat=True, name='hv')
¶
Init function of the atom property calculator
Parameters:
Name | Type | Description | Default |
---|---|---|---|
featurizer_funcs |
Mapping of feature name to the featurization function.
For compatibility a list of callable/function is still accepted, and the corresponding
featurizer name will be automatically generated. Each function is of signature
|
None
|
|
concat |
bool
|
Whether to concat all the data into a single value in the output dict |
True
|
name |
str
|
Name of the key name of the concatenated features |
'hv'
|
Source code in molfeat/calc/atom.py
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 |
|
__len__()
¶
Get length of the property estimator
Source code in molfeat/calc/atom.py
191 192 193 |
|
feat_size(feat_name=None)
¶
Get the feature size for feat_name
.
When there is only one feature, users do not need to provide feat_name
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
feat_name |
Feature for query. |
None
|
Returns:
Name | Type | Description |
---|---|---|
int |
Feature size for the feature with name |
Source code in molfeat/calc/atom.py
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 |
|
from_state_dict(state_dict, override_args=None)
classmethod
¶
Create an instance of an atom calculator from a state dict
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state_dict |
state dictionary to use to create the atom calculator |
required | |
override_args |
Optional[dict]
|
optional dictionary of arguments to override the ones in the state dict at construction of the new object |
None
|
Source code in molfeat/calc/atom.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
|
to_state_dict()
¶
Convert the Atom calculator to a state dict Due to some constraints and cross-version compatibility, the featurizer functions need to be pickled and not just return a list
Source code in molfeat/calc/atom.py
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 |
|
AtomMaterialCalculator
¶
Bases: AtomCalculator
Atom calculator with the extend atomic property list which have been collected from various material science packages
Source code in molfeat/calc/atom.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
|
DGLCanonicalAtomCalculator
¶
Bases: AtomCalculator
Default canonical featurizer for atoms used by dgllife
Source code in molfeat/calc/atom.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
|
DGLWeaveAtomCalculator
¶
Bases: DGLCanonicalAtomCalculator
Default atom featurizer used by WeaveNet in DGLLife
Source code in molfeat/calc/atom.py
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 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 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
|
__call__(mol, dtype=None)
¶
Get rdkit basic descriptors for a molecule
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mol |
Union[Mol, str]
|
the molecule of interest |
required |
dtype |
Callable
|
requested data type |
None
|
Returns:
Name | Type | Description |
---|---|---|
dict |
For each function in self.featurizer_funcs with the key |
Source code in molfeat/calc/atom.py
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
|
atom_weave_props(atom)
¶
Get the WeaveNet properties for an atom
Source code in molfeat/calc/atom.py
353 354 355 356 357 |
|
Bonds Featurizer
¶
BondCalculator
¶
Bases: SerializableCalculator
A class for bond featurizer which loops over all bonds in a molecule and
featurizes them with the featurizer_funcs
. The constructed graph is assumed to be
a bi-directed graph by default.
Source code in molfeat/calc/bond.py
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 235 236 237 238 239 240 |
|
__call__(mol, dtype=None, **kwargs)
¶
Featurize all bonds in a molecule.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mol |
Union[Mol, str]
|
the molecule of interest |
required |
dtype |
Callable
|
requested data type |
None
|
Returns:
Name | Type | Description |
---|---|---|
dict |
For each function in self.featurizer_funcs with the key |
Source code in molfeat/calc/bond.py
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 235 236 237 238 239 240 |
|
__init__(featurizer_funcs=None, self_loop=False, concat=True, name='he')
¶
Init function of the bond property calculator
Parameters:
Name | Type | Description | Default |
---|---|---|---|
featurizer_funcs |
Union[list, dict]
|
Mapping feature name to the featurization function. |
None
|
self_loop |
bool
|
Whether self loops will be added. Default to False. If True, an additional column of binary values to indicate the identity of self loops will be added. The other features of the self loops will be zero. |
False
|
concat |
bool
|
Whether to concat all the data into a single value in the output dict |
True
|
name |
str
|
Name of the key name of the concatenated features |
'he'
|
Source code in molfeat/calc/bond.py
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 |
|
__len__()
¶
Get length of the property estimator
Source code in molfeat/calc/bond.py
174 175 176 |
|
feat_size(feat_name=None)
¶
Get the feature size for feat_name
.
When there is only one feature, feat_name
can be None.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
feat_name |
Optional[str]
|
Feature for query. |
None
|
Returns:
Name | Type | Description |
---|---|---|
int |
Feature size for the feature with name |
Source code in molfeat/calc/bond.py
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 |
|
from_state_dict(state_dict, override_args=None)
classmethod
¶
Create an instance of an atom calculator from a state dict
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state_dict |
state dictionary to use to create the atom calculator |
required | |
override_args |
Optional[dict]
|
optional dictionary of arguments to override the ones in the state dict at construction of the new object |
None
|
Source code in molfeat/calc/bond.py
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 |
|
to_state_dict()
¶
Convert the Atom calculator to a state dict Due to some constraints and cross-version compatibility, the featurizer functions need to be pickled and not just list
Source code in molfeat/calc/bond.py
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 |
|
DGLCanonicalBondCalculator
¶
Bases: BondCalculator
Source code in molfeat/calc/bond.py
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 |
|
DGLWeaveEdgeCalculator
¶
Bases: EdgeMatCalculator
Edge featurizer used by WeaveNets
The edge featurization is introduced in Molecular Graph Convolutions:
Moving Beyond Fingerprints <https://arxiv.org/abs/1603.00856>
__.
This featurization is performed for a complete graph of atoms with self loops added, which considers the following default:
- Number of bonds between each pairs of atoms
- One-hot encoding of bond type if a bond exists between a pair of atoms
- Whether a pair of atoms belongs to a same ring
Source code in molfeat/calc/bond.py
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 |
|
EdgeMatCalculator
¶
Bases: BondCalculator
Generate edge featurizer matrix
Source code in molfeat/calc/bond.py
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 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 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 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 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 |
|
__call__(mol, dtype=None, flat=True)
¶
Featurize all bonds in a molecule.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mol |
Union[Mol, str]
|
the molecule of interest |
required |
dtype |
Callable
|
requested data type |
None
|
flat |
bool
|
whether to return a collapsed N^2, M or a N, N, M matrix |
True
|
Returns:
Name | Type | Description |
---|---|---|
dict |
For each function in self.featurizer_funcs with the key |
Source code in molfeat/calc/bond.py
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 |
|
__init__(featurizer_funcs=None, pairwise_atom_funcs='default', name='he')
¶
Init function of the edge matrix property calculator
Parameters:
Name | Type | Description | Default |
---|---|---|---|
featurizer_funcs |
Union[list, dict]
|
Mapping feature name to the featurization function. |
None
|
pairwise_atom_funcs |
Union[list, dict, str]
|
Mapping feature name to pairwise featurization function. Use the keywords "default" for the default values |
'default'
|
Source code in molfeat/calc/bond.py
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
|
feat_size(feat_name=None)
¶
Get the feature size for feat_name
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
feat_name |
Optional[str]
|
Feature for query. |
None
|
Returns:
Name | Type | Description |
---|---|---|
int |
Feature size for the feature with name |
Source code in molfeat/calc/bond.py
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 |
|
from_state_dict(state_dict, override_args=None)
classmethod
¶
Create an instance of an atom calculator from a state dict
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state_dict |
state dictionary to use to create the atom calculator |
required | |
override_args |
Optional[dict]
|
optional dictionary of arguments to override the ones in the state dict at construction of the new object |
None
|
Source code in molfeat/calc/bond.py
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
|
to_state_dict()
¶
Convert the Atom calculator to a state dict Due to some constraints and cross-version compatibility, the featurizer functions need to be pickled and not just list
Source code in molfeat/calc/bond.py
278 279 280 281 282 283 284 285 286 287 288 289 |
|