Package rdkit :: Package Chem :: Package EState :: Module EState_VSA

[hide private]
[frames] | no frames]

# Source Code for Module rdkit.Chem.EState.EState_VSA

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