rdkit.Chem.AvailDescriptors

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

# Source Code for Module rdkit.Chem.AvailDescriptors

     1  ## Automatically adapted for numpy.oldnumeric Jun 27, 2008 by -c
     2
     3  # $Id: AvailDescriptors.py 997 2009-02-25 06:12:43Z glandrum $
     4  #
     5  # Copyright (C) 2001-2006 greg Landrum and Rational Discovery LLC
     6  #
     7  #   @@ All Rights Reserved  @@
     8  #
     9  """ constructs the list of available descriptors
    10
    11  """
    12  import types
    13  from rdkit.Chem import GraphDescriptors,MolSurf,Lipinski,Fragments,Crippen,Descriptors
    14  from rdkit.Chem.EState import EState_VSA
    15  mods = [GraphDescriptors,MolSurf,EState_VSA,Lipinski,Descriptors,Crippen,Fragments]
    16
    17  import numpy.oldnumeric as Numeric
    18  from rdkit import Chem
    19  otherMods = [Numeric,Chem]
    20
    21  others = []
    22  for mod in otherMods:
    23    tmp = dir(mod)
    24    for name in tmp:
    25      if name[0] != '_':
    26        thing = getattr(mod,name)
    27        if hasattr(thing,'__call__'):
    28          others.append(name)
    29
    30  descList = []
    31  descDict = {}
    32  for mod in mods:
    33    tmp = dir(mod)
    34
    35    for name in tmp:
    36      if name[0] != '_' and name[-1] != '_' and name not in others:
    37        # filter out python reference implementations:
    38        if name[:2]=='py' and name[2:] in tmp:
    39          continue
    40        thing = getattr(mod,name)
    41        if hasattr(thing,'__call__'):
    42          descList.append((name,thing))
    43          descDict[name] = thing
    44
    45 -def Desensitize():
    46    """ puts in all upper and all lower case versions of each
    47    descriptor name
    48    """
    49    ks = descDict.keys()
    50    for k in ks:
    51      fn = descDict[k]
    52      descDict[k.upper()]=fn
    53      descDict[k.lower()]=fn
    54
    55
    56  if __name__ == '__main__':
    57    from rdkit import Chem
    58
    59    m = Chem.MolFromSmiles('CCOC')
    60    for name,fn in descs:
    61      print name,fn(m)
    62