datamol.viz
¶
Vizualize molecule in 2D or 3D¶
Generate an image out of a molecule or a list of molecules.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mols |
Union[List[dm.Mol], dm.Mol]
|
One or a list of molecules. |
required |
legends |
Union[List[Union[str, None]], str, None]
|
A string or a list of string as legend for every molecules. |
None
|
n_cols |
int
|
Number of molecules per column. |
4
|
use_svg |
bool
|
Whether to ouput an SVG (or a PNG). |
True
|
mol_size |
Union[Tuple[int, int], int]
|
A int or a tuple of int defining the size per molecule. |
(300, 300)
|
highlight_atom |
Optional[List[List[int]]]
|
the atoms to highlight. |
None
|
highlight_bond |
Optional[List[List[int]]]
|
The bonds to highlight. |
None
|
outfile |
Optional[str]
|
Path where to save the image (local or remote path). |
None
|
max_mols |
int
|
The maximum number of molecules to display. |
32
|
copy |
bool
|
Whether to copy the molecules or not. |
True
|
indices |
bool
|
Whether to draw the atom indices. |
False
|
bond_indices |
bool
|
Whether to draw the bond indices. |
False
|
bond_line_width |
int
|
The width of the bond lines. |
2
|
legend_fontsize |
int
|
Font size for the legend. |
16
|
kekulize |
bool
|
Run kekulization routine on molecules. Skipped if fails. |
True
|
align |
Union[dm.Mol, str, bool]
|
Whether to align the 2D coordinates of the molecules.
- If set to True, align all molecules with |
False
|
**kwargs |
Any
|
Additional arguments to pass to the drawing function. See RDKit
documentation related to |
{}
|
Source code in datamol/viz/_viz.py
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 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 |
|
Visualize the conformer(s) of a molecule.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mol |
Chem.rdchem.Mol
|
a molecule. |
required |
conf_id |
int
|
The ID of the conformer to show. -1 shows
the first conformer. Only works if |
-1
|
n_confs |
Union[int, List[int]]
|
Can be a number of conformers to shows or a list of conformer indices. When None, only the first conformer is displayed. When -1, show all conformers. |
None
|
align_conf |
bool
|
Whether to align conformers together. |
True
|
n_cols |
int
|
Number of columns. Defaults to 3. |
3
|
sync_views |
bool
|
Wether to sync the multiple views. |
True
|
remove_hs |
bool
|
Wether to remove the hydrogens of the conformers. |
True
|
width |
str
|
The width of the returned view. Defaults to "auto". |
'auto'
|
Source code in datamol/viz/_conformers.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 |
|
Specific plotting functions¶
Source code in datamol/viz/_circle_grid.py
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 |
|
__init__(center_mol, circle_mols, legend=None, mol_size=(200, 200), circle_margin=50, act_mapper=None)
¶
Show molecules in concentric rings, with one molecule at the center
Parameters:
Name | Type | Description | Default |
---|---|---|---|
center_mol |
Chem.rdchem.Mol
|
Molecule at center |
required |
circle_mols |
List[List[Chem.rdchem.Mol]]
|
List of molecule for each concentric circle around the center mol |
required |
mol_size |
Tuple[int, int]
|
Tuple of width and height for each molecule |
(200, 200)
|
circle_margin |
int
|
Margin between the circle layers |
50
|
act_mapper |
Optional[dict]
|
Map each molecule to a dictionary of activity |
None
|
Source code in datamol/viz/_circle_grid.py
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 |
|
Show molecules in concentric rings, with one molecule at the center
Parameters:
Name | Type | Description | Default |
---|---|---|---|
center_mol |
Chem.Mol
|
Molecule at center |
required |
circle_mols |
list of list of <Chem.Mol>
|
List of molecule for each concentric circle around the center mol |
required |
mol_size |
tuple
|
Tuple of width and height for each molecule |
(200, 200)
|
circle_margin |
int
|
Margin between the circle layers |
50
|
act_mapper |
dict
|
Map each molecule to a dictionary of activity |
None
|
Source code in datamol/viz/_circle_grid.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|
Vizualize 2D molecule with highlighted substructures¶
A generalized interface to access both highlighting options whether the input is as a smiles, smarts or mol
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_molecule |
Union[str, dm.Mol]
|
The molecule to be highlighted |
required |
search_molecules |
Union[str, List[str], dm.Mol, List[dm.Mol]]
|
The substructure to be identified |
required |
mol_size |
Tuple[int, int]
|
The size of the image to be returned |
(300, 300)
|
use_svg |
Optional[bool]
|
Whether to return an svg or png image |
True
|
r_min |
float
|
Radius of the smallest circle around atoms. Length is relative to average bond length (1 = avg. bond len). |
0.3
|
r_dist |
float
|
Incremental increase of radius for the next substructure. |
0.13
|
relative_bond_width |
float
|
Distance of line to "bond" (line segment between the two atoms). Size is relative to |
0.5
|
line_width |
int
|
width of drawn lines. |
2
|
color_list |
Optional[List[ColorTuple]]
|
List of tuples with RGBA or RGB values specifying the color of the highlighting. |
None
|
**kwargs |
Any
|
Additional arguments to pass to the drawing function. See RDKit
documentation related to |
{}
|
Source code in datamol/viz/_lasso_highlight.py
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 |
|