Chem.AvailDescriptors

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

# Source Code for Module Chem.AvailDescriptors

     1  ## Automatically adapted for numpy.oldnumeric Jun 27, 2008 by -c
     2
     3  # $Id: AvailDescriptors.py 797 2008-08-19 03:13:06Z 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 Chem import GraphDescriptors,MolSurf,Lipinski,Fragments,Crippen,Descriptors
    14  from Chem.EState import EState_VSA
    15  mods = [GraphDescriptors,MolSurf,EState_VSA,Lipinski,Descriptors,Crippen,Fragments]
    16
    17  import numpy.oldnumeric as Numeric,Chem
    18  otherMods = [Numeric,Chem]
    19
    20  others = []
    21  for mod in otherMods:
    22    tmp = dir(mod)
    23    for name in tmp:
    24      if name[0] != '_':
    25        thing = getattr(mod,name)
    26        if hasattr(thing,'__call__'):
    27          others.append(name)
    28
    29  descList = []
    30  descDict = {}
    31  for mod in mods:
    32    tmp = dir(mod)
    33
    34    for name in tmp:
    35      if name[0] != '_' and name[-1] != '_' and name not in others:
    36        # filter out python reference implementations:
    37        if name[:2]=='py' and name[2:] in tmp:
    38          continue
    39        thing = getattr(mod,name)
    40        if hasattr(thing,'__call__'):
    41          descList.append((name,thing))
    42          descDict[name] = thing
    43
    44 -def Desensitize():
    45    """ puts in all upper and all lower case versions of each
    46    descriptor name
    47    """
    48    ks = descDict.keys()
    49    for k in ks:
    50      fn = descDict[k]
    51      descDict[k.upper()]=fn
    52      descDict[k.lower()]=fn
    53
    54
    55  if __name__ == '__main__':
    56    import Chem
    57
    58    m = Chem.MolFromSmiles('CCOC')
    59    for name,fn in descs:
    60      print name,fn(m)
    61