Package rdkit :: Package Chem :: Module Lipinski
[hide private]
[frames] | no frames]

Source Code for Module rdkit.Chem.Lipinski

 1  # 
 2  # Copyright (C) 2001-2006 greg Landrum and Rational Discovery LLC 
 3  # 
 4  #   @@ All Rights Reserved @@ 
 5  #  This file is part of the RDKit. 
 6  #  The contents are covered by the terms of the BSD license 
 7  #  which is included in the file license.txt, found at the root 
 8  #  of the RDKit source tree. 
 9  # 
10  """ Calculation of Lipinski parameters for molecules 
11   
12  """ 
13  from rdkit import Chem 
14  from rdkit.Chem import rdMolDescriptors 
15   
16  # ----------------------------------- 
17  # on import build the SMARTS patterns so we only have to do it once 
18  # ----------------------------------- 
19  # The Daylight SMARTS expressions for 
20  # recognizing H-bond donors and acceptors in the Lipinski scheme. 
21  # HDonor     '[!#6;!H0;-0]' 
22  # HAcceptor  '[$([!#6;+0]);!$([F,Cl,Br,I]); 
23  #             !$([o,s,nX3]);!$([Nv5,Pv5,Sv4,Sv6])]' 
24  # Heteroatom '[B,N,O,P,S,F,Cl,Br,I]' 
25  # 2 definitions adapted from those in the Gobbi Paper 
26  #  NOTE: if you want traditional Lipinski numbers, you 
27  #  should use NOCounts (below) instead of HAcceptor 
28  # 
29  HDonorSmarts = Chem.MolFromSmarts('[$([N;!H0;v3]),$([N;!H0;+1;v4]),$([O,S;H1;+0]),$([n;H1;+0])]') 
30  # changes log for HAcceptorSmarts: 
31  #  v2, 1-Nov-2008, GL : fix amide-N exclusion; remove Fs from definition 
32  HAcceptorSmarts = Chem.MolFromSmarts('[$([O,S;H1;v2]-[!$(*=[O,N,P,S])]),' + 
33                                       '$([O,S;H0;v2]),$([O,S;-]),$([N;v3;!$(N-*=!@[O,N,P,S])]),' + 
34                                       '$([nH0,o,s;+0])]') 
35   
36  HeteroatomSmarts = Chem.MolFromSmarts('[!#6;!#1]') 
37  #  NOTE: the Rotatable bond smarts here doesn't treat deuteriums (which are left in the graph 
38  #  and therefore contribute to the degree of a carbon) the same as hydrogens (which are removed 
39  #  from the graph). So the bond in [2H]C([2H])([2H])C([2H])([2H])[2H] *is* considered 
40  #  rotatable. 
41  RotatableBondSmarts = Chem.MolFromSmarts('[!$(*#*)&!D1]-&!@[!$(*#*)&!D1]') 
42  NHOHSmarts = Chem.MolFromSmarts('[#8H1,#7H1,#7H2,#7H3]') 
43  NOCountSmarts = Chem.MolFromSmarts('[#7,#8]') 
44   
45  # # this little trick saves duplicated code 
46  # def _NumMatches(mol, smarts): 
47  #   return len(mol.GetSubstructMatches(smarts, uniquify=1)) 
48   
49  NumHDonors = lambda x: rdMolDescriptors.CalcNumHBD(x) 
50  NumHDonors.__doc__ = "Number of Hydrogen Bond Donors" 
51  NumHDonors.version = "1.0.0" 
52  _HDonors = lambda x, y=HDonorSmarts: x.GetSubstructMatches(y, uniquify=1) 
53  NumHAcceptors = lambda x: rdMolDescriptors.CalcNumHBA(x) 
54  NumHAcceptors.__doc__ = "Number of Hydrogen Bond Acceptors" 
55  NumHAcceptors.version = "2.0.0" 
56  _HAcceptors = lambda x, y=HAcceptorSmarts: x.GetSubstructMatches(y, uniquify=1) 
57  NumHeteroatoms = lambda x: rdMolDescriptors.CalcNumHeteroatoms(x) 
58  NumHeteroatoms.__doc__ = "Number of Heteroatoms" 
59  NumHeteroatoms.version = "1.0.0" 
60  _Heteroatoms = lambda x, y=HeteroatomSmarts: x.GetSubstructMatches(y, uniquify=1) 
61  NumRotatableBonds = lambda x: rdMolDescriptors.CalcNumRotatableBonds(x) 
62  NumRotatableBonds.__doc__ = "Number of Rotatable Bonds" 
63  NumRotatableBonds.version = "1.0.0" 
64  _RotatableBonds = lambda x, y=RotatableBondSmarts: x.GetSubstructMatches(y, uniquify=1) 
65  NOCount = lambda x: rdMolDescriptors.CalcNumLipinskiHBA(x) 
66  NOCount.__doc__ = "Number of Nitrogens and Oxygens" 
67  NOCount.version = "1.0.0" 
68  NHOHCount = lambda x: rdMolDescriptors.CalcNumLipinskiHBD(x) 
69  NHOHCount.__doc__ = "Number of NHs or OHs" 
70  NHOHCount.version = "2.0.0" 
71   
72  RingCount = lambda x: rdMolDescriptors.CalcNumRings(x) 
73  RingCount.version = "1.0.0" 
74   
75   
76 -def HeavyAtomCount(mol):
77 " Number of heavy atoms a molecule." 78 return mol.GetNumHeavyAtoms()
79 80 81 HeavyAtomCount.version = "1.0.1" 82 83 _bulkConvert = ("CalcFractionCSP3", "CalcNumAromaticRings", "CalcNumSaturatedRings", 84 "CalcNumAromaticHeterocycles", "CalcNumAromaticCarbocycles", 85 "CalcNumSaturatedHeterocycles", "CalcNumSaturatedCarbocycles", 86 "CalcNumAliphaticRings", "CalcNumAliphaticHeterocycles", 87 "CalcNumAliphaticCarbocycles") 88 for txt in _bulkConvert: 89 _cfn = getattr(rdMolDescriptors, txt) 90 _fn = lambda x, y=_cfn: y(x) 91 try: 92 _fn.version = getattr(rdMolDescriptors, "_" + txt + "_version") 93 except AttributeError: 94 pass 95 _fn.__doc__ = _cfn.__doc__ 96 nm = txt.replace("Calc", "") 97 locals()[nm] = _fn 98