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

Source Code for Module rdkit.Chem.EState.EState_VSA

  1  ## Automatically adapted for numpy.oldnumeric Jun 27, 2008 by -c 
  2   
  3  # $Id: EState_VSA.py 997 2009-02-25 06:12:43Z glandrum $ 
  4  # 
  5  # Copyright (C)2003-2006 greg Landrum and Rational Discovery LLC 
  6  # 
  7  #   @@ All Rights Reserved  @@ 
  8  # 
  9  """ Hybrid EState-VSA descriptors (like the MOE VSA descriptors) 
 10   
 11  """ 
 12  import numpy.oldnumeric as Numeric 
 13  from rdkit.Chem.EState.EState import EStateIndices as EStateIndices_ 
 14  from rdkit.Chem.MolSurf import _LabuteHelper as VSAContribs_ 
 15  import bisect 
 16   
 17  """ 
 18   
 19  These default VSA bins were chosen using the PP3K solubility data 
 20  set.  An arbitrary number of bins were selected and the 
 21  boundaries were selected to give an approximately equal number of 
 22  atoms per bin 
 23   
 24  """ 
 25  vsaBins=[4.78,5.00,5.410,5.740,6.00,6.07,6.45,7.00,11.0] 
26 -def VSA_EState_(mol,bins=None,force=1):
27 """ *Internal Use Only* 28 """ 29 if not force and hasattr(mol,'_vsaEState'): 30 return mol._vsaEState 31 32 if bins is None: bins = estateBins 33 propContribs = EStateIndices_(mol,force=force) 34 volContribs = VSAContribs_(mol) 35 36 ans = Numeric.zeros(len(bins)+1,Numeric.Float) 37 for i,prop in enumerate(propContribs): 38 if prop is not None: 39 bin = bisect.bisect_right(bins,volContribs[i+1]) 40 ans[bin] += prop 41 mol._vsaEState=ans 42 return ans
43 44 45 """ 46 47 These default EState bins were chosen using the PP3K solubility data 48 set. An arbitrary number of bins (10) were selected and the 49 boundaries were selected to give an approximately equal number of 50 atoms per bin 51 52 """ 53 estateBins=[-0.390,0.290,0.717,1.165,1.540,1.807,2.05,4.69,9.17,15.0]
54 -def EState_VSA_(mol,bins=None,force=1):
55 """ *Internal Use Only* 56 """ 57 if not force and hasattr(mol,'_eStateVSA'): 58 return mol._eStateVSA 59 60 if bins is None: bins = estateBins 61 propContribs = EStateIndices_(mol,force=force) 62 volContribs = VSAContribs_(mol) 63 64 ans = Numeric.zeros(len(bins)+1,Numeric.Float) 65 for i,prop in enumerate(propContribs): 66 if prop is not None: 67 bin = bisect.bisect_right(bins,prop) 68 ans[bin] += volContribs[i+1] 69 mol._eStateVSA=ans 70 return ans
71 -def _InstallDescriptors():
72 for i in range(len(vsaBins)): 73 fn = lambda x,y=i:VSA_EState_(x,force=0)[y] 74 if i > 0: 75 fn.__doc__="VSA EState Descriptor %d (% 4.2f <= x < % 4.2f)"%(i+1,vsaBins[i-1],vsaBins[i]) 76 else: 77 fn.__doc__="VSA EState Descriptor %d (-inf < x < % 4.2f)"%(i+1,vsaBins[i]) 78 name="VSA_EState%d"%(i+1) 79 fn.version="1.0.0" 80 globals()[name]=fn 81 i+=1 82 fn = lambda x,y=i:VSA_EState_(x,force=0)[y] 83 fn.__doc__="VSA EState Descriptor %d (% 4.2f <= x < inf)"%(i+1,vsaBins[i-1]) 84 name="VSA_EState%d"%(i+1) 85 fn.version="1.0.0" 86 globals()[name]=fn 87 fn=None 88 89 for i in range(len(estateBins)): 90 fn = lambda x,y=i:EState_VSA_(x,force=0)[y] 91 if i > 0: 92 fn.__doc__="EState VSA Descriptor %d (% 4.2f <= x < % 4.2f)"%(i+1,estateBins[i-1],estateBins[i]) 93 else: 94 fn.__doc__="EState VSA Descriptor %d (-inf < x < % 4.2f)"%(i+1,estateBins[i]) 95 name="EState_VSA%d"%(i+1) 96 fn.version="1.0.1" 97 globals()[name]=fn 98 i+=1 99 fn = lambda x,y=i:EState_VSA_(x,force=0)[y] 100 fn.__doc__="EState VSA Descriptor %d (% 4.2f <= x < inf)"%(i+1,estateBins[i-1]) 101 name="EState_VSA%d"%(i+1) 102 fn.version="1.0.1" 103 globals()[name]=fn 104 fn=None
105 # Change log for EState_VSA descriptors: 106 # version 1.0.1: optimizations, values unaffected 107 _InstallDescriptors() 108