|
Package rdkit ::
Package Chem
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13 """ A module for molecules and stuff
14
15 see Chem/index.html in the doc tree for documentation
16
17 """
18 from rdkit import rdBase
19 from rdkit import RDConfig
20
21 from rdkit import DataStructs
22 from rdkit.Geometry import rdGeometry
23 import PeriodicTable as pyPeriodicTable
24 import rdchem
25 _HasSubstructMatchStr=rdchem._HasSubstructMatchStr
26 from rdchem import *
27 from rdmolfiles import *
28 from rdmolops import *
29 from inchi import *
30
38
42
61
63 """
64 >>> from rdkit import Chem
65 >>> mol = Chem.MolFromSmiles('[C@H](Cl)(F)Br')
66 >>> FindMolChiralCenters(mol)
67 [(0, 'R')]
68 >>> mol = Chem.MolFromSmiles('[C@@H](Cl)(F)Br')
69 >>> FindMolChiralCenters(mol)
70 [(0, 'S')]
71
72 >>> FindMolChiralCenters(Chem.MolFromSmiles('CCC'))
73 []
74
75 By default unassigned stereo centers are not reported:
76 >>> mol = Chem.MolFromSmiles('C[C@H](F)C(F)(Cl)Br')
77 >>> FindMolChiralCenters(mol)
78 [(1, 'S')]
79
80 but this can be changed:
81 >>> FindMolChiralCenters(mol,includeUnassigned=True)
82 [(1, 'S'), (3, '?')]
83
84 The handling of dependent stereochemistry is not correct:
85 >>> Chem.FindMolChiralCenters(Chem.MolFromSmiles('C1CC(C)C(C)C(C)C1'),includeUnassigned=True)
86 [(2, '?'), (6, '?')]
87 >>> Chem.FindMolChiralCenters(Chem.MolFromSmiles('C1C[C@H](C)C(C)[C@H](C)C1'),includeUnassigned=True)
88 [(2, 'S'), (6, 'R')]
89
90 """
91 AssignStereochemistry(mol,force=force, flagPossibleStereoCenters=includeUnassigned)
92 centers = []
93 for atom in mol.GetAtoms():
94 if atom.HasProp('_CIPCode'):
95 centers.append((atom.GetIdx(),atom.GetProp('_CIPCode')))
96 elif includeUnassigned and atom.HasProp('_ChiralityPossible'):
97 centers.append((atom.GetIdx(),'?'))
98 return centers
99
100
101
102
103
105 import doctest,sys
106 return doctest.testmod(sys.modules["__main__"])
107
108
109 if __name__ == '__main__':
110 import sys
111 failed,tried = _test()
112 sys.exit(failed)
113