rdworks 0.52.1__tar.gz → 0.53.1__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.
- {rdworks-0.52.1 → rdworks-0.53.1}/PKG-INFO +1 -1
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/__init__.py +3 -3
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/mol.py +32 -1
- rdworks-0.53.1/src/rdworks/stereoisomers.py +67 -0
- rdworks-0.53.1/src/rdworks/workflow.py +85 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks.egg-info/PKG-INFO +1 -1
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks.egg-info/SOURCES.txt +1 -1
- rdworks-0.52.1/src/rdworks/stereoisomers.py +0 -127
- rdworks-0.52.1/src/rdworks/tautomers.py +0 -20
- {rdworks-0.52.1 → rdworks-0.53.1}/LICENSE +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/README.md +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/pyproject.toml +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/setup.cfg +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/autograph/__init__.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/autograph/autograph.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/autograph/centroid.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/autograph/dynamictreecut.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/autograph/nmrclust.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/autograph/rckmeans.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/bitqt/__init__.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/bitqt/bitqt.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/conf.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/descriptor.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/display.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/ionized.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/matchedseries.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/microstates.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/mollibr.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/pka.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/Asinex_fragment.xml +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/Astex_RO3.xml +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/Baell2010_PAINS/Baell2010A.xml +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/Baell2010_PAINS/Baell2010B.xml +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/Baell2010_PAINS/Baell2010C.xml +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/Baell2010_PAINS/PAINS-less-than-015-hits.xml +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/Baell2010_PAINS/PAINS-less-than-150-hits.xml +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/Baell2010_PAINS/PAINS-more-than-150-hits.xml +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/Baell2010_PAINS/makexml.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/Brenk2008_Dundee/makexml.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/CNS.xml +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/ChEMBL_Walters/BMS.xml +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/ChEMBL_Walters/Dundee.xml +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/ChEMBL_Walters/Glaxo.xml +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/ChEMBL_Walters/Inpharmatica.xml +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/ChEMBL_Walters/LINT.xml +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/ChEMBL_Walters/MLSMR.xml +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/ChEMBL_Walters/PAINS.xml +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/ChEMBL_Walters/SureChEMBL.xml +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/ChEMBL_Walters/makexml.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/Hann1999_Glaxo/Hann1999.xml +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/Hann1999_Glaxo/Hann1999Acid.xml +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/Hann1999_Glaxo/Hann1999Base.xml +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/Hann1999_Glaxo/Hann1999ElPh.xml +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/Hann1999_Glaxo/Hann1999NuPh.xml +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/Hann1999_Glaxo/makexml.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/Kazius2005/Kazius2005.xml +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/Kazius2005/makexml.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/ZINC_druglike.xml +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/ZINC_fragment.xml +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/ZINC_leadlike.xml +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/fragment.xml +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/ionized/simple_smarts_pattern.csv +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/ionized/smarts_pattern.csv +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/misc/makexml.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/misc/reactive-part-2.xml +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/misc/reactive-part-3.xml +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/predefined/misc/reactive.xml +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/readin.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/rgroup.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/scaffold.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/std.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/testdata.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/torsion.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/units.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/utils.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/xml.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/xtb/__init__.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks/xtb/wrapper.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks.egg-info/dependency_links.txt +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks.egg-info/requires.txt +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/src/rdworks.egg-info/top_level.txt +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/tests/test_basics.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/tests/test_ionized.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/tests/test_qupkake.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/tests/test_round.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/tests/test_torsion.py +0 -0
- {rdworks-0.52.1 → rdworks-0.53.1}/tests/test_xtb.py +0 -0
@@ -1,11 +1,11 @@
|
|
1
|
-
__version__ = '0.
|
1
|
+
__version__ = '0.53.1'
|
2
2
|
|
3
3
|
from rdworks.conf import Conf
|
4
4
|
from rdworks.mol import Mol
|
5
5
|
from rdworks.mollibr import MolLibr
|
6
6
|
|
7
|
-
from rdworks.
|
8
|
-
|
7
|
+
from rdworks.workflow import complete_stereoisomers, complete_tautomers
|
8
|
+
|
9
9
|
from rdworks.ionized import IonizedStates
|
10
10
|
|
11
11
|
from rdworks.readin import read_csv, merge_csv, read_dataframe, read_smi, read_sdf, read_mae
|
@@ -28,7 +28,6 @@ from rdkit.Chem import (
|
|
28
28
|
Draw, rdDepictor, inchi,
|
29
29
|
rdDistGeom, rdMolAlign, rdMolTransforms, rdmolops
|
30
30
|
)
|
31
|
-
from rdkit.Chem.Draw import rdMolDraw2D
|
32
31
|
from rdkit.ML.Cluster import Butina
|
33
32
|
from PIL import Image
|
34
33
|
|
@@ -43,6 +42,8 @@ from rdworks.autograph import NMRCLUST, DynamicTreeCut, RCKmeans, AutoGraph
|
|
43
42
|
from rdworks.bitqt import BitQT
|
44
43
|
from rdworks.torsion import create_torsion_fragment, get_torsion_atoms
|
45
44
|
from rdworks.display import render_svg, render_png
|
45
|
+
from rdworks.stereoisomers import enumerate_stereoisomers, enumerate_ring_bond_stereoisomers
|
46
|
+
|
46
47
|
|
47
48
|
from scour.scour import scourString
|
48
49
|
|
@@ -329,6 +330,36 @@ class Mol:
|
|
329
330
|
return self
|
330
331
|
|
331
332
|
|
333
|
+
def count_stereoisomers(self) -> int:
|
334
|
+
"""Counts number of all possible stereoisomers ignoring the current stereochemistry.
|
335
|
+
|
336
|
+
Returns:
|
337
|
+
int: number of stereoisomers.
|
338
|
+
"""
|
339
|
+
|
340
|
+
ring_bond_stereo_info = self.get_ring_bond_stereo()
|
341
|
+
mol = self.copy()
|
342
|
+
# remove stereochemistry
|
343
|
+
mol = mol.remove_stereo()
|
344
|
+
rdmols = enumerate_stereoisomers(mol.rdmol)
|
345
|
+
# ring bond stereo is not properly enumerated
|
346
|
+
# cis/trans information is lost if stereochemistry is removed,
|
347
|
+
# which cannot be enumerated by EnumerateStereoisomers() function
|
348
|
+
# so enumerate_ring_bond_stereoisomers() is introduced
|
349
|
+
if len(ring_bond_stereo_info) > 0:
|
350
|
+
ring_cis_trans = []
|
351
|
+
for rdmol in rdmols:
|
352
|
+
ring_cis_trans += enumerate_ring_bond_stereoisomers(rdmol,
|
353
|
+
ring_bond_stereo_info,
|
354
|
+
override=True)
|
355
|
+
if len(ring_cis_trans) > 0:
|
356
|
+
rdmols = ring_cis_trans
|
357
|
+
|
358
|
+
unique_rdmols = set([Chem.MolToSmiles(rdmol) for rdmol in rdmols])
|
359
|
+
|
360
|
+
return len(unique_rdmols)
|
361
|
+
|
362
|
+
|
332
363
|
def make_confs(self, n: int = 50, method: str = 'ETKDG', **kwargs) -> Self:
|
333
364
|
"""Generates 3D conformers.
|
334
365
|
|
@@ -0,0 +1,67 @@
|
|
1
|
+
from rdkit import Chem
|
2
|
+
from rdkit.Chem.EnumerateStereoisomers import EnumerateStereoisomers, StereoEnumerationOptions
|
3
|
+
|
4
|
+
|
5
|
+
def enumerate_stereoisomers(rdmol: Chem.Mol) -> list[Chem.Mol]:
|
6
|
+
"""Returns enumerated stereoisomers.
|
7
|
+
|
8
|
+
Args:
|
9
|
+
rdmol (Chem.Mol): input molecule.
|
10
|
+
|
11
|
+
Returns:
|
12
|
+
List[Chem.Mol]: a list of enumerated stereoisomers.
|
13
|
+
"""
|
14
|
+
return list(EnumerateStereoisomers(
|
15
|
+
rdmol,
|
16
|
+
options=StereoEnumerationOptions(
|
17
|
+
tryEmbedding=False,
|
18
|
+
onlyUnassigned=True,
|
19
|
+
maxIsomers=1024,
|
20
|
+
rand=None,
|
21
|
+
unique=True,
|
22
|
+
onlyStereoGroups=False,
|
23
|
+
)))
|
24
|
+
|
25
|
+
|
26
|
+
def enumerate_ring_bond_stereoisomers(rdmol: Chem.Mol,
|
27
|
+
ring_bond_stereo_info: list[tuple],
|
28
|
+
override: bool = False) -> list[Chem.Mol]:
|
29
|
+
"""Enumerates unspecified double bond stereochemistry (cis/trans).
|
30
|
+
|
31
|
+
<pre>
|
32
|
+
a1 a4 a1
|
33
|
+
\ / \
|
34
|
+
a2=a3 a2=a3
|
35
|
+
\
|
36
|
+
a4
|
37
|
+
</pre>
|
38
|
+
|
39
|
+
Args:
|
40
|
+
rdmol (Chem.Mol): input molecule.
|
41
|
+
ring_bond_stereo_info (List[Tuple]):
|
42
|
+
ring_bond_stereo_info will be set when .remove_stereo() is called.
|
43
|
+
bond_stereo_info = [(bond_idx, bond_stereo_descriptor), ..] where
|
44
|
+
bond_stereo_descriptor is `Chem.StereoDescriptor.Bond_Cis` or
|
45
|
+
`Chem.StereoDescriptor.Bond_Trans`, or `Chem.StereoDescriptor.NoValue`.
|
46
|
+
override (bool, optional): _description_. Defaults to False.
|
47
|
+
|
48
|
+
Returns:
|
49
|
+
List[Chem.Mol]: list of enumerated stereoisomers.
|
50
|
+
"""
|
51
|
+
isomers = []
|
52
|
+
for bond_idx, bond_stereo_desc in ring_bond_stereo_info:
|
53
|
+
if (bond_stereo_desc == Chem.StereoDescriptor.NoValue) or override:
|
54
|
+
bond = rdmol.GetBondWithIdx(bond_idx)
|
55
|
+
(a2,a3) = (bond.GetBeginAtom(), bond.GetEndAtom())
|
56
|
+
a2_idx = a2.GetIdx()
|
57
|
+
a3_idx = a3.GetIdx()
|
58
|
+
a1_idx = sorted([(a.GetIdx(), a.GetAtomicNum()) for a in a2.GetNeighbors() if a.GetIdx() != a3_idx], key=lambda x: x[1], reverse=True)[0][0]
|
59
|
+
a4_idx = sorted([(a.GetIdx(), a.GetAtomicNum()) for a in a3.GetNeighbors() if a.GetIdx() != a2_idx], key=lambda x: x[1], reverse=True)[0][0]
|
60
|
+
bond.SetStereoAtoms(a1_idx, a4_idx) # need to set reference atoms
|
61
|
+
# cis
|
62
|
+
bond.SetStereo(Chem.BondStereo.STEREOCIS)
|
63
|
+
isomers.append(Chem.Mol(rdmol))
|
64
|
+
# trans
|
65
|
+
bond.SetStereo(Chem.BondStereo.STEREOTRANS)
|
66
|
+
isomers.append(Chem.Mol(rdmol))
|
67
|
+
return isomers
|
@@ -0,0 +1,85 @@
|
|
1
|
+
|
2
|
+
from rdworks.stereoisomers import enumerate_stereoisomers, enumerate_ring_bond_stereoisomers
|
3
|
+
from rdworks.mol import Mol
|
4
|
+
from rdworks.mollibr import MolLibr
|
5
|
+
|
6
|
+
from rdkit import Chem
|
7
|
+
from rdkit.Chem.MolStandardize import rdMolStandardize
|
8
|
+
|
9
|
+
|
10
|
+
def complete_stereoisomers(molecular_input: str | Chem.Mol | Mol,
|
11
|
+
name: str | None = None,
|
12
|
+
std: bool = False,
|
13
|
+
override: bool = False,
|
14
|
+
**kwargs) -> MolLibr:
|
15
|
+
"""Completes stereoisomers and returns a rdworks.MolLibr.
|
16
|
+
|
17
|
+
Args:
|
18
|
+
molecular_input (Union[Mol, str, Chem.Mol]): input molecule.
|
19
|
+
name (Optional[str], optional): name of the molecule. Defaults to None.
|
20
|
+
std (bool, optional): whether to standardize the input. Defaults to False.
|
21
|
+
override (bool, optional): whether to override input stereoisomers. Defaults to False.
|
22
|
+
|
23
|
+
Raises:
|
24
|
+
TypeError: if `molecular_input` is not rdworks.Mol, SMILES, or rdkit.Chem.Mol object.
|
25
|
+
|
26
|
+
Returns:
|
27
|
+
MolLibr: a library of complete stereoisomers.
|
28
|
+
"""
|
29
|
+
if isinstance(molecular_input, Mol):
|
30
|
+
if name:
|
31
|
+
mol = molecular_input.rename(name)
|
32
|
+
else:
|
33
|
+
mol = molecular_input
|
34
|
+
elif isinstance(molecular_input, str) or isinstance(molecular_input, Chem.Mol):
|
35
|
+
mol = Mol(molecular_input, name, std)
|
36
|
+
else:
|
37
|
+
raise TypeError('complete_stereoisomers() expects rdworks.Mol, SMILES or rdkit.Chem.Mol object')
|
38
|
+
|
39
|
+
ring_bond_stereo_info = mol.get_ring_bond_stereo()
|
40
|
+
|
41
|
+
if override:
|
42
|
+
mol = mol.remove_stereo()
|
43
|
+
|
44
|
+
rdmols = enumerate_stereoisomers(mol.rdmol)
|
45
|
+
# ring bond stereo is not properly enumerated
|
46
|
+
# cis/trans information is lost if stereochemistry is removed,
|
47
|
+
# which cannot be enumerated by EnumerateStereoisomers() function
|
48
|
+
# so enumerate_ring_bond_stereoisomers() is introduced
|
49
|
+
if len(ring_bond_stereo_info) > 0:
|
50
|
+
ring_cis_trans = []
|
51
|
+
for rdmol in rdmols:
|
52
|
+
ring_cis_trans += enumerate_ring_bond_stereoisomers(rdmol,
|
53
|
+
ring_bond_stereo_info,
|
54
|
+
override=override)
|
55
|
+
if len(ring_cis_trans) > 0:
|
56
|
+
rdmols = ring_cis_trans
|
57
|
+
|
58
|
+
if len(rdmols) > 1:
|
59
|
+
libr = MolLibr(rdmols).unique().rename(mol.name, sep='.').compute(**kwargs)
|
60
|
+
else:
|
61
|
+
libr = MolLibr(rdmols).rename(mol.name).compute(**kwargs)
|
62
|
+
|
63
|
+
for _ in libr:
|
64
|
+
_.props.update(mol.props)
|
65
|
+
|
66
|
+
return libr
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
def complete_tautomers(mol: Mol, **kwargs) -> MolLibr:
|
71
|
+
"""Returns a library of enumerated tautomers.
|
72
|
+
|
73
|
+
Args:
|
74
|
+
mol (Mol): input molecule.
|
75
|
+
|
76
|
+
Returns:
|
77
|
+
MolLibr: a library of enumerated tautomers.
|
78
|
+
"""
|
79
|
+
enumerator = rdMolStandardize.TautomerEnumerator()
|
80
|
+
rdmols = list(enumerator.Enumerate(mol.rdmol))
|
81
|
+
|
82
|
+
if len(rdmols) > 1:
|
83
|
+
return MolLibr(rdmols).unique().rename(mol.name, sep='.').compute(**kwargs)
|
84
|
+
|
85
|
+
return MolLibr(rdmols).compute(**kwargs)
|
@@ -16,11 +16,11 @@ src/rdworks/rgroup.py
|
|
16
16
|
src/rdworks/scaffold.py
|
17
17
|
src/rdworks/std.py
|
18
18
|
src/rdworks/stereoisomers.py
|
19
|
-
src/rdworks/tautomers.py
|
20
19
|
src/rdworks/testdata.py
|
21
20
|
src/rdworks/torsion.py
|
22
21
|
src/rdworks/units.py
|
23
22
|
src/rdworks/utils.py
|
23
|
+
src/rdworks/workflow.py
|
24
24
|
src/rdworks/xml.py
|
25
25
|
src/rdworks.egg-info/PKG-INFO
|
26
26
|
src/rdworks.egg-info/SOURCES.txt
|
@@ -1,127 +0,0 @@
|
|
1
|
-
from typing import List, Tuple, Union, Optional
|
2
|
-
|
3
|
-
from rdkit import Chem
|
4
|
-
from rdkit.Chem.EnumerateStereoisomers import EnumerateStereoisomers, StereoEnumerationOptions
|
5
|
-
|
6
|
-
from .mol import Mol
|
7
|
-
from .mollibr import MolLibr
|
8
|
-
|
9
|
-
|
10
|
-
def _enum_stereoisomers(rdmol:Chem.Mol) -> List[Chem.Mol]:
|
11
|
-
"""Returns enumerated stereoisomers.
|
12
|
-
|
13
|
-
Args:
|
14
|
-
rdmol (Chem.Mol): input molecule.
|
15
|
-
|
16
|
-
Returns:
|
17
|
-
List[Chem.Mol]: a list of enumerated stereoisomers.
|
18
|
-
"""
|
19
|
-
return list(EnumerateStereoisomers(
|
20
|
-
rdmol,
|
21
|
-
options=StereoEnumerationOptions(
|
22
|
-
tryEmbedding=False,
|
23
|
-
onlyUnassigned=True,
|
24
|
-
maxIsomers=1024,
|
25
|
-
rand=None,
|
26
|
-
unique=True,
|
27
|
-
onlyStereoGroups=False,
|
28
|
-
)))
|
29
|
-
|
30
|
-
|
31
|
-
def _enum_ring_bond_stereo(rdmol:Chem.Mol, ring_bond_stereo_info:List[Tuple],
|
32
|
-
override:bool=False) -> List[Chem.Mol]:
|
33
|
-
"""Enumerates unspecified double bond stereochemistry (cis/trans).
|
34
|
-
|
35
|
-
<pre>
|
36
|
-
a1 a4 a1
|
37
|
-
\ / \
|
38
|
-
a2=a3 a2=a3
|
39
|
-
\
|
40
|
-
a4
|
41
|
-
</pre>
|
42
|
-
|
43
|
-
Args:
|
44
|
-
rdmol (Chem.Mol): input molecule.
|
45
|
-
ring_bond_stereo_info (List[Tuple]):
|
46
|
-
ring_bond_stereo_info will be set when .remove_stereo() is called.
|
47
|
-
bond_stereo_info = [(bond_idx, bond_stereo_descriptor), ..] where
|
48
|
-
bond_stereo_descriptor is `Chem.StereoDescriptor.Bond_Cis` or
|
49
|
-
`Chem.StereoDescriptor.Bond_Trans`, or `Chem.StereoDescriptor.NoValue`.
|
50
|
-
override (bool, optional): _description_. Defaults to False.
|
51
|
-
|
52
|
-
Returns:
|
53
|
-
List[Chem.Mol]: list of enumerated stereoisomers.
|
54
|
-
"""
|
55
|
-
isomers = []
|
56
|
-
for bond_idx, bond_stereo_desc in ring_bond_stereo_info:
|
57
|
-
if (bond_stereo_desc == Chem.StereoDescriptor.NoValue) or override:
|
58
|
-
bond = rdmol.GetBondWithIdx(bond_idx)
|
59
|
-
(a2,a3) = (bond.GetBeginAtom(), bond.GetEndAtom())
|
60
|
-
a2_idx = a2.GetIdx()
|
61
|
-
a3_idx = a3.GetIdx()
|
62
|
-
a1_idx = sorted([(a.GetIdx(), a.GetAtomicNum()) for a in a2.GetNeighbors() if a.GetIdx() != a3_idx], key=lambda x: x[1], reverse=True)[0][0]
|
63
|
-
a4_idx = sorted([(a.GetIdx(), a.GetAtomicNum()) for a in a3.GetNeighbors() if a.GetIdx() != a2_idx], key=lambda x: x[1], reverse=True)[0][0]
|
64
|
-
bond.SetStereoAtoms(a1_idx, a4_idx) # need to set reference atoms
|
65
|
-
# cis
|
66
|
-
bond.SetStereo(Chem.BondStereo.STEREOCIS)
|
67
|
-
isomers.append(Chem.Mol(rdmol))
|
68
|
-
# trans
|
69
|
-
bond.SetStereo(Chem.BondStereo.STEREOTRANS)
|
70
|
-
isomers.append(Chem.Mol(rdmol))
|
71
|
-
return isomers
|
72
|
-
|
73
|
-
|
74
|
-
def complete_stereoisomers(molecular_input:Union[Mol, str, Chem.Mol], name:Optional[str]=None,
|
75
|
-
std:bool=False, override:bool=False, **kwargs) -> MolLibr:
|
76
|
-
"""Completes stereoisomers and returns a rdworks.MolLibr.
|
77
|
-
|
78
|
-
Args:
|
79
|
-
molecular_input (Union[Mol, str, Chem.Mol]): input molecule.
|
80
|
-
name (Optional[str], optional): name of the molecule. Defaults to None.
|
81
|
-
std (bool, optional): whether to standardize the input. Defaults to False.
|
82
|
-
override (bool, optional): whether to override input stereoisomers. Defaults to False.
|
83
|
-
|
84
|
-
Raises:
|
85
|
-
TypeError: if `molecular_input` is not rdworks.Mol, SMILES, or rdkit.Chem.Mol object.
|
86
|
-
|
87
|
-
Returns:
|
88
|
-
MolLibr: a library of complete stereoisomers.
|
89
|
-
"""
|
90
|
-
if isinstance(molecular_input, Mol):
|
91
|
-
if name:
|
92
|
-
mol = molecular_input.rename(name)
|
93
|
-
else:
|
94
|
-
mol = molecular_input
|
95
|
-
elif isinstance(molecular_input, str) or isinstance(molecular_input, Chem.Mol):
|
96
|
-
mol = Mol(molecular_input, name, std)
|
97
|
-
else:
|
98
|
-
raise TypeError('complete_stereoisomers() expects rdworks.Mol, SMILES or rdkit.Chem.Mol object')
|
99
|
-
|
100
|
-
ring_bond_stereo_info = mol.get_ring_bond_stereo()
|
101
|
-
|
102
|
-
if override:
|
103
|
-
mol = mol.remove_stereo()
|
104
|
-
|
105
|
-
rdmols = _enum_stereoisomers(mol.rdmol)
|
106
|
-
# ring bond stereo is not properly enumerated
|
107
|
-
# cis/trans information is lost if stereochemistry is removed,
|
108
|
-
# which cannot be enumerated by EnumerateStereoisomers() function
|
109
|
-
# so _enum_bond_stereo() is introduced
|
110
|
-
if len(ring_bond_stereo_info) > 0:
|
111
|
-
ring_cis_trans = []
|
112
|
-
for rdmol in rdmols:
|
113
|
-
ring_cis_trans += _enum_ring_bond_stereo(rdmol,
|
114
|
-
ring_bond_stereo_info,
|
115
|
-
override=override)
|
116
|
-
if len(ring_cis_trans) > 0:
|
117
|
-
rdmols = ring_cis_trans
|
118
|
-
|
119
|
-
if len(rdmols) > 1:
|
120
|
-
libr = MolLibr(rdmols).unique().rename(mol.name, sep='.').compute(**kwargs)
|
121
|
-
else:
|
122
|
-
libr = MolLibr(rdmols).rename(mol.name).compute(**kwargs)
|
123
|
-
|
124
|
-
for _ in libr:
|
125
|
-
_.props.update(mol.props)
|
126
|
-
|
127
|
-
return libr
|
@@ -1,20 +0,0 @@
|
|
1
|
-
from rdkit.Chem.MolStandardize import rdMolStandardize
|
2
|
-
|
3
|
-
from .mol import Mol
|
4
|
-
from .mollibr import MolLibr
|
5
|
-
|
6
|
-
|
7
|
-
def complete_tautomers(mol:Mol, **kwargs) -> MolLibr:
|
8
|
-
"""Returns a library of enumerated tautomers.
|
9
|
-
|
10
|
-
Args:
|
11
|
-
mol (Mol): input molecule.
|
12
|
-
|
13
|
-
Returns:
|
14
|
-
MolLibr: a library of enumerated tautomers.
|
15
|
-
"""
|
16
|
-
enumerator = rdMolStandardize.TautomerEnumerator()
|
17
|
-
rdmols = list(enumerator.Enumerate(mol.rdmol))
|
18
|
-
if len(rdmols) > 1:
|
19
|
-
return MolLibr(rdmols).unique().rename(mol.name, sep='.').compute(**kwargs)
|
20
|
-
return MolLibr(rdmols).compute(**kwargs)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|